[PATCH v2 6/8] abg-dwarf-reader: migrate more ELF helpers to elf-helpers
Dodji Seketeli
dodji@seketeli.org
Wed Apr 22 09:53:18 GMT 2020
Matthias Maennich <maennich@google.com> a écrit:
> This change migrates all ELF helpers related to section lookup to
> abg-elf-helpers.{cc,h}. It also homogenizes the interface of those to
> always return Elf_Scn* and NULL in case that section can't be found.
> Though this smells like a functional change, this latter change is
> purely cosmetic.
>
> * src/abg-dwarf-reader.cc (read_context::find_symbol_table_section):
> adjust to new interface of elf_helpers::find_symbol_table_section.
> (find_opd_section): use elf_helpers::find_opd_section for lookup.
> (find_ksymtab_section): use elf_helpers::find_ksymtab_section.
> (find_ksymtab_gpl_section): use elf_helpers::find_ksymtab_gpl_section.
> (find_relocation_section): Move out function.
> (get_binary_load_address): Move out function.
> (find_ksymtab_reloc_section): use elf_helpers::find_relocation_section
> (find_ksymtab_gpl_reloc_section): use elf_helpers::find_relocation_section
> * src/elf-helpers.cc (find_symbol_table_section): change
> interface to match other find_*_section functions.
> (find_symbol_table_section_index): Adjust for the new interface
> of find_symbol_table_section.
> (find_opd_section): New function.
> (find_ksymtab_section): New function.
> (find_ksymtab_gpl_section): New function.
> (find_relocation_section): New function.
> (get_binary_load_address): New function.
> * src/elf-helpers.h (find_symbol_table_section): Change declaration.
> (find_opd_section): New function declation.
I am correcting the typo in "declation" here. Likewise for the
lines below, until ...
> (find_ksymtab_section): New function declation.
> (find_ksymtab_gpl_section): New function declation.
> (find_relocation_section): New function declation.
> (get_binary_load_address): New function declation.
... here.
[...]
> @@ -5282,8 +5235,8 @@ public:
> find_symbol_table_section() const
> {
> if (!symtab_section_)
> - dwarf_reader::find_symbol_table_section(elf_handle(),
> - const_cast<read_context*>(this)->symtab_section_);
> + const_cast<read_context*>(this)->symtab_section_ =
> + elf_helpers::find_symbol_table_section(elf_handle());
> return symtab_section_;
> }
I am declaring the read_context::symtab_section_ as mutable to avoid the
const_cast here.
>
> @@ -5296,8 +5249,8 @@ public:
> find_opd_section() const
> {
> if (!opd_section_)
> - const_cast<read_context*>(this)->opd_section_=
> - find_section(elf_handle(), ".opd", SHT_PROGBITS);
> + const_cast<read_context*>(this)->opd_section_ =
> + elf_helpers::find_opd_section(elf_handle());
> return opd_section_;
> }
Likewise.
>
> @@ -5310,39 +5263,21 @@ public:
> {
> if (!ksymtab_section_)
> const_cast<read_context*>(this)->ksymtab_section_ =
> - find_section(elf_handle(), "__ksymtab", SHT_PROGBITS);
> + elf_helpers::find_ksymtab_section(elf_handle());
> return ksymtab_section_;
> }
Likewise.
[...]
> Elf_Scn*
> - find_relocation_section(Elf_Scn* target_section) const
> + find_ksymtab_gpl_section() const
> {
[...]
> - return NULL;
> + if (!ksymtab_gpl_section_)
> + const_cast<read_context*>(this)->ksymtab_gpl_section_ =
> + elf_helpers::find_ksymtab_gpl_section(elf_handle());
> + return ksymtab_gpl_section_;
> }
Likewise.
>
> /// Return the .rel{a,}__ksymtab section of a linux kernel ELF file (either
> @@ -5354,25 +5289,12 @@ public:
> {
> if (!ksymtab_reloc_section_)
> {
> - const_cast<read_context*>(this)->ksymtab_reloc_section_
> - = find_relocation_section(find_ksymtab_section());
> + const_cast<read_context*>(this)->ksymtab_reloc_section_ =
> + find_relocation_section(elf_handle(), find_ksymtab_section());
> }
> return ksymtab_reloc_section_;
> }
Likewise.
[...]
> @@ -5382,8 +5304,8 @@ public:
> {
> if (!ksymtab_gpl_reloc_section_)
> {
> - const_cast<read_context*>(this)->ksymtab_gpl_reloc_section_
> - = find_relocation_section(find_ksymtab_gpl_section());
> + const_cast<read_context*>(this)->ksymtab_gpl_reloc_section_ =
> + find_relocation_section(elf_handle(), find_ksymtab_gpl_section());
> }
Likewise.
[...]
Applying to master with those changes, thanks!
Cheers,
--
Dodji
More information about the Libabigail
mailing list