From patchwork Mon Mar 29 13:19:14 2021 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: 42794 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 3D6B53858002; Mon, 29 Mar 2021 13:19:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3D6B53858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617023995; bh=Ds3C7phrDvBT1zHeWDzqjYZb2O+F2Q8Yt1lrQ+CCQ+A=; h=Date:To:Subject:In-Reply-To:List-Id:List-Unsubscribe:List-Archive: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Po1z5r/9QTZpWvtsysR6FfNr8Dy28hvSoZu1ocmfKp1KGlCoRpI/q3Pk3XZV5B7ig 1JG7teW2czFXGoPanO7j9Fa1HOTBh8Uhe4BIT0iAi99J3pMaQtWl1FaI76A+7AOgCT mSl3n95Ypr24JLkNZeX2TU0/kpI/sIxB8pglUW+E= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by sourceware.org (Postfix) with ESMTPS id 834783858002 for ; Mon, 29 Mar 2021 13:19:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 834783858002 Received: by mail-wr1-x42b.google.com with SMTP id k8so12850440wrc.3 for ; Mon, 29 Mar 2021 06:19:18 -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:from:to:cc:subject:message-id:mime-version :content-disposition:in-reply-to; bh=Ds3C7phrDvBT1zHeWDzqjYZb2O+F2Q8Yt1lrQ+CCQ+A=; b=Jv/iC4OSAcZTotaDhAjZq7irjOGHCmWyBfH8qNSk9FssH8WhEGdLOyPa5XSIRzJU2e PnxszaLn6Y2uf2XPrsTJm0WpnNXTFXAhK3aZhL6tys6UJ4NZnk3G6dwh31dLki7ro9gH lITzCJXb7Ndnc7a0WXVmzhf/eS8syQpnxT+peGEq8DT/5AqAtLcvCvzwvvzjEQ4EtmAJ gQ7+8LSr+3xMQlBAsyVwCtg/Mhk39EOjc/7YIrPRrET1coe+Reb4oObjLhPzY+e8teyB KI3DYhk7GS5JTJYui7D4AQh36RoM/zcCqflEkgyaukbMypP1l3DNjZ84psgNiEhryjNa TzLQ== X-Gm-Message-State: AOAM531wflNHWe2BgBrHEiwncKqXddkFI454w3PhMrhBZE+HFtHZrViZ Q1m+Askq1UHZBhuueg9Zv+oykRU6Lrtl0w== X-Google-Smtp-Source: ABdhPJwU9mwmzgxey7IQy2YlWLGF4HQUJE7w61nI05K6E68NpVUD9/WJT3pHdqcs+08Ph1KcOKo5aw== X-Received: by 2002:a05:6000:1363:: with SMTP id q3mr28477849wrz.74.1617023956588; Mon, 29 Mar 2021 06:19:16 -0700 (PDT) Received: from google.com ([2a00:79e0:d:210:f03b:fb2d:9c5b:31b2]) by smtp.gmail.com with ESMTPSA id g16sm30090588wrs.76.2021.03.29.06.19.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Mar 2021 06:19:15 -0700 (PDT) Date: Mon, 29 Mar 2021 14:19:14 +0100 To: Dodji Seketeli , libabigail@sourceware.org Subject: [GIT PULL] Refactor (k)symtab reader Message-ID: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210127125853.886677-1-maennich@google.com> X-Spam-Status: No, score=-22.1 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=no 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: kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Hi Dodji, This is technically v4 of the symtab reader series. I addressed all the requests from the review and since they were mostly about style, I did not send out the series again. Instead I staged the version at the sourceware git for you to merge (or fast-forward) directly. There is a new tiny commit that enhances the .clang-format file to create better matching style and obviously. I folded the relevant ARM32 patch into the first commit of the series. I omitted the commits that were already merged. I also attached the full inter-diff between v3 and v4 for your reference. Cheers, Matthias --- So, please pull: The following changes since commit 2eefd1727663285fe3544c41ec01dea32b2ec7dd: Bug 27569 - abidiff misses a function parameter addition (2021-03-29 12:34:48 +0200) are available in the Git repository at: ssh://sourceware.org/git/libabigail.git mm-symtab-reader for you to fetch changes up to 6be21667a07e261dc9779271048c219232c1b911: symtab: Add support for MODVERSIONS (CRC checksums) (2021-03-29 13:39:56 +0100) ---------------------------------------------------------------- Giuliano Procida (1): abg-writer.cc: fix write_elf_symbol_reference loop Matthias Maennich (16): clang-format: Minor correction to not break parameters on the first line Refactor ELF symbol table reading by adding a new symtab reader Integrate new symtab reader into corpus and read_context corpus: make get_(undefined_)?_(var|fun)_symbols use the new symtab corpus: make get_unreferenced_(function|variable)_symbols use the new symtab abg-reader: avoid using the (var|function)_symbol_map dwarf-reader: read_context: use new symtab in *_symbols_is_exported Switch kernel stuff over to new symtab and drop unused code abg-elf-helpers: migrate ppc64 specific helpers symtab_reader: add support for ppc64 ELFv1 binaries abg-corpus: remove symbol maps and their setters dwarf reader: drop (now) unused code related to symbol table reading test-symtab: add tests for whitelisted functions symtab/dwarf-reader: allow hinting of main symbols for aliases dwarf-reader/writer: consider aliases when dealing with suppressions symtab: Add support for MODVERSIONS (CRC checksums) .clang-format | 3 +- include/abg-corpus.h | 24 +- include/abg-dwarf-reader.h | 6 - include/abg-fwd.h | 9 + include/abg-ir.h | 11 + src/abg-comp-filter.cc | 39 +- src/abg-corpus-priv.h | 57 +- src/abg-corpus.cc | 637 +++-- src/abg-dwarf-reader.cc | 2453 ++------------------ src/abg-elf-helpers.cc | 186 ++ src/abg-elf-helpers.h | 8 + src/abg-ir.cc | 79 +- src/abg-reader.cc | 57 +- src/abg-reporter-priv.cc | 18 +- src/abg-symtab-reader.cc | 543 +++++ src/abg-symtab-reader.h | 314 ++- src/abg-tools-utils.cc | 13 - src/abg-writer.cc | 68 +- tests/data/Makefile.am | 38 +- .../test-abicompat/test5-fn-changed-report-0.txt | 4 - .../test-abicompat/test5-fn-changed-report-1.txt | 4 - tests/data/test-abidiff-exit/test-crc-report.txt | 15 + tests/data/test-abidiff-exit/test-crc-v0.abi | 29 + tests/data/test-abidiff-exit/test-crc-v1.abi | 30 + .../test-missing-alias-report.txt | 0 .../data/test-abidiff-exit/test-missing-alias.abi | 12 + .../test-abidiff-exit/test-missing-alias.suppr | 4 + ...166-libtirpc.so.report.txt => empty-report.txt} | 0 tests/data/test-abidiff/test-PR24552-report0.txt | 3 - tests/data/test-abidiff/test-crc-0.xml | 1601 +++++++++++++ tests/data/test-abidiff/test-crc-1.xml | 1601 +++++++++++++ tests/data/test-abidiff/test-crc-2.xml | 1601 +++++++++++++ tests/data/test-abidiff/test-crc-report.txt | 9 + .../data/test-abidiff/test-empty-corpus-report.txt | 3 - tests/data/test-annotate/test15-pr18892.so.abi | 918 ++++---- .../test19-pr19023-libtcmalloc_and_profiler.so.abi | 60 +- tests/data/test-annotate/test2.so.abi | 12 +- tests/data/test-annotate/test3.so.abi | 6 +- tests/data/test-diff-dwarf/test12-report.txt | 7 + .../test36-ppc64-aliases-report-0.txt | 4 +- .../test42-PR21296-clanggcc-report0.txt | 6 +- .../test-diff-filter/test-PR27569-report-0.txt | 2 + .../test31-pr18535-libstdc++-report-0.txt | 6 +- .../test31-pr18535-libstdc++-report-1.txt | 6 +- ...64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt | 6 +- ...64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt | 6 +- .../test-diff-suppr/test23-alias-filter-4.suppr | 2 +- .../test23-alias-filter-report-0.txt | 4 +- .../test23-alias-filter-report-2.txt | 4 +- tests/data/test-diff-suppr/test31-report-0.txt | 3 + tests/data/test-diff-suppr/test32-report-1.txt | 2 +- .../PR22015-libboost_iostreams.so.abi | 48 +- tests/data/test-read-dwarf/PR22122-libftdc.so.abi | 6 +- tests/data/test-read-dwarf/PR25007-sdhci.ko.abi | 77 +- .../data/test-read-dwarf/libtest24-drop-fns.so.abi | 314 +-- tests/data/test-read-dwarf/test-suppressed-alias.c | 16 + tests/data/test-read-dwarf/test-suppressed-alias.o | Bin 0 -> 2848 bytes .../test-read-dwarf/test-suppressed-alias.o.abi | 16 + .../test-read-dwarf/test-suppressed-alias.suppr | 7 + .../data/test-read-dwarf/test10-pr18818-gcc.so.abi | 192 +- tests/data/test-read-dwarf/test11-pr18828.so.abi | 516 ++-- tests/data/test-read-dwarf/test12-pr18844.so.abi | 66 +- tests/data/test-read-dwarf/test15-pr18892.so.abi | 918 ++++---- tests/data/test-read-dwarf/test16-pr18904.so.abi | 990 ++++---- .../test19-pr19023-libtcmalloc_and_profiler.so.abi | 60 +- tests/data/test-read-dwarf/test2.so.abi | 12 +- tests/data/test-read-dwarf/test2.so.hash.abi | 12 +- .../test22-pr19097-libstdc++.so.6.0.17.so.abi | 1042 ++++----- .../data/test-read-dwarf/test3-alias-1.so.hash.abi | 14 + tests/data/test-read-dwarf/test3-alias-1.suppr | 3 + .../data/test-read-dwarf/test3-alias-2.so.hash.abi | 18 + tests/data/test-read-dwarf/test3-alias-2.suppr | 3 + .../data/test-read-dwarf/test3-alias-3.so.hash.abi | 14 + tests/data/test-read-dwarf/test3-alias-3.suppr | 3 + .../data/test-read-dwarf/test3-alias-4.so.hash.abi | 8 + tests/data/test-read-dwarf/test3-alias-4.suppr | 3 + tests/data/test-read-dwarf/test3.so.abi | 6 +- tests/data/test-read-dwarf/test3.so.hash.abi | 6 +- tests/data/test-read-write/test-crc.xml | 10 + tests/data/test-symtab/basic/aliases.c | 13 + tests/data/test-symtab/basic/aliases.so | Bin 0 -> 17176 bytes tests/data/test-symtab/basic/no_debug_info.c | 2 +- tests/data/test-symtab/basic/no_debug_info.so | Bin 15360 -> 15544 bytes .../basic/one_function_one_variable_all.whitelist | 3 + .../one_function_one_variable_function.whitelist | 2 + .../one_function_one_variable_irrelevant.whitelist | 2 + .../one_function_one_variable_variable.whitelist | 2 + tests/data/test-symtab/kernel-modversions/Makefile | 19 + .../test-symtab/kernel-modversions/one_of_each.c | 1 + .../test-symtab/kernel-modversions/one_of_each.ko | Bin 0 -> 131760 bytes tests/test-abidiff-exit.cc | 22 + tests/test-abidiff.cc | 34 +- tests/test-read-dwarf.cc | 40 + tests/test-read-write.cc | 6 + tests/test-symtab.cc | 188 +- tools/abidw.cc | 2 - 96 files changed, 9832 insertions(+), 5417 deletions(-) create mode 100644 tests/data/test-abidiff-exit/test-crc-report.txt create mode 100644 tests/data/test-abidiff-exit/test-crc-v0.abi create mode 100644 tests/data/test-abidiff-exit/test-crc-v1.abi create mode 100644 tests/data/test-abidiff-exit/test-missing-alias-report.txt create mode 100644 tests/data/test-abidiff-exit/test-missing-alias.abi create mode 100644 tests/data/test-abidiff-exit/test-missing-alias.suppr rename tests/data/test-abidiff/{test-PR18166-libtirpc.so.report.txt => empty-report.txt} (100%) delete mode 100644 tests/data/test-abidiff/test-PR24552-report0.txt create mode 100644 tests/data/test-abidiff/test-crc-0.xml create mode 100644 tests/data/test-abidiff/test-crc-1.xml create mode 100644 tests/data/test-abidiff/test-crc-2.xml create mode 100644 tests/data/test-abidiff/test-crc-report.txt delete mode 100644 tests/data/test-abidiff/test-empty-corpus-report.txt create mode 100644 tests/data/test-read-dwarf/test-suppressed-alias.c create mode 100644 tests/data/test-read-dwarf/test-suppressed-alias.o create mode 100644 tests/data/test-read-dwarf/test-suppressed-alias.o.abi create mode 100644 tests/data/test-read-dwarf/test-suppressed-alias.suppr create mode 100644 tests/data/test-read-dwarf/test3-alias-1.so.hash.abi create mode 100644 tests/data/test-read-dwarf/test3-alias-1.suppr create mode 100644 tests/data/test-read-dwarf/test3-alias-2.so.hash.abi create mode 100644 tests/data/test-read-dwarf/test3-alias-2.suppr create mode 100644 tests/data/test-read-dwarf/test3-alias-3.so.hash.abi create mode 100644 tests/data/test-read-dwarf/test3-alias-3.suppr create mode 100644 tests/data/test-read-dwarf/test3-alias-4.so.hash.abi create mode 100644 tests/data/test-read-dwarf/test3-alias-4.suppr create mode 100644 tests/data/test-read-write/test-crc.xml create mode 100644 tests/data/test-symtab/basic/aliases.c create mode 100755 tests/data/test-symtab/basic/aliases.so create mode 100644 tests/data/test-symtab/basic/one_function_one_variable_all.whitelist create mode 100644 tests/data/test-symtab/basic/one_function_one_variable_function.whitelist create mode 100644 tests/data/test-symtab/basic/one_function_one_variable_irrelevant.whitelist create mode 100644 tests/data/test-symtab/basic/one_function_one_variable_variable.whitelist create mode 100644 tests/data/test-symtab/kernel-modversions/Makefile create mode 120000 tests/data/test-symtab/kernel-modversions/one_of_each.c create mode 100644 tests/data/test-symtab/kernel-modversions/one_of_each.ko --- Range-Diff between v3 and v3 ---------------------------- -: ------------ > 1: 4f997ce9e4cb clang-format: Minor correction to not break parameters on the first line 1: c6a596e02f78 ! 2: af33bfb78470 Refactor ELF symbol table reading by adding a new symtab reader @@ Commit message (symtab::load_): Likewise. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-symtab-reader.cc ## @@ src/abg-symtab-reader.cc: namespace abigail +{ + bool + operator()(const elf_symbol_sptr& left, const elf_symbol_sptr& right) -+ { return left->get_id_string() < right->get_id_string(); } ++ {return left->get_id_string() < right->get_id_string();} +} symbol_sort; + +/// Construct a symtab object and instantiate from an ELF handle. Also pass +/// in an ir::environment handle to interact with the context we are living +/// in. If specified, the symbol_predicate will be respected when creating +/// the full vector of symbols. ++/// ++/// @param elf_handle the elf handle to load the symbol table from ++/// ++/// @param env the environment we are operating in ++/// ++/// @param is_suppressed a predicate function to determine if a symbol should ++/// be suppressed ++/// ++/// @return a smart pointer handle to symtab, set to nullptr if the load was ++/// not completed +symtab_ptr +symtab::load(Elf* elf_handle, + ir::environment* env, @@ src/abg-symtab-reader.cc: namespace abigail + +/// Construct a symtab object from existing name->symbol lookup maps. +/// They were possibly read from a different representation (XML maybe). ++/// ++/// @param function_symbol_map a map from ELF function name to elf_symbol ++/// ++/// @param variable_symbol_map a map from ELF variable name to elf_symbol ++/// ++/// @return a smart pointer handle to symtab, set to nullptr if the load was ++/// not completed +symtab_ptr +symtab::load(string_elf_symbols_map_sptr function_symbol_map, + string_elf_symbols_map_sptr variables_symbol_map) @@ src/abg-symtab-reader.cc: namespace abigail + return result; +} + -+symtab::symtab() : is_kernel_binary_(false), has_ksymtab_entries_(false) {} ++symtab::symtab() ++ : is_kernel_binary_(false), has_ksymtab_entries_(false) ++{} + +/// Load the symtab representation from an Elf binary presented to us by an +/// Elf* handle. @@ src/abg-symtab-reader.cc: namespace abigail +/// Symbols that are suppressed will be omitted from the symbols_ vector, but +/// still be discoverable through the name->symbol and addr->symbol lookup +/// maps. ++/// ++/// @param elf_handle the elf handle to load the symbol table from ++/// ++/// @param env the environment we are operating in ++/// ++/// @param is_suppressed a predicate function to determine if a symbol should ++/// be suppressed ++/// ++/// @return true if the load succeeded +bool +symtab::load_(Elf* elf_handle, + ir::environment* env, @@ src/abg-symtab-reader.cc: namespace abigail + const bool is_kernel = elf_helpers::is_linux_kernel(elf_handle); + std::unordered_set exported_kernel_symbols; + ++ const bool is_arm32 = elf_helpers::architecture_is_arm32(elf_handle); ++ + for (size_t i = 0; i < number_syms; ++i) + { + GElf_Sym *sym, sym_mem; @@ src/abg-symtab-reader.cc: namespace abigail + elf_symbol::version ver; + elf_helpers::get_version_for_symbol(elf_handle, i, sym_is_defined, ver); + -+ const elf_symbol_sptr& symbol_sptr = elf_symbol::create( -+ env, i, sym->st_size, name, -+ elf_helpers::stt_to_elf_symbol_type(GELF_ST_TYPE(sym->st_info)), -+ elf_helpers::stb_to_elf_symbol_binding(GELF_ST_BIND(sym->st_info)), -+ sym_is_defined, sym_is_common, ver, -+ elf_helpers::stv_to_elf_symbol_visibility( -+ GELF_ST_VISIBILITY(sym->st_other)), -+ false); // TODO: is_linux_strings_cstr ++ const elf_symbol_sptr& symbol_sptr = ++ elf_symbol::create ++ (env, i, sym->st_size, name, ++ elf_helpers::stt_to_elf_symbol_type(GELF_ST_TYPE(sym->st_info)), ++ elf_helpers::stb_to_elf_symbol_binding(GELF_ST_BIND(sym->st_info)), ++ sym_is_defined, sym_is_common, ver, ++ elf_helpers::stv_to_elf_symbol_visibility ++ (GELF_ST_VISIBILITY(sym->st_other)), ++ /*is_linux_strings_cstr=*/false); // TODO: remove ++ // is_linux_strings_cstr ++ // as it is obsolete + + // We do not take suppressed symbols into our symbol vector to avoid + // accidental leakage. But we ensure supressed symbols are otherwise set @@ src/abg-symtab-reader.cc: namespace abigail + } + else if (symbol_sptr->is_defined()) + { -+ const GElf_Addr symbol_value = ++ GElf_Addr symbol_value = + elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle, + sym); + ++ if (symbol_sptr->is_function() && is_arm32) ++ // Clear bit zero of ARM32 addresses as per "ELF for the Arm ++ // Architecture" section 5.5.3. ++ // https://static.docs.arm.com/ihi0044/g/aaelf32.pdf ++ symbol_value &= ~1; ++ + const auto result = + addr_symbol_map_.emplace(symbol_value, symbol_sptr); + if (!result.second) @@ src/abg-symtab-reader.cc: namespace abigail +/// This method assumes the lookup maps are correct and sets up the data +/// vector as well as the name->symbol lookup map. The addr->symbol lookup +/// map cannot be set up in this case. ++/// ++/// @param function_symbol_map a map from ELF function name to elf_symbol ++/// ++/// @param variable_symbol_map a map from ELF variable name to elf_symbol ++/// ++/// @return true if the load succeeded +bool +symtab::load_(string_elf_symbols_map_sptr function_symbol_map, + string_elf_symbols_map_sptr variables_symbol_map) @@ src/abg-symtab-reader.h + bool + matches(const elf_symbol& symbol) const; + ++ /// Enable or disable function filtering ++ /// ++ /// @param new_value whether to filter for functions + void + set_functions(bool new_value = true) -+ { functions_ = new_value; }; ++ {functions_ = new_value;}; + ++ /// Enable or disable variable filtering ++ /// ++ /// @param new_value whether to filter for variables + void + set_variables(bool new_value = true) -+ { variables_ = new_value; }; ++ {variables_ = new_value;}; + ++ /// Enable or disable public symbol filtering ++ /// ++ /// @param new_value whether to filter for public symbols + void + set_public_symbols(bool new_value = true) -+ { public_symbols_ = new_value; }; ++ {public_symbols_ = new_value;}; + ++ /// Enable or disable undefined symbol filtering ++ /// ++ /// @param new_value whether to filter for undefined symbols + void + set_undefined_symbols(bool new_value = true) -+ { undefined_symbols_ = new_value; }; ++ {undefined_symbols_ = new_value;}; + ++ /// Enable or disable kernel symbol filtering ++ /// ++ /// @param new_value whether to filter for kernel symbols + void + set_kernel_symbols(bool new_value = true) -+ { kernel_symbols_ = new_value; }; ++ {kernel_symbols_ = new_value;}; + +private: + // The symbol is a function (FUNC) @@ src/abg-symtab-reader.h + /// Construct the iterator based on a pair of underlying iterators and a + /// symtab_filter object. Immediately fast forward to the next element that + /// matches the criteria (if any). ++ /// ++ /// @param begin the underlying begin iterator ++ /// ++ /// @param begin the underlying end iterator ++ /// ++ /// @param filter the symtab_filter to apply + symtab_iterator(base_iterator begin, + base_iterator end, + const symtab_filter& filter = symtab_filter()) + : base_iterator(begin), end_(end), filter_(filter) -+ { skip_to_next(); } ++ {skip_to_next();} + + /// Pre-increment operator to advance to the next matching element. ++ /// ++ /// @return itself after incrementing + symtab_iterator& + operator++() + { @@ src/abg-symtab-reader.h + } + + /// Post-increment operator to advance to the next matching element. ++ /// ++ /// @return a copy of the iterator before incrementing + symtab_iterator + operator++(int) + { @@ src/abg-symtab-reader.h + /// @return true if there are symbols detected earlier. + bool + has_symbols() const -+ { return is_kernel_binary_ ? has_ksymtab_entries_ : !symbols_.empty(); } ++ {return is_kernel_binary_ ? has_ksymtab_entries_ : !symbols_.empty();} + + symtab_filter + make_filter() const; @@ src/abg-symtab-reader.h + /// @return a filtering const_iterator of the underlying type + const_iterator + begin(const symtab_filter& filter) const -+ { return symtab_iterator(symbols_.begin(), symbols_.end(), filter); } ++ {return symtab_iterator(symbols_.begin(), symbols_.end(), filter);} + + /// Obtain an iterator to the end of the symtab. + /// + /// @return an end iterator + const_iterator + end() const -+ { return symtab_iterator(symbols_.end(), symbols_.end()); } ++ {return symtab_iterator(symbols_.end(), symbols_.end());} + + const elf_symbols& + lookup_symbol(const std::string& name) const; @@ src/abg-symtab-reader.h + /// Construct the proxy object keeping references to the underlying symtab + /// and the filter object. + filtered_symtab(const symtab& tab, const symtab_filter& filter) -+ : tab_(tab), filter_(filter) { } ++ : tab_(tab), filter_(filter) ++ {} + + /// Pass through symtab.begin(), but also pass on the filter. + symtab::const_iterator + begin() const -+ { return tab_.begin(filter_); } ++ {return tab_.begin(filter_);} + + /// Pass through symtab.end(). + symtab::const_iterator + end() const -+ { return tab_.end(); } ++ {return tab_.end();} +}; + } // end namespace symtab_reader 2: 39bcfbea4481 ! 3: 55ed5b05594f Integrate new symtab reader into corpus and read_context @@ Commit message * tests/test-symtab.cc: Add test assertions. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## include/abg-corpus.h ## @@ include/abg-fwd.h: typedef vector suppressions_type; +{ + +class symtab; ++/// Convenience typedef for a shared pointer to a @ref symtab +typedef std::shared_ptr symtab_sptr; + +} // end namespace symtab_reader @@ src/abg-corpus.cc: corpus::operator==(const corpus& other) const && j == other.get_translation_units().end()); } ++/// Setter for the symtab object. ++/// ++/// @param symtab a shared pointer to the new symtab object +void +corpus::set_symtab(symtab_reader::symtab_sptr symtab) +{priv_->symtab_ = symtab;} + ++/// Getter for the symtab object. ++/// ++/// @return a shared pointer to the symtab object +const symtab_reader::symtab_sptr& +corpus::get_symtab() const -+{ return priv_->symtab_; } ++{return priv_->symtab_;} + /// Setter of the function symbols map. /// @@ src/abg-dwarf-reader.cc: public: return symbol; } ++ /// Getter for the symtab reader. Will load the symtab from the elf handle if ++ /// not yet set. ++ /// ++ /// @return a shared pointer to the symtab object + const symtab_reader::symtab_sptr& + symtab() const + { + if (!symtab_) -+ symtab_ = symtab_reader::symtab::load( -+ elf_handle(), options_.env, [&](const elf_symbol_sptr& symbol) { -+ return is_elf_symbol_suppressed(symbol); -+ }); ++ symtab_ = symtab_reader::symtab::load ++ (elf_handle(), options_.env, ++ [&](const elf_symbol_sptr& symbol) ++ {return is_elf_symbol_suppressed(symbol);}); + + if (!symtab_) + std::cerr << "Symbol table of '" << elf_path_ @@ src/abg-reader.cc: ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-corpus.h" +#include "abg-symtab-reader.h" - #ifdef WITH_ZIP_ARCHIVE - #include "abg-libzip-utils.h" + ABG_END_EXPORT_DECLARATIONS + // @@ src/abg-reader.cc: read_corpus_from_input(read_context& ctxt) // Note that it's possible that both fn_sym_db and var_sym_db // are nil, due to potential suppression specifications. That's @@ tests/test-symtab.cc: TEST_CASE("Symtab::Empty", "[symtab, basic]") } TEST_CASE("Symtab::NoDebugInfo", "[symtab, basic]") -@@ tests/test-symtab.cc: TEST_CASE("Symtab::NoDebugInfo", "[symtab, basic]") - const dwarf_reader::status status = read_corpus(binary, corpus_ptr); - REQUIRE(corpus_ptr); - -- REQUIRE(status -- == (dwarf_reader::STATUS_OK -- | dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)); -+ REQUIRE( -+ status -+ == (dwarf_reader::STATUS_OK | dwarf_reader::STATUS_DEBUG_INFO_NOT_FOUND)); - } - - // this value indicates in the following helper method, that we do not want to 3: 5ef5579b2e02 ! 4: e32f1b981ec5 corpus: make get_(undefined_)?_(var|fun)_symbols use the new symtab @@ Commit message data. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-corpus-priv.h ## @@ src/abg-corpus.cc: const string_elf_symbols_map_type& - {return operator()(*l, *r);} -}; // end struct elf_symbol_comp_functor - --/// Return a sorted vector of function symbols for this corpus. --/// --/// Note that the first time this function is called, the symbols are --/// sorted and cached. Subsequent invocations of this function return --/// the cached vector that was built previously. --/// --/// @return the sorted list of function symbols. + /// Return a sorted vector of function symbols for this corpus. + /// + /// Note that the first time this function is called, the symbols are +@@ src/abg-corpus.cc: struct elf_symbol_comp_functor + /// @return the sorted list of function symbols. const elf_symbols& corpus::get_sorted_fun_symbols() const -{ @@ src/abg-corpus.cc: const string_elf_symbols_map_type& - s != i->second.end(); - ++s) - priv_->sorted_fun_symbols.push_back(*s); -+{ return priv_->get_sorted_fun_symbols(); } - +- - elf_symbol_comp_functor comp; - std::sort(priv_->sorted_fun_symbols.begin(), - priv_->sorted_fun_symbols.end(), @@ src/abg-corpus.cc: const string_elf_symbols_map_type& - } - return priv_->sorted_fun_symbols; -} -- --/// Getter for a sorted vector of the function symbols undefined in --/// this corpus. --/// --/// @return a vector of the function symbols undefined in this corpus, --/// sorted by name and then version. ++{return priv_->get_sorted_fun_symbols();} + + /// Getter for a sorted vector of the function symbols undefined in + /// this corpus. +@@ src/abg-corpus.cc: corpus::get_sorted_fun_symbols() const + /// sorted by name and then version. const elf_symbols& corpus::get_sorted_undefined_fun_symbols() const -{ @@ src/abg-corpus.cc: const string_elf_symbols_map_type& - s != i->second.end(); - ++s) - priv_->sorted_undefined_fun_symbols.push_back(*s); -+{ return priv_->get_sorted_undefined_fun_symbols(); } ++{return priv_->get_sorted_undefined_fun_symbols();} - elf_symbol_comp_functor comp; - std::sort(priv_->sorted_undefined_fun_symbols.begin(), @@ src/abg-corpus.cc: const string_elf_symbols_map_type& - } - return priv_->sorted_undefined_fun_symbols; -} ++/// Getter for the sorted vector of variable symbols for this corpus. ++/// ++/// Note that the first time this function is called, it computes the ++/// sorted vector, caches the result and returns it. Subsequent ++/// invocations of this function just return the cached vector. ++/// ++/// @return the sorted vector of variable symbols for this corpus. +const elf_symbols& +corpus::get_sorted_var_symbols() const -+{ return priv_->get_sorted_var_symbols(); } ++{return priv_->get_sorted_var_symbols();} + ++/// Getter for a sorted vector of the variable symbols undefined in ++/// this corpus. ++/// ++/// @return a vector of the variable symbols undefined in this corpus, ++/// sorted by name and then version. +const elf_symbols& +corpus::get_sorted_undefined_var_symbols() const -+{ return priv_->get_sorted_undefined_var_symbols(); } ++{return priv_->get_sorted_undefined_var_symbols();} /// Getter for the variable symbols map. /// @@ tests/data/test-read-dwarf/PR25007-sdhci.ko.abi - - + 4: 8e0b8cc05905 ! 5: dfdc0dac7a41 corpus: make get_unreferenced_(function|variable)_symbols use the new symtab @@ Commit message (corpus::get_unreferenced_variable_symbols): Likewise. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-corpus-priv.h ## @@ src/abg-corpus.cc: corpus::priv::get_sorted_undefined_fun_symbols() const +/// unreferenced function symbol is not in the list of functions to keep, then +/// that symbol is dropped and will not be part of the resulting table of +/// unreferenced symbol that is built. ++/// ++/// @return list of symbols that are not referenced by any function +const elf_symbols& +corpus::priv::get_unreferenced_function_symbols() const +{ @@ src/abg-corpus.cc: corpus::priv::get_sorted_undefined_var_symbols() const +/// unreferenced variable symbol is not in the list of variable to keep, then +/// that symbol is dropped and will not be part of the resulting table of +/// unreferenced symbol that is built. ++/// ++/// @return list of symbols that are not referenced by any variable +const elf_symbols& +corpus::priv::get_unreferenced_variable_symbols() const +{ @@ src/abg-corpus.cc: corpus::sort_variables() - priv_->build_unreferenced_symbols_tables(); - return priv_->unrefed_fun_symbols; -} -+{ return priv_->get_unreferenced_function_symbols(); } ++{return priv_->get_unreferenced_function_symbols();} /// Getter of the set of variable symbols that are not referenced by /// any variable exported by the current corpus. @@ src/abg-corpus.cc: corpus::get_unreferenced_function_symbols() const - priv_->build_unreferenced_symbols_tables(); - return priv_->unrefed_var_symbols; -} -+{ return priv_->get_unreferenced_variable_symbols(); } ++{return priv_->get_unreferenced_variable_symbols();} /// Accessor for the regex patterns describing the functions to drop /// from the public decl table. 5: 27ea88e05723 ! 6: 7cd416fa89a6 abg-reader: avoid using the (var|function)_symbol_map @@ Commit message (build_var_decl): Likewise. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-reader.cc ## 6: 3fa9dd5b1896 ! 7: d4008d912907 dwarf-reader: read_context: use new symtab in *_symbols_is_exported @@ Commit message (variable_symbol_is_exported): Likewise. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-dwarf-reader.cc ## 7: 1c77268752a8 ! 8: 2411eea56423 Switch kernel stuff over to new symtab and drop unused code @@ Commit message (read_context::var_addr_sym_map): Likewise. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-dwarf-reader.cc ## 8: 4c25fd44ae50 ! 9: 6bb34d0ef69f abg-elf-helpers: migrate ppc64 specific helpers @@ Commit message (address_is_in_opd_section): New declaration. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-dwarf-reader.cc ## @@ src/abg-dwarf-reader.cc: public: GElf_Addr fn_desc_addr = sym->st_value; GElf_Addr fn_entry_point_addr = - lookup_ppc64_elf_fn_entry_point_address(fn_desc_addr); -+ lookup_ppc64_elf_fn_entry_point_address( -+ elf_handle(), fn_desc_addr); ++ lookup_ppc64_elf_fn_entry_point_address(elf_handle(), ++ fn_desc_addr); addr_elf_symbol_sptr_map_type::const_iterator it2 = fun_entry_addr_sym_map().find(fn_entry_point_addr); @@ src/abg-elf-helpers.h #include #include -@@ src/abg-elf-helpers.h: architecture_is_ppc64(Elf* elf_handle); +@@ src/abg-elf-helpers.h: architecture_is_arm32(Elf* elf_handle); bool architecture_is_big_endian(Elf* elf_handle); 9: 5976180a2a32 ! 10: 6e29c69af793 symtab_reader: add support for ppc64 ELFv1 binaries @@ Commit message function declaration. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-symtab-reader.cc ## @@ src/abg-symtab-reader.cc: const elf_symbol_sptr& + return addr_it->second; + else + { ++ // check for a potential entry address mapping instead, ++ // relevant for ppc ELFv1 binaries + const auto entry_it = entry_addr_symbol_map_.find(symbol_addr); + if (entry_it != entry_addr_symbol_map_.end()) + return entry_it->second; @@ src/abg-symtab-reader.cc: const elf_symbol_sptr& } @@ src/abg-symtab-reader.cc: symtab::load_(Elf* elf_handle, - const bool is_kernel = elf_helpers::is_linux_kernel(elf_handle); std::unordered_set exported_kernel_symbols; + const bool is_arm32 = elf_helpers::architecture_is_arm32(elf_handle); + const bool is_ppc64 = elf_helpers::architecture_is_ppc64(elf_handle); -+ + for (size_t i = 0; i < number_syms; ++i) { - GElf_Sym *sym, sym_mem; @@ src/abg-symtab-reader.cc: symtab::load_(Elf* elf_handle, elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle, sym); -+ if (is_ppc64 && symbol_sptr->is_function()) -+ update_function_entry_address_symbol_map(elf_handle, sym, -+ symbol_sptr); -+ +- if (symbol_sptr->is_function() && is_arm32) +- // Clear bit zero of ARM32 addresses as per "ELF for the Arm +- // Architecture" section 5.5.3. +- // https://static.docs.arm.com/ihi0044/g/aaelf32.pdf +- symbol_value &= ~1; ++ if (symbol_sptr->is_function()) ++ { ++ if (is_arm32) ++ // Clear bit zero of ARM32 addresses as per "ELF for the Arm ++ // Architecture" section 5.5.3. ++ // https://static.docs.arm.com/ihi0044/g/aaelf32.pdf ++ symbol_value &= ~1; ++ else if (is_ppc64) ++ update_function_entry_address_symbol_map(elf_handle, sym, ++ symbol_sptr); ++ } + const auto result = addr_symbol_map_.emplace(symbol_value, symbol_sptr); - if (!result.second) @@ src/abg-symtab-reader.cc: symtab::load_(string_elf_symbols_map_sptr function_symbol_map, return true; } ++/// Update the function entry symbol map to later allow lookups of this symbol ++/// by entry address as well. This is relevant for ppc64 ELFv1 binaries. ++/// ++/// For ppc64 ELFv1 binaries, we need to build a function entry point address ++/// -> function symbol map. This is in addition to the function pointer -> ++/// symbol map. This is because on ppc64 ELFv1, a function pointer is ++/// different from a function entry point address. ++/// ++/// On ppc64 ELFv1, the DWARF DIE of a function references the address of the ++/// entry point of the function symbol; whereas the value of the function ++/// symbol is the function pointer. As these addresses are different, if I we ++/// want to get to the symbol of a function from its entry point address (as ++/// referenced by DWARF function DIEs) we must have the two maps I mentionned ++/// right above. ++/// ++/// In other words, we need a map that associates a function entry point ++/// address with the symbol of that function, to be able to get the function ++/// symbol that corresponds to a given function DIE, on ppc64. ++/// ++/// The value of the function pointer (the value of the symbol) usually refers ++/// to the offset of a table in the .opd section. But sometimes, for a symbol ++/// named "foo", the corresponding symbol named ".foo" (note the dot before ++/// foo) which value is the entry point address of the function; that entry ++/// point address refers to a region in the .text section. ++/// ++/// So we are only interested in values of the symbol that are in the .opd ++/// section. ++/// ++/// @param elf_handle the ELF handle to operate on ++/// ++/// @param native_symbol the native Elf symbol to update the entry for ++/// ++/// @param symbol_sptr the internal symbol to associte the entry address with +void +symtab::update_function_entry_address_symbol_map( -+ Elf* elf_handle, -+ GElf_Sym* native_symbol, -+ const elf_symbol_sptr& symbol_sptr) ++ Elf* elf_handle, GElf_Sym* native_symbol, const elf_symbol_sptr& symbol_sptr) +{ -+ -+ // For ppc64 ELFv1 binaries, we need to build a function entry point address -+ // -> function symbol map. This is in addition to the function pointer -> -+ // symbol map. This is because on ppc64 ELFv1, a function pointer is -+ // different from a function entry point address. -+ // -+ // On ppc64 ELFv1, the DWARF DIE of a function references the address of the -+ // entry point of the function symbol; whereas the value of the function -+ // symbol is the function pointer. As these addresses are different, if I we -+ // want to get to the symbol of a function from its entry point address (as -+ // referenced by DWARF function DIEs) we must have the two maps I mentionned -+ // right above. -+ // -+ // In other words, we need a map that associates a function entry point -+ // address with the symbol of that function, to be able to get the function -+ // symbol that corresponds to a given function DIE, on ppc64. -+ // -+ // The value of the function pointer (the value of the symbol) usually refers -+ // to the offset of a table in the .opd section. But sometimes, for a symbol -+ // named "foo", the corresponding symbol named ".foo" (note the dot before -+ // foo) which value is the entry point address of the function; that entry -+ // point address refers to a region in the .text section. -+ // -+ // So we are only interested in values of the symbol that are in the .opd -+ // section. + const GElf_Addr fn_desc_addr = native_symbol->st_value; + const GElf_Addr fn_entry_point_addr = + elf_helpers::lookup_ppc64_elf_fn_entry_point_address(elf_handle, 10: fccb335d3763 ! 11: ef5a022875f0 abg-corpus: remove symbol maps and their setters @@ Commit message expected test output. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## include/abg-corpus.h ## @@ src/abg-corpus.cc: corpus::priv::get_sorted_fun_symbols() const return *sorted_fun_symbols; } ++/// Return a map from name to function symbol for this corpus. ++/// ++/// Note that the first time this function is called, the map is built. ++/// Subsequent invocations of this function return the cached map that was ++/// built previously. ++/// ++/// @return the name function symbol map +const string_elf_symbols_map_type& +corpus::priv::get_fun_symbol_map() const +{ @@ src/abg-corpus.cc: corpus::priv::get_sorted_undefined_fun_symbols() const return *sorted_undefined_fun_symbols; } ++/// Return a map from name to undefined function symbol for this corpus. ++/// ++/// Note that the first time this function is called, the map is built. ++/// Subsequent invocations of this function return the cached map that was ++/// built previously. ++/// ++/// @return the name function symbol map for undefined symbols +const string_elf_symbols_map_type& +corpus::priv::get_undefined_fun_symbol_map() const +{ @@ src/abg-corpus.cc: corpus::priv::get_sorted_var_symbols() const return *sorted_var_symbols; } ++/// Return a map from name to variable symbol for this corpus. ++/// ++/// Note that the first time this function is called, the map is built. ++/// Subsequent invocations of this function return the cached map that was ++/// built previously. ++/// ++/// @return the name variable symbol map +const string_elf_symbols_map_type& +corpus::priv::get_var_symbol_map() const +{ @@ src/abg-corpus.cc: corpus::priv::get_sorted_undefined_var_symbols() const return *sorted_undefined_var_symbols; } ++/// Return a map from name to undefined variable symbol for this corpus. ++/// ++/// Note that the first time this function is called, the map is built. ++/// Subsequent invocations of this function return the cached map that was ++/// built previously. ++/// ++/// @return the name undefined variable symbol map +const string_elf_symbols_map_type& +corpus::priv::get_undefined_var_symbol_map() const +{ @@ src/abg-corpus.cc: corpus::is_empty() const } @@ src/abg-corpus.cc: const symtab_reader::symtab_sptr& corpus::get_symtab() const - { return priv_->symtab_; } + {return priv_->symtab_;} -/// Setter of the function symbols map. -/// @@ src/abg-corpus.cc: corpus::get_undefined_fun_symbol_map_sptr() const -{return *get_undefined_fun_symbol_map_sptr();} +{return priv_->get_undefined_fun_symbol_map();} - const elf_symbols& - corpus::get_sorted_fun_symbols() const + /// Return a sorted vector of function symbols for this corpus. + /// @@ src/abg-corpus.cc: const elf_symbols& corpus::get_sorted_undefined_var_symbols() const - { return priv_->get_sorted_undefined_var_symbols(); } + {return priv_->get_sorted_undefined_var_symbols();} -/// Getter for the variable symbols map. -/// @@ tests/data/test-read-dwarf/PR25007-sdhci.ko.abi - - - + 11: b3567a749c22 ! 12: f8c3cd1438d7 dwarf reader: drop (now) unused code related to symbol table reading @@ Commit message * tools/abidw.cc (main): Likewise. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## include/abg-dwarf-reader.h ## @@ src/abg-dwarf-reader.cc: public: - ABG_ASSERT(gelf_getehdr(elf_handle(), &elf_header)); - - bool is_ppc64 = architecture_is_ppc64(elf_handle()); +- bool is_arm32 = architecture_is_arm32(elf_handle()); - - for (size_t i = 0; i < nb_syms; ++i) - { @@ src/abg-dwarf-reader.cc: public: - maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle(), - sym); - +- if (is_arm32) +- // Clear bit zero of ARM32 addresses as per "ELF for the Arm +- // Architecture" section 5.5.3. +- // https://static.docs.arm.com/ihi0044/g/aaelf32.pdf +- symbol_value &= ~1; - addr_elf_symbol_sptr_map_type::const_iterator it = - fun_addr_sym_map_->find(symbol_value); - if (it == fun_addr_sym_map_->end()) @@ src/abg-dwarf-reader.cc: public: - // symbol that are in the .opd section. - GElf_Addr fn_desc_addr = sym->st_value; - GElf_Addr fn_entry_point_addr = -- lookup_ppc64_elf_fn_entry_point_address( -- elf_handle(), fn_desc_addr); +- lookup_ppc64_elf_fn_entry_point_address(elf_handle(), +- fn_desc_addr); - addr_elf_symbol_sptr_map_type::const_iterator it2 = - fun_entry_addr_sym_map().find(fn_entry_point_addr); - @@ src/abg-dwarf-reader.cc: build_var_decl(read_context& ctxt, - } + Dwarf_Addr var_addr; + if (ctxt.get_variable_address(die, var_addr)) -+ var_sym = var_sym = ctxt.variable_symbol_is_exported(var_addr); ++ var_sym = ctxt.variable_symbol_is_exported(var_addr); if (var_sym) { 12: 9ab4ff413b6d ! 13: 9231995c5fc5 test-symtab: add tests for whitelisted functions @@ Commit message (Symtab::SymtabWithWhitelist): New testcase. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## tests/data/Makefile.am ## @@ tests/test-symtab.cc: using dwarf_reader::read_context_sptr; dwarf_reader::status -read_corpus(const std::string path, corpus_sptr& result) -+read_corpus( -+ const std::string& path, -+ corpus_sptr& result, -+ const std::vector& whitelist_paths = std::vector()) ++read_corpus(const std::string& path, ++ corpus_sptr& result, ++ const std::vector& whitelist_paths = ++ std::vector()) { const std::string& absolute_path = test_data_dir + path; -@@ tests/test-symtab.cc: read_corpus(const std::string path, corpus_sptr& result) - absolute_path, debug_info_root_paths, env.get(), - /* load_all_type = */ true, /* linux_kernel_mode = */ true); - + environment_sptr env(new environment); + const std::vector debug_info_root_paths; +- read_context_sptr ctxt = create_read_context( +- absolute_path, debug_info_root_paths, env.get(), +- /* load_all_type = */ true, /* linux_kernel_mode = */ true); ++ read_context_sptr ctxt = ++ create_read_context(absolute_path, debug_info_root_paths, env.get(), ++ /* load_all_type = */ true, ++ /* linux_kernel_mode = */ true); ++ + if (!whitelist_paths.empty()) + { + const suppressions_type& wl_suppr = @@ tests/test-symtab.cc: read_corpus(const std::string path, corpus_sptr& result) + REQUIRE_FALSE(wl_suppr.empty()); + dwarf_reader::add_read_context_suppressions(*ctxt, wl_suppr); + } -+ + dwarf_reader::status status = dwarf_reader::STATUS_UNKNOWN; result = read_corpus_from_elf(*ctxt, status); - -@@ tests/test-symtab.cc: TEST_CASE("Symtab::NoDebugInfo", "[symtab, basic]") - #define N std::numeric_limits::max() - - corpus_sptr --assert_symbol_count(const std::string& path, -- size_t function_symbols = 0, -- size_t variable_symbols = 0, -- size_t undefined_function_symbols = 0, +@@ tests/test-symtab.cc: assert_symbol_count(const std::string& path, + size_t function_symbols = 0, + size_t variable_symbols = 0, + size_t undefined_function_symbols = 0, - size_t undefined_variable_symbols = 0) -+assert_symbol_count( -+ const std::string& path, -+ size_t function_symbols = 0, -+ size_t variable_symbols = 0, -+ size_t undefined_function_symbols = 0, -+ size_t undefined_variable_symbols = 0, -+ const std::vector& whitelist_paths = std::vector()) ++ size_t undefined_variable_symbols = 0, ++ const std::vector& whitelist_paths = ++ std::vector()) { corpus_sptr corpus_ptr; - const dwarf_reader::status status = read_corpus(path, corpus_ptr); 13: a7536e784c80 ! 14: 200f7f10e6bf symtab/dwarf-reader: allow hinting of main symbols for aliases @@ Commit message (Symtab::AliasedVariableSymbols): Likewise. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## include/abg-ir.h ## @@ src/abg-dwarf-reader.cc: build_var_decl(read_context& ctxt, elf_symbol_sptr var_sym; Dwarf_Addr var_addr; if (ctxt.get_variable_address(die, var_addr)) -- var_sym = var_sym = ctxt.variable_symbol_is_exported(var_addr); +- var_sym = ctxt.variable_symbol_is_exported(var_addr); + { + ctxt.symtab()->update_main_symbol(var_addr, + result->get_linkage_name().empty() @@ src/abg-symtab-reader.cc: symtab::load_(string_elf_symbols_map_sptr function_sym + addr_symbol_map_[addr] = new_main; +} + - void - symtab::update_function_entry_address_symbol_map( - Elf* elf_handle, + /// Update the function entry symbol map to later allow lookups of this symbol + /// by entry address as well. This is relevant for ppc64 ELFv1 binaries. + /// ## src/abg-symtab-reader.h ## @@ src/abg-symtab-reader.h: public: @@ tests/data/Makefile.am: test-kmi-whitelist/whitelist-with-duplicate-entry \ ## tests/data/test-abicompat/test5-fn-changed-report-0.txt ## @@ tests/data/test-abicompat/test5-fn-changed-report-0.txt: have sub-types that are different from what application 'test5-fn-changed-app' e 1 data member deletion: - 'unsigned char S1::m1', at offset 32 (in bits) + 'unsigned char m1', at offset 32 (in bits) - method S0::S0(): - implicit parameter 0 of type 'S0*' has sub-type changes: @@ tests/data/test-abicompat/test5-fn-changed-report-0.txt: have sub-types that are ## tests/data/test-abicompat/test5-fn-changed-report-1.txt ## @@ tests/data/test-abicompat/test5-fn-changed-report-1.txt: have sub-types that are different from what application 'test5-fn-changed-app' e 1 data member deletion: - 'unsigned char S1::m1', at offset 32 (in bits) at test5-fn-changed-libapp-v0.h:11:1 + 'unsigned char m1', at offset 32 (in bits) at test5-fn-changed-libapp-v0.h:11:1 - method S0::S0(): - implicit parameter 0 of type 'S0*' has sub-type changes: @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + - + - + - + - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + - + - + - + @@ @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ - + - + - + - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi - + - + @@ - + - + - + @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-annotate/test15-pr18892.so.abi @@ - + - @@ tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt: Variables changes in pointed to type 'struct S': type size changed from 32 to 64 (in bits) 1 data member insertion: - 'int S::m1', at offset 32 (in bits) + 'int m1', at offset 32 (in bits) - [C] 'method S::S(int)' has some indirect sub-type changes: + [C] 'method S::S()' has some indirect sub-type changes: @@ tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt ## tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt ## @@ --Functions changes summary: 0 Removed, 5 Changed (195 filtered out), 13 Added functions -+Functions changes summary: 0 Removed, 5 Changed (206 filtered out), 13 Added functions +-Functions changes summary: 0 Removed, 11 Changed (189 filtered out), 13 Added functions ++Functions changes summary: 0 Removed, 11 Changed (200 filtered out), 13 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable Function symbols changes summary: 0 Removed, 0 Added function symbol not referenced by debug info Variable symbols changes summary: 0 Removed, 6 Added variable symbols not referenced by debug info @@ tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Variable symbols changes summary: 0 Removed, 6 Added variable symbols not refere - no member function changes (10 filtered); + parameter 2 of type 'void**' was removed [C] 'method std::codecvt_byname* std::codecvt_byname::codecvt_byname(const char*, std::size_t)' has some indirect sub-type changes: - Please note that the symbol of this function is _ZNSt14codecvt_bynameIwc11__mbstate_tEC1EPKcj@@GLIBCXX_3.4 @@ tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Variable symb ## tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt ## @@ --Functions changes summary: 0 Removed, 5 Changed (195 filtered out), 13 Added functions -+Functions changes summary: 0 Removed, 5 Changed (206 filtered out), 13 Added functions +-Functions changes summary: 0 Removed, 11 Changed (189 filtered out), 13 Added functions ++Functions changes summary: 0 Removed, 11 Changed (200 filtered out), 13 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable Function symbols changes summary: 0 Removed, 0 Added function symbol not referenced by debug info Variable symbols changes summary: 0 Removed, 6 Added variable symbols not referenced by debug info @@ tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt: Variable symbols changes summary: 0 Removed, 6 Added variable symbols not refere - no member function changes (10 filtered); + parameter 2 of type 'void**' was removed [C] 'method std::codecvt_byname* std::codecvt_byname::codecvt_byname(const char*, std::size_t)' at codecvt.h:462:1 has some indirect sub-type changes: - Please note that the symbol of this function is _ZNSt14codecvt_bynameIwc11__mbstate_tEC1EPKcj@@GLIBCXX_3.4 @@ tests/data/test-read-dwarf/test12-pr18844.so.abi - + - + @@ tests/data/test-read-dwarf/test12-pr18844.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test12-pr18844.so.abi - + - + @@ tests/data/test-read-dwarf/test12-pr18844.so.abi - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi + - + - + - + - + - - + + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - - - + + + - + - - + + - + - - + + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - + - + - + @@ - + - + - + - + - + @@ - + - + - + - + - - + + - + - + - - + + - + - + - + - + - + - + @@ - + - + - + - + - + - + - + - + - + - + @@ - + - + - + - + @@ - + - + - + @@ - + - + - + @@ - + - + - + - + - + @@ - + - + - + - + - + @@ - + - + - + @@ - - + + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - + - + @@ - + - + - - + + - + - + - - + + @@ - - + + - + - + - + - + - - + + - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi + - + - + - + - + - - + + - + - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - + - + - + @@ - + - @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - + - + @@ - + - + - - + + @@ - + - + - + @@ - + - + - + @@ - + - + - + - + - + - + - + @@ - - + + - + - - + + @@ - + - + - + - + - + - + - + - + @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - + - + - + - + - + @@ - + - + - - + + @@ - + - + - - + + - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - + @@ - + - + - + - + - + - + - + @@ - + - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - + - + - + - + - + - + - + - + - + - + @@ - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + - + - - + + @@ - + - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - + - - - + + + - + - - - + + + @@ - + - + - - + + @@ - + - + - + @@ - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - - + + - + - + @@ - + - + - + @@ - - + + - + - - + + - + - - + + @@ - - + + - + - + - + - + - + @@ - - + + - + - - + + @@ - - + + - + - + - - + + - + - - + + @@ - - + + - + - - - + + + - + - - + + @@ - - + + - + - - + + @@ - + - + - + - + - + @@ - + - + - + @@ - + - + - + - + - + - + @@ - + - + - + @@ - + - + - + - + - + - + - + - + @@ - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - + @@ - + - + - + - + - + @@ - + - + - + @@ - + - + - - + + @@ - + - + - + @@ - + - + - + @@ @@ tests/data/test-read-dwarf/test15-pr18892.so.abi + - + @@ - + - - + + @@ - + - + - - - + + + @@ - - + + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + @@ tests/data/test-read-dwarf/test15-pr18892.so.abi - + - - + + @@ - + - + - + - @@ tests/data/test-read-dwarf/test15-pr18892.so.abi @@ - + - + - + @@ - + - + @@ tests/data/test-read-dwarf/test16-pr18904.so.abi -@@ - - - -- -+ - - - - - - -- -+ - - - -@@ - - - -- -+ - - - - - - -- -+ - - - @@ - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + +@@ + + + +- ++ + + + + + + +- ++ + + + +@@ + + + +- ++ + + + + + + +- ++ + + + @@ - + - + @@ - - + + - + - - + + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi @@ - + - + - + @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ - - + + - + - - + + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ - + - + - + @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi @@ - + - @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test16-pr18904.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - - + + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi - + - + @@ @@ tests/data/test-read-dwarf/test3.so.abi + - + - + @@ tests/data/test-read-dwarf/test3.so.hash.abi + - + - + 14: f328cdab60d9 ! 15: 1b99c3a83176 dwarf-reader/writer: consider aliases when dealing with suppressions @@ Metadata ## Commit message ## dwarf-reader/writer: consider aliases when dealing with suppressions - When a symbol is suppressed and it happens to be the main symbol of a - group of aliased symbols where another symbol is not suppressed, the - dwarf reader discards the DWARF information upon reading and the writer - will not be able to connect dwarf information to the aliased elf symbol. + When the symbol of a decl is suppressed and it happens to be the main + symbol of a group of aliased symbols where another symbol is not + suppressed, the dwarf reader discards the decl from the internal + representation altogether upon reading and thus the writer will not be + able to connect that decl to the non-suppressed aliased elf symbol. - In order to address this, ensure we are not suppressing symbols - (actually functions and variables) for which an alias is not suppressed. - We therefore keep the DWARF information even if only a non-main symbol - is asked for. + In order to address this, ensure we are not suppressing decls for which + an alias is not suppressed. We therefore keep the decl in the IR when at + least one its underlying aliased symbols is non-suppressed. Likewise, when the abg-writer is having to attach an elf-symbol-id to - the DWARF collected information (for functions and variables), instead - of omitting the symbol altogether, rather make use of the property of - aliases and connect the dwarf information to an alias instead. This way - the function dwarf information stays connected to the elf symbol that we - want to track. + the decl, instead of omitting the symbol altogether, rather make use of + the property of aliases and connect the dwarf information to an alias + instead. This way the function dwarf information stays connected to the + elf symbol that we want to track. When reading from XML with a symbol whitelist that leads to suppression of aliased symbols, abidiff would hit an assertion and crash when @@ Commit message * tests/test-read-dwarf.cc: Add new test cases. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-dwarf-reader.cc ## @@ tests/data/test-read-dwarf/test-suppressed-alias.o (new) ## tests/data/test-read-dwarf/test-suppressed-alias.o.abi (new) ## @@ -+ ++ + + + + + + -+ ++ + + + @@ tests/data/test-read-dwarf/test-suppressed-alias.suppr (new) ## tests/data/test-read-dwarf/test3-alias-1.so.hash.abi (new) ## @@ -+ ++ + + + + + + -+ ++ + + + @@ tests/data/test-read-dwarf/test3-alias-1.suppr (new) ## tests/data/test-read-dwarf/test3-alias-2.so.hash.abi (new) ## @@ -+ ++ + + + @@ tests/data/test-read-dwarf/test3-alias-2.so.hash.abi (new) + + + -+ ++ + + + @@ tests/data/test-read-dwarf/test3-alias-2.suppr (new) ## tests/data/test-read-dwarf/test3-alias-3.so.hash.abi (new) ## @@ -+ ++ + + + + + + -+ ++ + + + @@ tests/data/test-read-dwarf/test3-alias-3.suppr (new) ## tests/data/test-read-dwarf/test3-alias-4.so.hash.abi (new) ## @@ -+ ++ + + + 15: da602c769e8f ! 16: 61f3486a7623 abg-writer.cc: fix write_elf_symbol_reference loop @@ Commit message Fixes: commmit ("dwarf-reader/writer: consider aliases when dealing with suppressions") Signed-off-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## src/abg-writer.cc ## 16: 9557767144f9 ! 17: 764897310058 symtab: Add support for MODVERSIONS (CRC checksums) @@ Commit message * tests/test-symtab.cc (Symtab::KernelSymtabsWithCRC): New test case. Reviewed-by: Giuliano Procida + Reviewed-by: Dodji Seketeli Signed-off-by: Matthias Maennich ## include/abg-ir.h ## @@ src/abg-ir.cc: struct elf_symbol::priv is_suppressed_(is_suppressed) { if (!is_common_) +@@ src/abg-ir.cc: elf_symbol::elf_symbol() + /// + /// @param is_linux_string_cst true if the symbol is a Linux Kernel + /// string constant defined in the __ksymtab_strings section. ++/// ++/// @param crc the CRC (modversions) value of Linux Kernel symbols + elf_symbol::elf_symbol(const environment* e, + size_t i, + size_t s, @@ src/abg-ir.cc: elf_symbol::elf_symbol(const environment* e, visibility vi, bool is_linux_string_cst, @@ src/abg-ir.cc: elf_symbol::elf_symbol(const environment* e, is_suppressed)) {} +@@ src/abg-ir.cc: elf_symbol::create() + /// @param is_linux_string_cst if true, it means the symbol represents + /// a string constant from a linux kernel binary. + /// ++/// @param crc the CRC (modversions) value of Linux Kernel symbols ++/// + /// @return a (smart) pointer to a newly created instance of @ref + /// elf_symbol. + elf_symbol_sptr @@ src/abg-ir.cc: elf_symbol::create(const environment* e, visibility vi, bool is_linux_string_cst, @@ src/abg-ir.cc: void elf_symbol::set_is_in_ksymtab(bool is_in_ksymtab) {priv_->is_in_ksymtab_ = is_in_ksymtab;} ++/// Getter of the 'crc' property. ++/// ++/// @return the CRC (modversions) value for Linux Kernel symbols (if present) +uint64_t +elf_symbol::get_crc() const +{return priv_->crc_;} + ++/// Setter of the 'crc' property. ++/// ++/// @param crc the new CRC (modversions) value for Linux Kernel symbols +void +elf_symbol::set_crc(uint64_t crc) +{priv_->crc_ = crc;} + - bool - elf_symbol::is_suppressed() const - {return priv_->is_suppressed_;} + /// Getter for the 'is-suppressed' property. + /// + /// @return true iff the current symbol has been suppressed by a ## src/abg-reader.cc ## @@ src/abg-reader.cc: build_elf_symbol(read_context& ctxt, const xmlNodePtr node, @@ src/abg-symtab-reader.cc: symtab::load_(Elf* elf_handle, std::unordered_set exported_kernel_symbols; + std::unordered_map crc_values; + const bool is_arm32 = elf_helpers::architecture_is_arm32(elf_handle); const bool is_ppc64 = elf_helpers::architecture_is_ppc64(elf_handle); - @@ src/abg-symtab-reader.cc: symtab::load_(Elf* elf_handle, ABG_ASSERT(exported_kernel_symbols.insert(name.substr(10)).second); continue; @@ src/abg-symtab-reader.cc: symtab::load_(Elf* elf_handle, + if (r == name_symbol_map_.end()) + continue; + -+ for (const auto& symbol : r->second) { ++ for (const auto& symbol : r->second) + symbol->set_crc(crc_entry.second); -+ } + } + // sort the symbols for deterministic output @@ tests/data/test-abidiff/test-empty-corpus-report.txt (deleted) ## tests/data/test-read-dwarf/PR25007-sdhci.ko.abi ## @@ - + - - @@ tests/data/test-read-dwarf/PR25007-sdhci.ko.abi + + - + ## tests/data/test-read-write/test-crc.xml (new) ## @@ -+ ++ + + +