mirror of
git://sourceware.org/git/libabigail.git
synced 2025-02-23 09:16:57 +00:00
In the use case laid out by the "Library Splitting support" at https://sourceware.org/bugzilla/show_bug.cgi?id=30034, tools might want to be able to re-initialize a given front-end to load several corpora in a row, independently from the kind of front-end (elf-based, ABIXML, etc). So we need a fe_iface::initialize() interface that is similar to the elf_based_reader::initialize() interface but, unlike that one, it should not depend on parameters that only make sense in a elf-based context. For instance, the fe_iface::initialize() interface should not contain paths to debug-info as that information does not make sense in an ABIXML context. This patch thus renames fe_iface::reset() into fe_iface::initialize() and makes it virtual. It adjusts the plumbing accordingly, basically making the other ::initialize() methods of classes that inherit fe_iface use fe_iface::initialize() when appropriate. The patch also provides an elf_based_reader::initialize() implementation of the fe_iface::initialize() interface, so that invoking ::initialize on elf_based_reader through the fe_iface interface does the right thing so that the initial use case presented at the beginning of this comment is supported. * include/abg-elf-based-reader.h (elf_based_reader::initialize): Rename elf_based_reader::reset into this. Add a new virtual overload that implements fe_iface::initialize. * include/abg-elf-reader.h (reader::initialize): Rename elf_reader::reset into this. Add a new virtual overload that implements fe_iface::initialize. * include/abg-fe-iface.h (fe_iface::initialize): Rename fe_iface::reset into this and make it virtual. * src/abg-btf-reader.cc (btf::reader::initialize): Adjust call to elf_based_reader::reset to elf_based_reader::initialize. * src/abg-ctf-reader.cc (ctf::reader::initialize): Likewise. * src/abg-dwarf-reader.cc (dwarf::reader::initialize): Likewise. * src/abg-elf-based-reader.cc (elf_based_reader::initialize): Rename elf_based_reader::reset into this. Adjust call to elf::reader::reset into elf::reader::initialize. Add a new virtual overload that implements fe_iface::initialize. * src/abg-elf-reader.cc (reader::initialize): Rename elf::reader::reset into this. Adjust call to fe_iface::reset into fe_iface::initialize. Add a new virtual overload that implements fe_iface::initialize. * src/abg-fe-iface.cc (fe_iface::priv::initialize): Reset the corpus too. (fe_iface::initialize): Rename fe_iface::reset into this. Invoke priv::initialize and set the new corpus_path. Signed-off-by: Dodji Seketeli <dodji@redhat.com>
177 lines
3.6 KiB
C++
177 lines
3.6 KiB
C++
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
// -*- Mode: C++ -*-
|
|
//
|
|
// Copyright (C) 2022-2023 Red Hat, Inc.
|
|
//
|
|
// Author: Dodji Seketeli
|
|
|
|
/// @file
|
|
///
|
|
/// This file contains the declarations for the @ref fe_iface a.k.a
|
|
/// "Front End Interface".
|
|
|
|
#ifndef __ABG_ELF_READER_H__
|
|
#define __ABG_ELF_READER_H__
|
|
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include <elfutils/libdwfl.h>
|
|
|
|
#include "abg-fe-iface.h"
|
|
#include "abg-ir.h"
|
|
#include "abg-suppression.h"
|
|
|
|
namespace abigail
|
|
{
|
|
|
|
/// The namespace for the ELF Reader.
|
|
namespace elf
|
|
{
|
|
|
|
/// The kind of ELF file we are looking at.
|
|
enum elf_type : unsigned
|
|
{
|
|
/// A normal executable binary
|
|
ELF_TYPE_EXEC,
|
|
/// A Position Independant Executable binary
|
|
ELF_TYPE_PI_EXEC,
|
|
/// A dynamic shared object, a.k.a shared library binary.
|
|
ELF_TYPE_DSO,
|
|
/// A relocatalbe binary.
|
|
ELF_TYPE_RELOCATABLE,
|
|
/// An unknown kind of binary.
|
|
ELF_TYPE_UNKNOWN
|
|
};
|
|
|
|
/// This is the interface an ELF reader.
|
|
///
|
|
/// It knows how to open an ELF file, read its content and expose an
|
|
/// interface for its symbol table and other properties.
|
|
///
|
|
/// Note that the ABI corpus returned by the elf::read_corpus()
|
|
/// member function doesn't contain any type representation. It only
|
|
/// contains the representations of the the ELF symbols found in the
|
|
/// ELF file.
|
|
///
|
|
/// To construct the type representations for the functions and global
|
|
/// variables present in the ELF file, please use the implementations
|
|
/// of the @ref elf_based_reader interface. Those know how to read
|
|
/// the debug information from the ELF file to build type
|
|
/// representation in the @ref abigail::ir::corpus instance.
|
|
class reader : public fe_iface
|
|
{
|
|
struct priv;
|
|
priv *priv_;
|
|
|
|
public:
|
|
|
|
reader(const std::string& elf_path,
|
|
const vector<char**>& debug_info_roots,
|
|
environment& env);
|
|
|
|
~reader();
|
|
|
|
virtual void
|
|
initialize(const std::string& elf_path,
|
|
const vector<char**>& debug_info_roots);
|
|
|
|
virtual void
|
|
initialize(const std::string& elf_path);
|
|
|
|
const vector<char**>&
|
|
debug_info_root_paths() const;
|
|
|
|
const Dwfl_Callbacks&
|
|
dwfl_offline_callbacks() const;
|
|
|
|
Dwfl_Callbacks&
|
|
dwfl_offline_callbacks();
|
|
|
|
Elf*
|
|
elf_handle() const;
|
|
|
|
const Dwarf*
|
|
dwarf_debug_info() const;
|
|
|
|
bool
|
|
has_dwarf_debug_info() const;
|
|
|
|
bool
|
|
has_ctf_debug_info() const;
|
|
|
|
bool
|
|
has_btf_debug_info() const;
|
|
|
|
const Dwarf*
|
|
alternate_dwarf_debug_info() const;
|
|
|
|
const string&
|
|
alternate_dwarf_debug_info_path() const;
|
|
|
|
bool
|
|
refers_to_alt_debug_info(string& alt_di_path) const;
|
|
|
|
const Elf_Scn*
|
|
find_symbol_table_section() const;
|
|
|
|
void
|
|
reset_symbol_table_section();
|
|
|
|
const Elf_Scn*
|
|
find_ctf_section() const;
|
|
|
|
const Elf_Scn*
|
|
find_alternate_ctf_section() const;
|
|
|
|
const Elf_Scn*
|
|
find_btf_section() const;
|
|
|
|
const vector<string>&
|
|
dt_needed()const;
|
|
|
|
const string&
|
|
elf_architecture() const;
|
|
|
|
symtab_reader::symtab_sptr&
|
|
symtab() const;
|
|
|
|
elf_symbol_sptr
|
|
function_symbol_is_exported(GElf_Addr symbol_address) const;
|
|
|
|
elf_symbol_sptr
|
|
variable_symbol_is_exported(GElf_Addr symbol_address) const;
|
|
|
|
elf_symbol_sptr
|
|
function_symbol_is_exported(const string& name) const;
|
|
|
|
elf_symbol_sptr
|
|
variable_symbol_is_exported(const string& name) const;
|
|
|
|
void
|
|
load_dt_soname_and_needed();
|
|
|
|
void
|
|
load_elf_architecture();
|
|
|
|
void
|
|
load_elf_properties();
|
|
|
|
virtual ir::corpus_sptr
|
|
read_corpus(status& status);
|
|
};//end class reader.
|
|
|
|
/// A convenience typedef for a smart pointer to a
|
|
/// elf::reader.
|
|
typedef shared_ptr<elf::reader> reader_sptr;
|
|
|
|
bool
|
|
get_soname_of_elf_file(const string& path, string &soname);
|
|
|
|
bool
|
|
get_type_of_elf_file(const string& path, elf_type& type);
|
|
} // end namespace elf.
|
|
} // end namespace abigail
|
|
|
|
#endif // __ABG_ELF_READER_H__
|