From patchwork Mon May 18 11:45:35 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: 39283 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 483B8388A823; Mon, 18 May 2020 11:45:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 483B8388A823 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1589802349; bh=E6MESOsqOTo6dgisTolWN8tnI9a9fhN6SsVtO2eRYL0=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=V2mEFKw9jMT3HVk4xoFPPCHP+CoWy+wpGVwgp/RqLNH6uAYTr/nUlt+p6aBjAM9MH 4nKbfdtW+TfWDtoLESG92F9o7vK5pImyCAbgRjDOemdV+3+YYPEYI+CyQGqksVgTwT 0AK3+S15+KBw0IhG1jxYb06wp1Fcq5wwmA88ATMQ= 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 41914388A823 for ; Mon, 18 May 2020 11:45:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 41914388A823 Received: by mail-qt1-x849.google.com with SMTP id k54so11115456qtb.18 for ; Mon, 18 May 2020 04:45:46 -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:message-id:mime-version:subject:from:to:cc; bh=E6MESOsqOTo6dgisTolWN8tnI9a9fhN6SsVtO2eRYL0=; b=eWWmjd6pVMqTjFVOXCxidIQgtj0NxyoAyWt7Hpx8+zHhi2+HWZjZ9G5SdF7BPkmGTq Jfqzq8+EK9TNs3wB/E+gPPr2yVclFJuY7JKeg6PWiAret3UwAPb3L0PYqwD/jUL69/0a NNZLLu9OOcOi0jkhEshNKcQoHXpx7+Md7o0S4Tk8w/SakpBsxQoAhuORpY0JmMZng1uC z3dl4OXqNxmQZy/NZgNRu2hdV3rLcnSS1qxt4hWWr1az61jKoZcbwSj8BN7Q573KNsl0 5tTdtimb36BwlEdM39PSUgzjGAyfs+uZoRXtSk160W39Qu1UDWjKrDcEdlus7HuuGGZM T+cA== X-Gm-Message-State: AOAM532JPWGXnUovA9DDVJv047rz/CYMAu6lY4qFkSSUtTrEh3i9b9am uPbrBBwdua2uFN7BIftP5U2Wde2JWpbGbuKvfxwgDgga1oI5CavhRXzkWu9gxfwiJEnTljfT2oW icI3s2IBW/i8YUWGzUBqG1ttMTqhb3ewL7CrqPp2kh8ker29WQdXXxfi79LIGZpP4YsirkIk= X-Google-Smtp-Source: ABdhPJx+HhKyX7ue1PDdVAj8jFzM5enTUtg2TpT7xQMqfXxJvi88ppW/vcL96XNjFFKDqsiaHfmUGTAPskAzMg== X-Received: by 2002:a0c:f94b:: with SMTP id i11mr2209498qvo.218.1589802345734; Mon, 18 May 2020 04:45:45 -0700 (PDT) Date: Mon, 18 May 2020 13:45:35 +0200 Message-Id: <20200518114536.202504-1-maennich@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.26.2.761.g0e0b3e54be-goog Subject: [PATCH 1/2] dwarf-reader: Remove unused code To: libabigail@sourceware.org X-Spam-Status: No, score=-23.5 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" Cleanup code that is never used to reduce overall compiled code and complexity. Some are leftovers from prior refactorings, some are unused overloads where the more suitable overload is still left. * src/abg-dwarf-reader.cc (lookup_public_variable_symbol_from_elf): Delete. (read_context::bss_section_): Delete. (read_context::text_section_): Delete. (read_context::rodata_section_): Delete. (read_context::data_section_): Delete. (read_context::data1_section_): Delete. (read_context::initialize): Remove initializations of deleted members. (read_context::options): Delete. (read_context::bss_section): Delete. (read_context::text_section): Delete. (read_context::rodata_section): Delete. (read_context::data_section): Delete. (read_context::data1_section): Delete. (read_context::get_elf_file_type): Delete. (read_context::lookup_symbol_from_elf): Delete. (read_context::lookup_public_variable_symbol_from_elf): Delete. (read_context::fun_addr_sym_map_sptr): Delete. (read_context::fun_addr_sym_map): Delete. (read_context::get_data_section_for_variable_address): Delete. (read_context::suppression_matches_function_sym_name): Delete. (read_context::suppression_matches_function_name): Delete. (read_context::suppression_matches_type_name): Delete. Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 349 ---------------------------------------- 1 file changed, 349 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 4bcc652fefa6..ab1a01cb3aa0 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -1449,44 +1449,6 @@ lookup_public_function_symbol_from_elf(const environment* env, return found; } -/// Look into the symbol tables of the underlying elf file and see if -/// we find a given public (global or weak) symbol of variable type. -/// -/// @param env the environment we are operating from. -/// -/// @param elf the elf handle to use for the query. -/// -/// @param symname the variable symbol to look for. -/// -/// @param var_syms the vector of public variable symbols found, if any. -/// -/// @return true iff symbol @p symname was found. -static bool -lookup_public_variable_symbol_from_elf(const environment* env, - Elf* elf, - const string& symname, - vector& var_syms) -{ - vector syms_found; - bool found = false; - - if (lookup_symbol_from_elf(env, elf, symname, /*demangle=*/false, syms_found)) - { - for (vector::const_iterator i = syms_found.begin(); - i != syms_found.end(); - ++i) - if ((*i)->is_variable() - && ((*i)->get_binding() == elf_symbol::GLOBAL_BINDING - || (*i)->get_binding() == elf_symbol::WEAK_BINDING)) - { - var_syms.push_back(*i); - found = true; - } - } - - return found; -} - /// Get data tag information of an ELF file by looking up into its /// dynamic segment /// @@ -2197,11 +2159,6 @@ public: Dwfl_Module* elf_module_; mutable Elf* elf_handle_; string elf_path_; - mutable Elf_Scn* bss_section_; - mutable Elf_Scn* text_section_; - mutable Elf_Scn* rodata_section_; - mutable Elf_Scn* data_section_; - mutable Elf_Scn* data1_section_; mutable Elf_Scn* symtab_section_; // The "Official procedure descriptor section, aka .opd", used in // ppc64 elf v1 binaries. This section contains the procedure @@ -2411,11 +2368,6 @@ public: elf_module_ = 0; elf_handle_ = 0; elf_path_ = elf_path; - bss_section_ = 0; - text_section_ = 0; - rodata_section_ = 0; - data_section_ = 0; - data1_section_ = 0; symtab_section_ = 0; opd_section_ = 0; ksymtab_format_ = UNDEFINED_KSYMTAB_FORMAT; @@ -2542,27 +2494,6 @@ public: clear_types_to_canonicalize(); } - /// Getter of the options of the read context. - /// - /// @return the options of the read context. - options_type& - options() - {return options_;} - - /// Getter of the options of the read context. - /// - /// @return the options of the read context. - const options_type& - options() const - {return options_;} - - /// Getter of the options of the read context. - /// - /// @return the options of the read context. - void - options(const options_type& o) - {options_ = o;} - /// Getter for the current environment. /// /// @return the current environment. @@ -2874,96 +2805,6 @@ public: elf_path() const {return elf_path_;} - /// Return the bss section of the ELF file we are reading. - /// - /// The first time this function is called, the ELF file is scanned - /// to look for the section we are looking for. Once the section is - /// found, it's cached. - /// - /// Subsequent calls to this function just return the cached - /// version. - /// - /// @return the bss section. - Elf_Scn* - bss_section() const - { - if (!bss_section_) - bss_section_ = find_bss_section(elf_handle()); - return bss_section_; - } - - /// Return the text section of the ELF file we are reading. - /// - /// The first time this function is called, the ELF file is scanned - /// to look for the section we are looking for. Once the section is - /// found, it's cached. - /// - /// Subsequent calls to this function just return the cached - /// version. - /// - /// return the text section. - Elf_Scn* - text_section() const - { - if (!text_section_) - text_section_ = find_text_section(elf_handle()); - return text_section_; - } - - /// Return the rodata section of the ELF file we are reading. - /// - /// The first time this function is called, the ELF file is scanned - /// to look for the section we are looking for. Once the section is - /// found, it's cached. - /// - /// Subsequent calls to this function just return the cached - /// version. - /// - /// return the rodata section. - Elf_Scn* - rodata_section() const - { - if (!rodata_section_) - rodata_section_ =find_rodata_section(elf_handle()); - return rodata_section_; - } - - /// Return the data section of the ELF file we are reading. - /// - /// The first time this function is called, the ELF file is scanned - /// to look for the section we are looking for. Once the section is - /// found, it's cached. - /// - /// Subsequent calls to this function just return the cached - /// version. - /// - /// return the data section. - Elf_Scn* - data_section() const - { - if (!data_section_) - data_section_ = find_data_section(elf_handle()); - return data_section_; - } - - /// Return the data1 section of the ELF file we are reading. - /// - /// The first time this function is called, the ELF file is scanned - /// to look for the section we are looking for. Once the section is - /// found, it's cached. - /// - /// Subsequent calls to this function just return the cached - /// version. - /// - /// return the data1 section. - Elf_Scn* - data1_section() const - { - if (!data1_section_) - data1_section_ = find_data1_section(elf_handle()); - return data1_section_; - } - const Dwarf_Die* cur_tu_die() const {return cur_tu_die_;} @@ -3542,8 +3383,6 @@ public: m[die_offset] = decl; } -public: - /// Lookup the decl for a given DIE. /// /// The returned decl is either the decl of the DIE that as the @@ -5214,15 +5053,6 @@ public: var_decls_to_re_add_to_tree() {return var_decls_to_add_;} - /// Return the type of the current elf file. - /// - /// @return the type of the current elf file. - elf_type - get_elf_file_type() - { - return elf_file_type(elf_handle()); - } - /// The section containing the symbol table from the current ELF /// file. /// @@ -5447,30 +5277,6 @@ public: return false; } - /// Look into the symbol tables of the underlying elf file and see - /// if we find a given symbol. - /// - /// @param symbol_name the name of the symbol to look for. - /// - /// @param demangle if true, demangle the symbols found in the symbol - /// tables. - /// - /// @param syms the vector of symbols with the name @p symbol_name - /// that were found. - /// - /// @return true iff the symbol was found. - bool - lookup_symbol_from_elf(const string& symbol_name, - bool demangle, - vector& syms) const - { - return dwarf_reader::lookup_symbol_from_elf(env(), - elf_handle(), - symbol_name, - demangle, - syms); - } - /// Lookup an elf symbol, referred to by its index, from the .symtab /// section. /// @@ -5815,25 +5621,6 @@ public: syms); } - /// Look in the symbol tables of the underying elf file and see if - /// we find a symbol of a given name of variable type. - /// - /// @param sym_name the name of the symbol to look for. - /// - /// @param syms the variable symbols that were found, with the name - /// @p sym_name. - /// - /// @return true iff the symbol was found. - bool - lookup_public_variable_symbol_from_elf(const string& sym_name, - vector& syms) - { - return dwarf_reader::lookup_public_variable_symbol_from_elf(env(), - elf_handle(), - sym_name, - syms); - } - /// Test if a given function symbol has been exported. /// /// @param symbol_address the address of the symbol we are looking @@ -5914,50 +5701,6 @@ public: return symbol; } - /// Getter for the map of function address -> symbol. - /// - /// @return the function address -> symbol map. - const addr_elf_symbol_sptr_map_sptr - fun_addr_sym_map_sptr() const - { - maybe_load_symbol_maps(); - return fun_addr_sym_map_; - } - - /// Getter for the map of function address -> symbol. - /// - /// @return the function address -> symbol map. - addr_elf_symbol_sptr_map_sptr - fun_addr_sym_map_sptr() - { - maybe_load_symbol_maps(); - return fun_addr_sym_map_; - } - - /// Getter for the map of function symbol address -> function symbol - /// index. - /// - /// @return the map. Note that this initializes the map once when - /// its nedded. - const addr_elf_symbol_sptr_map_type& - fun_addr_sym_map() const - { - maybe_load_symbol_maps(); - return *fun_addr_sym_map_; - } - - /// Getter for the map of function symbol address -> function symbol - /// index. - /// - /// @return the map. Note that this initializes the map once when - /// its nedded. - addr_elf_symbol_sptr_map_type& - fun_addr_sym_map() - { - maybe_load_symbol_maps(); - return *fun_addr_sym_map_; - } - /// Getter for a pointer to the map that associates the address of /// an entry point of a function with the symbol of that function. /// @@ -7431,37 +7174,6 @@ public: return false; } - /// Get the section which a global variable address comes from. - /// - /// @param var_addr the address for the variable. - /// - /// @return the ELF section the @p var_addr comes from, or nil if no - /// section was found for that variable address. - Elf_Scn* - get_data_section_for_variable_address(Dwarf_Addr var_addr) const - { - // There are several potential 'data sections" from which a - // variable address can come from: .data, .data1 and .rodata. - // Let's try to try them all in sequence. - - Elf_Scn* data_scn = bss_section(); - if (!address_is_in_section(var_addr, data_scn)) - { - data_scn = data_section(); - if (!address_is_in_section(var_addr, data_scn)) - { - data_scn = data1_section(); - if (!address_is_in_section(var_addr, data_scn)) - { - data_scn = rodata_section(); - if (!address_is_in_section(var_addr, data_scn)) - return 0; - } - } - } - return data_scn; - } - /// For a relocatable (*.o) elf file, this function expects an /// absolute address, representing a global variable symbol. It /// then extracts the address of the {.data,.data1,.rodata,.bss} @@ -7633,26 +7345,6 @@ public: return true; } - /// Test whether if a given function suppression matches a function - /// designated by a regular expression that describes its linkage - /// name (symbol name). - /// - /// @param s the suppression specification to evaluate to see if it - /// matches a given function linkage name - /// - /// @param fn_linkage_name the linkage name of the function of interest. - /// - /// @return true iff the suppression specification @p s matches the - /// function whose linkage name is @p fn_linkage_name. - bool - suppression_matches_function_sym_name(const suppr::function_suppression_sptr& s, - const string& fn_linkage_name) const - { - if (!s) - return false; - return suppression_matches_function_sym_name(*s,fn_linkage_name); - } - /// Test whether if a given function suppression matches a function /// designated by a regular expression that describes its linkage /// name (symbol name). @@ -7674,26 +7366,6 @@ public: return suppr::suppression_matches_function_sym_name(s, fn_linkage_name); } - /// Test whether if a given function suppression matches a function - /// designated by a regular expression that describes its name. - /// - /// @param s the suppression specification to evaluate to see if it - /// matches a given function name. - /// - /// @param fn_name the name of the function of interest. Note that - /// this name must be *non* qualified. - /// - /// @return true iff the suppression specification @p s matches the - /// function whose name is @p fn_name. - bool - suppression_matches_function_name(const suppr::function_suppression_sptr& s, - const string& fn_name) const - { - if (!s) - return false; - return suppression_matches_function_name(*s, fn_name); - } - /// Test whether if a given function suppression matches a function /// designated by a regular expression that describes its name. /// @@ -7776,27 +7448,6 @@ public: type_location); } - /// Test if a type suppression specification matches the name of a - /// type within a given scope. - /// - /// @param s the type suppression specification to consider. - /// - /// @param type_scope the type scope to consider. - /// - /// @param type the type to consider. - /// - /// @return true iff the type suppression specification matches a - /// the name of type @p type. - bool - suppression_matches_type_name(const suppr::type_suppression& s, - const scope_decl* type_scope, - const type_base_sptr& type) const - { - if (!suppression_can_match(s)) - return false; - return suppr::suppression_matches_type_name(s, type_scope, type); - } - /// Getter of the exported decls builder object. /// /// @return the exported decls builder. 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));