From: Dodji Seketeli <dodji@seketeli.org>
To: Matthias Maennich <maennich@google.com>
Cc: libabigail@sourceware.org, gprocida@google.com,
kernel-team@android.com
Subject: Re: [PATCH v2 6/8] abg-dwarf-reader: migrate more ELF helpers to elf-helpers
Date: Wed, 22 Apr 2020 11:53:18 +0200 [thread overview]
Message-ID: <87r1wfdey9.fsf@seketeli.org> (raw)
In-Reply-To: <20200421063551.222511-7-maennich@google.com> (Matthias Maennich's message of "Tue, 21 Apr 2020 08:35:49 +0200")
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
next prev parent reply other threads:[~2020-04-22 9:53 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 11:08 [PATCH 0/8] Refactor dwarf-reader: split out ELF helpers Matthias Maennich
2020-04-20 11:08 ` [PATCH 1/8] abg-dwarf-reader split: create abg-elf-helpers.{h, cc} and test case Matthias Maennich
2020-04-20 15:35 ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 2/8] abg-elf-helpers: move some elf helpers from abg-dwarf-reader Matthias Maennich
2020-04-20 15:34 ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 3/8] abg-elf-helpers: move some versioning " Matthias Maennich
2020-04-20 15:33 ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 4/8] abg-elf-helpers: move some kernel " Matthias Maennich
2020-04-20 14:32 ` Giuliano Procida
2020-04-20 15:30 ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 5/8] abg-elf-helpers: consolidate the is_linux_kernel* helpers Matthias Maennich
2020-04-20 15:29 ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 6/8] abg-dwarf-reader: migrate more ELF helpers to elf-helpers Matthias Maennich
2020-04-20 15:24 ` Giuliano Procida
2020-04-21 6:14 ` Matthias Maennich
2020-04-21 11:02 ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 7/8] abg-elf-helpers: migrate more elf helpers (architecture specific helpers) Matthias Maennich
2020-04-20 15:25 ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 8/8] abg-elf-helpers: migrate maybe_adjust_et_rel_sym_addr_to_abs_addr Matthias Maennich
2020-04-21 6:35 ` [PATCH v2 0/8] Refactor dwarf-reader: split out ELF helpers Matthias Maennich
2020-04-21 6:35 ` [PATCH v2 1/8] abg-dwarf-reader split: create abg-elf-helpers.{h, cc} and test case Matthias Maennich
2020-04-22 9:42 ` Dodji Seketeli
2020-04-21 6:35 ` [PATCH v2 2/8] abg-elf-helpers: move some elf helpers from abg-dwarf-reader Matthias Maennich
2020-04-22 9:44 ` Dodji Seketeli
2020-04-21 6:35 ` [PATCH v2 3/8] abg-elf-helpers: move some versioning " Matthias Maennich
2020-04-22 9:46 ` Dodji Seketeli
2020-04-21 6:35 ` [PATCH v2 4/8] abg-elf-helpers: move some kernel " Matthias Maennich
2020-04-22 9:47 ` Dodji Seketeli
2020-04-21 6:35 ` [PATCH v2 5/8] abg-elf-helpers: consolidate the is_linux_kernel* helpers Matthias Maennich
2020-04-22 9:48 ` Dodji Seketeli
2020-04-21 6:35 ` [PATCH v2 6/8] abg-dwarf-reader: migrate more ELF helpers to elf-helpers Matthias Maennich
2020-04-22 9:53 ` Dodji Seketeli [this message]
2020-04-21 6:35 ` [PATCH v2 7/8] abg-elf-helpers: migrate more elf helpers (architecture specific helpers) Matthias Maennich
2020-04-22 9:55 ` Dodji Seketeli
2020-04-21 6:35 ` [PATCH v2 8/8] abg-elf-helpers: migrate maybe_adjust_et_rel_sym_addr_to_abs_addr Matthias Maennich
2020-04-22 9:56 ` Dodji Seketeli
2020-04-22 9:57 ` [PATCH v2 0/8] Refactor dwarf-reader: split out ELF helpers Dodji Seketeli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87r1wfdey9.fsf@seketeli.org \
--to=dodji@seketeli.org \
--cc=gprocida@google.com \
--cc=kernel-team@android.com \
--cc=libabigail@sourceware.org \
--cc=maennich@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).