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.