From patchwork Mon May 18 11:45:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 39284 X-Patchwork-Delegate: dodji@seketeli.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 972FD388A826; Mon, 18 May 2020 11:45:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 972FD388A826 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589802352; bh=AbHtaNIOVoahXAX/EQeAiah4aGCYa7SXWsHHF+DKRBY=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=iqPP6dUsHENb6KdqYFkZjBl2wdGRwF8RgZQ/d91uoDmDb36i9itjmutxjEdiGv1bB 970W9VaP2ghty8Og5y6Ut1LjRvNW+YGAOUQW6ZVW9OCwNvf5B9jn1h41xU+0SxxACh BiGy9OaT1nlezUu9ZOnK+FyIYtmH+Gdmu+rlk5ak= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by sourceware.org (Postfix) with ESMTPS id 3DA55388A82A for ; Mon, 18 May 2020 11:45:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3DA55388A82A Received: by mail-qt1-x849.google.com with SMTP id a14so9582414qto.6 for ; Mon, 18 May 2020 04:45:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AbHtaNIOVoahXAX/EQeAiah4aGCYa7SXWsHHF+DKRBY=; b=TemHecJ1sMauz/slt2isanf07gAUPWlcJwzbtw2NaC1hbz3y9a00uIdD07+aB5G+4I W1s9rFjnxIoIobfNnsBkxMrjfVX7XC81Gdcu054gw0WOx08sEEO9L4z/vRXd5yh2ND4G 53BLDwxVOhlegFUWRsll96vPfa0XQIZUKo1Helvs47pqEvDEhtbXnJRDitROpeDI3e7Q fAb9W472X7nTGz4vQcQH2axucEEqcsbJdYyXQHGy/zrY5Bj3jxGOXMGf+T3Lsr/rosgZ 4fz8YBloufcmnEQoUjGfaNnUURFzCBw3HKfIN86YpD9pVMo+YfBtzpGVFQHbyqVT/E3n EzMw== X-Gm-Message-State: AOAM531AAKMFt45/RBv+tvIbgO4sCkotP9QYG3ci40wUAIaWamZX/TUb /4pyxTtwym1XWA5H/5pE7WuftG/SFqf1+QtGas3k7A9Sab5WO5erzwSiegBNxhWMaaiYkjYq8mF 41w8zRLLan1DybmTrpa1oSIk5jJ4XeYOUlWyfCtTkpLwuTsdxd9EvEg9X2fac3/0h/LcRIdM= X-Google-Smtp-Source: ABdhPJxSIjuP6r0Jtwl61973YBDePDqR7gBMVZ5x7KKGlFD9KIEw1tNd9dZjUrzgnaGCbkjAR1/z9q58zeKRpQ== X-Received: by 2002:a0c:e9c9:: with SMTP id q9mr15252871qvo.215.1589802349469; Mon, 18 May 2020 04:45:49 -0700 (PDT) Date: Mon, 18 May 2020 13:45:36 +0200 In-Reply-To: <20200518114536.202504-1-maennich@google.com> Message-Id: <20200518114536.202504-2-maennich@google.com> Mime-Version: 1.0 References: <20200518114536.202504-1-maennich@google.com> X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Subject: [PATCH 2/2] dwarf-reader: read_context: drop unused symbol versioning code To: libabigail@sourceware.org X-Spam-Status: No, score=-23.4 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL 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: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matthias Maennich via Libabigail From: =?utf-8?q?Matthias_M=C3=A4nnich?= Reply-To: Matthias Maennich Cc: maennich@google.com, gprocida@google.com, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Since the symbol versioning helper code has been moved to elf_helpers in commit 9815efe7a5be ("abg-elf-helpers: move some versioning helpers from abg-dwarf-reader"), remove the leftover unused code from read_context. * src/abg-dwarf-reader.cc (read_context::versym_section_): Delete. (read_context::verdef_section_): Delete. (read_context::verneed_section_): Delete. (read_context::symbol_versionning_sections_loaded_): Delete. (read_context::symbol_versionning_sections_found_): Delete. (read_context::initialize): Remove initializations of deleted members. (read_context::get_symbol_versionning_sections): Delete. (read_context::get_version_for_symbol): Delete. (read_context::lookup_elf_symbol_from_index): Use get_version_for_symbol provided by elf_helpers. Signed-off-by: Matthias Maennich Acked-by: Dodji Seketeli --- src/abg-dwarf-reader.cc | 119 +--------------------------------------- 1 file changed, 2 insertions(+), 117 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index ab1a01cb3aa0..621e00e00a9d 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2184,11 +2184,6 @@ public: mutable Elf_Scn* ksymtab_gpl_section_; mutable Elf_Scn* ksymtab_gpl_reloc_section_; mutable Elf_Scn* ksymtab_strings_section_; - Elf_Scn* versym_section_; - Elf_Scn* verdef_section_; - Elf_Scn* verneed_section_; - bool symbol_versionning_sections_loaded_; - bool symbol_versionning_sections_found_; Dwarf_Die* cur_tu_die_; mutable dwarf_expr_eval_context dwarf_expr_eval_context_; // A set of maps (one per kind of die source) that associates a decl @@ -2379,11 +2374,6 @@ public: ksymtab_gpl_section_ = 0; ksymtab_gpl_reloc_section_ = 0; ksymtab_strings_section_ = 0; - versym_section_ = 0; - verdef_section_ = 0; - verneed_section_ = 0; - symbol_versionning_sections_loaded_ = 0; - symbol_versionning_sections_found_ = 0; cur_tu_die_ = 0; exported_decls_builder_ = 0; @@ -5173,110 +5163,6 @@ public: return result; } - /// Return the SHT_GNU_versym, SHT_GNU_verdef and SHT_GNU_verneed - /// sections that are involved in symbol versionning. - /// - /// @param versym_section the SHT_GNU_versym section found. - /// - /// @param verdef_section the SHT_GNU_verdef section found. - /// - /// @param verneed_section the SHT_GNU_verneed section found. - /// - /// @return true iff the sections where found. - bool - get_symbol_versionning_sections(Elf_Scn*& versym_section, - Elf_Scn*& verdef_section, - Elf_Scn*& verneed_section) - { - if (!symbol_versionning_sections_loaded_) - { - symbol_versionning_sections_found_ = - dwarf_reader::get_symbol_versionning_sections(elf_handle(), - versym_section_, - verdef_section_, - verneed_section_); - symbol_versionning_sections_loaded_ = true; - } - - versym_section = versym_section_; - verdef_section = verdef_section_; - verneed_section = verneed_section_; - return symbol_versionning_sections_found_; - } - - /// Return the version for a symbol that is at a given index in its - /// SHT_SYMTAB section. - /// - /// The first invocation of this function caches the results and - /// subsequent invocations just return the cached results. - /// - /// @param symbol_index the index of the symbol to consider. - /// - /// @param get_def_version if this is true, it means that that we want - /// the version for a defined symbol; in that case, the version is - /// looked for in a section of type SHT_GNU_verdef. Otherwise, if - /// this parameter is false, this means that we want the version for - /// an undefined symbol; in that case, the version is the needed one - /// for the symbol to be resolved; so the version is looked fo in a - /// section of type SHT_GNU_verneed. - /// - /// @param version the version found for symbol at @p symbol_index. - /// - /// @return true iff a version was found for symbol at index @p - /// symbol_index. - bool - get_version_for_symbol(size_t symbol_index, - bool get_def_version, - elf_symbol::version& version) - { - Elf_Scn *versym_section = NULL, - *verdef_section = NULL, - *verneed_section = NULL; - - if (!get_symbol_versionning_sections(versym_section, - verdef_section, - verneed_section)) - return false; - - GElf_Versym versym_mem; - Elf_Data* versym_data = (versym_section) - ? elf_getdata(versym_section, NULL) - : NULL; - GElf_Versym* versym = (versym_data) - ? gelf_getversym(versym_data, symbol_index, &versym_mem) - : NULL; - - if (versym == 0 || *versym <= 1) - // I got these value from the code of readelf.c in elfutils. - // Apparently, if the symbol version entry has these values, the - // symbol must be discarded. This is not documented in the - // official specification. - return false; - - if (get_def_version) - { - if (*versym == 0x8001) - // I got this value from the code of readelf.c in elfutils - // too. It's not really documented in the official - // specification. - return false; - - if (verdef_section - && get_version_definition_for_versym(elf_handle(), versym, - verdef_section, version)) - return true; - } - else - { - if (verneed_section - && get_version_needed_for_versym(elf_handle(), versym, - verneed_section, version)) - return true; - } - - return false; - } - /// Lookup an elf symbol, referred to by its index, from the .symtab /// section. /// @@ -5366,9 +5252,8 @@ public: name_str = ""; elf_symbol::version ver; - get_version_for_symbol(symbol_index, - sym_is_defined, - ver); + elf_helpers::get_version_for_symbol(elf_handle(), symbol_index, + sym_is_defined, ver); elf_symbol::visibility vis = stv_to_elf_symbol_visibility(GELF_ST_VISIBILITY(native_sym.st_other));