From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by sourceware.org (Postfix) with ESMTPS id 97880386F82E for ; Wed, 22 Apr 2020 09:53:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 97880386F82E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dodji@seketeli.org X-Originating-IP: 91.166.131.130 Received: from localhost (91-166-131-130.subs.proxad.net [91.166.131.130]) (Authenticated sender: dodji@seketeli.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 379D940017; Wed, 22 Apr 2020 09:53:19 +0000 (UTC) Received: by localhost (Postfix, from userid 1000) id 783F7581891; Wed, 22 Apr 2020 11:53:18 +0200 (CEST) From: Dodji Seketeli To: Matthias Maennich 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 Organization: Me, myself and I References: <20200420110846.218792-1-maennich@google.com> <20200421063551.222511-1-maennich@google.com> <20200421063551.222511-7-maennich@google.com> X-Operating-System: Fedora 33 X-URL: http://www.seketeli.net/~dodji Date: Wed, 22 Apr 2020 11:53:18 +0200 In-Reply-To: <20200421063551.222511-7-maennich@google.com> (Matthias Maennich's message of "Tue, 21 Apr 2020 08:35:49 +0200") Message-ID: <87r1wfdey9.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libabigail mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Apr 2020 09:53:22 -0000 Matthias Maennich a =C3=A9crit: > 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_secti= on > * 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(this)->symtab_section_); > + const_cast(this)->symtab_section_ =3D > + 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. >=20=20 > @@ -5296,8 +5249,8 @@ public: > find_opd_section() const > { > if (!opd_section_) > - const_cast(this)->opd_section_=3D > - find_section(elf_handle(), ".opd", SHT_PROGBITS); > + const_cast(this)->opd_section_ =3D > + elf_helpers::find_opd_section(elf_handle()); > return opd_section_; > } Likewise. >=20=20 > @@ -5310,39 +5263,21 @@ public: > { > if (!ksymtab_section_) > const_cast(this)->ksymtab_section_ =3D > - 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(this)->ksymtab_gpl_section_ =3D > + elf_helpers::find_ksymtab_gpl_section(elf_handle()); > + return ksymtab_gpl_section_; > } Likewise. >=20=20 > /// Return the .rel{a,}__ksymtab section of a linux kernel ELF file (e= ither > @@ -5354,25 +5289,12 @@ public: > { > if (!ksymtab_reloc_section_) > { > - const_cast(this)->ksymtab_reloc_section_ > - =3D find_relocation_section(find_ksymtab_section()); > + const_cast(this)->ksymtab_reloc_section_ =3D > + 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(this)->ksymtab_gpl_reloc_section_ > - =3D find_relocation_section(find_ksymtab_gpl_section()); > + const_cast(this)->ksymtab_gpl_reloc_section_ =3D > + find_relocation_section(elf_handle(), find_ksymtab_gpl_section()); > } Likewise. [...] Applying to master with those changes, thanks! Cheers, --=20 Dodji