From patchwork Wed Jan 27 12:58:34 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: 41835 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 CF2073971C3C; Wed, 27 Jan 2021 12:59:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CF2073971C3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752351; bh=IMAJmyAnvqlExA+Te96eT75k6mPliMHDurcni5mQK7M=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=LPRR5dk99a2/mxRBHSIZZIpa5ayvc8jSvvCvOCFyvA2G0CkAOjE9PRrC7Na/7XZkD 1R+ZqzM7ZixtcJ/zvydPtcejJsPredDVXhhBFqljjDQ6Si6vzdiIOlZsLp2TQkNbiK PNQWx6CtqdE8f1H9CAuZl+m+q/JBg7x+0GcJrvCs= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by sourceware.org (Postfix) with ESMTPS id 7C67B382D830 for ; Wed, 27 Jan 2021 12:59:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7C67B382D830 Received: by mail-wr1-x44a.google.com with SMTP id o17so912327wrv.4 for ; Wed, 27 Jan 2021 04:59:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IMAJmyAnvqlExA+Te96eT75k6mPliMHDurcni5mQK7M=; b=CO8Ba2cdWr3zGyHYOob+VCJUxXV6WMWsTxt9s8R7niG8CvRNEFeMRAAE7imICGvQ5L wJ5nOkPSRIeaTbOwcl6dtXbj/UkMwfThzr3butEE1XAGS1uXmohoglK42h2qWHOJTr38 FJLs0j7CKB/Czg6ryDhMkRIfy315+V0Go8tKsNcM+1Z1RTWTdGK57p6qVpGRHeI67KKA l2meo46hTdktP5Rcx6RaLWltvwo7TTncl7PVMLG5EgHpNLTsmHRYbAQfyDRX7PMnK8QE c/rF7rj8zVQWZLe8sWbdGcHglFSFa6ycqg4Li2JmIhaEWzrvBismqdeJfmRSQvkaGRJa 7uNQ== X-Gm-Message-State: AOAM531drfqoX9UoUSS7WacSdAq+QmC4BaUnKAdCyVNw5+3mgvk5hSEo 5QUXV/KVdEEmeA7Sl2Ivc4P6Noox1uhLnYKWHmiQO1yR/anfKr91fw2Rps/trcuUdos3wUfAa5+ fFFTTMUAOweL1s/bPDussGoWXCQU4jYdaUMRwb2ed9rmWN75w3hHkXszJnZr2ReToqk0MzmY= X-Google-Smtp-Source: ABdhPJwqR4vxv9uU5aWG5Ejg5IGsCLYyoGM1BxgB7otlKP2iJbJ8jFj6e3gzpaf9jVxmfqutLgUKJQw7AB0CTg== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a7b:cb54:: with SMTP id v20mr4251488wmj.148.1611752348145; Wed, 27 Jan 2021 04:59:08 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:34 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-2-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 01/20] abg-cxx-compat: add simplified version of std::optional To: libabigail@sourceware.org X-Spam-Status: No, score=-22.6 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" In the absence (but desire) of std::optional, add a simplified version of it to abg_compat:: in case we are compiling with a pre-C++17 standard. Otherwise use std::optional from directly. This is being used by a later patch and serves as a prerequisite. It only serves the purpose of being a compatibility implementation and does not claim to be complete at all. Just enough for the project's needs. * include/abg-cxx-compat.h (abg_compat::optional): Add new class. * tests/tests-cxx-compat.cc: Add new test cases. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-cxx-compat.h | 84 ++++++++++++++++++++++++++++++++++++++++ tests/test-cxx-compat.cc | 52 +++++++++++++++++++++++++ 2 files changed, 136 insertions(+) diff --git a/include/abg-cxx-compat.h b/include/abg-cxx-compat.h index 838fa53707d1..443905c75138 100644 --- a/include/abg-cxx-compat.h +++ b/include/abg-cxx-compat.h @@ -8,8 +8,92 @@ #ifndef __ABG_CXX_COMPAT_H #define __ABG_CXX_COMPAT_H +// C++17 support (via custom implementations if compiled with earlier standard) + +#if __cplusplus >= 201703L + +#include + +#else + +#include // for throwing std::runtime_error("bad_optional_access") + +#endif + namespace abg_compat { +#if __cplusplus >= 201703L + +using std::optional; + +#else + +// + +/// Simplified implementation of std::optional just enough to be used as a +/// replacement for our purposes and when compiling with pre C++17. +/// +/// The implementation intentionally does not support a whole lot of features +/// to minimize the maintenance effort with this. +template class optional +{ + bool has_value_; + T value_; + +public: + optional() : has_value_(false), value_() {} + optional(const T& value) : has_value_(true), value_(value) {} + + bool + has_value() const + { + return has_value_; + } + + const T& + value() const + { + if (!has_value_) + throw std::runtime_error("bad_optional_access"); + return value_; + } + + const T + value_or(const T& default_value) const + { + if (!has_value_) + return default_value; + return value_; + } + + const T& + operator*() const + { return value_; } + + T& + operator*() + { return value_; } + + const T* + operator->() const + { return &value_; } + + T* + operator->() + { return &value_; } + + optional& + operator=(const T& value) + { + has_value_ = true; + value_ = value; + return *this; + } + + explicit operator bool() const { return has_value_; } +}; + +#endif } #endif // __ABG_CXX_COMPAT_H diff --git a/tests/test-cxx-compat.cc b/tests/test-cxx-compat.cc index 35dc4f6104c2..2b0caaae1ab4 100644 --- a/tests/test-cxx-compat.cc +++ b/tests/test-cxx-compat.cc @@ -12,3 +12,55 @@ #include "lib/catch.hpp" #include "abg-cxx-compat.h" + +using abg_compat::optional; + +TEST_CASE("OptionalConstruction", "[abg_compat::optional]") +{ + optional opt1; + REQUIRE_FALSE(opt1.has_value()); + + optional opt2(true); + REQUIRE(opt2.has_value()); + CHECK(opt2.value() == true); + + optional opt3(false); + REQUIRE(opt3.has_value()); + CHECK(opt3.value() == false); +} + +TEST_CASE("OptionalValue", "[abg_compat::optional]") +{ + optional opt; + REQUIRE_FALSE(opt.has_value()); + REQUIRE_THROWS(opt.value()); + + opt = true; + REQUIRE_NOTHROW(opt.value()); + CHECK(opt.value() == true); +} + +TEST_CASE("OptionalValueOr", "[abg_compat::optional]") +{ + optional opt; + REQUIRE_FALSE(opt.has_value()); + + const std::string& mine = "mine"; + // Ensure we get a copy of our own value. + CHECK(opt.value_or(mine) == mine); + + // Now set the value + const std::string& other = "other"; + opt = other; + CHECK(opt.value_or(mine) != mine); + CHECK(opt.value_or(mine) == other); +} + +TEST_CASE("OptionalDeref", "[abg_compat::optional]") +{ + optional opt("asdf"); + REQUIRE(opt.has_value()); + + CHECK(*opt == "asdf"); + CHECK(opt->size() == 4); +} From patchwork Wed Jan 27 12:58:35 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: 41836 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 24BE2396EC6E; Wed, 27 Jan 2021 12:59:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 24BE2396EC6E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752353; bh=zgjd9IU5V06y2MD77ruwpvAOtYwhySW9CVAbHbe/+/U=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Yhp2lFdZz204ONJZiqdaEdlY7IylEDl+mD6zKIiYNTcqwt4X3UKxud0sO7ArZG42K L5xfGCPiHXTOIg+fvpcDho999mrwxfB/8fTuPDM4evMirqzCl40ajtqLpeHHoZJ/54 hzicm4O4jraMv0Zuhyds4Ng2L9TwmQeJNyMjeNb4= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qt1-x84a.google.com (mail-qt1-x84a.google.com [IPv6:2607:f8b0:4864:20::84a]) by sourceware.org (Postfix) with ESMTPS id 418AE382D830 for ; Wed, 27 Jan 2021 12:59:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 418AE382D830 Received: by mail-qt1-x84a.google.com with SMTP id z19so1002779qtv.20 for ; Wed, 27 Jan 2021 04:59:11 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=zgjd9IU5V06y2MD77ruwpvAOtYwhySW9CVAbHbe/+/U=; b=fvb0ZgcJcvuZfNCh9Pw+hwCdOfChvWphTnjUPCphz80u9HQLLAWQATdBQNHM5mSGo2 2/YBccgBAtxuyTCK7bK1GImnAX3/Fh2n3Hw51Tgi5lffr3x1tEWOXBYvMxMT8/Dhog/2 VRMiwmL6CmJgEW4MIBdM5xXNOuNJv5m0Au+cT57gVez/yeYIzerT18s38sl5IEg43eHC xwOuwLTSmZnZAHKI6UuaU7jL2z9Rh3noChZV3JHA79CmKD/8pWNN17+4q40frxgpOq7d o5IdIvIXX3EFDQ0BG+PzVLdVzYtJlfHEAOK99ilHZfx/sNLLPe8nUQIZwTW+f7K6WSo3 0EZQ== X-Gm-Message-State: AOAM532qfHdUtYxyW8qwP/jySC1l7kjGobW3idNvtLTgss5XK80ALNXF 0tZzfkq4ocMlHK4Im9VquHOm7mJ3QjG7RqUhPcbimLKgdDLtnKlxzH5JWrhDoK0teITc8fFG+99 tH44aqrqbFU95pGsok/USrdRyr/wdcW84/A51aKPn8TUWWDHoYPqhTpYWzLfuWH5fZWmyhu8= X-Google-Smtp-Source: ABdhPJyWaXeC3FUoJvPQfQWEOG0YVe5cGBg999FrwBMEeh3Z7YGUPiIjQLGXZj5f8ZxoMmmZk2uUO0p+svTv/Q== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:eda6:: with SMTP id h6mr10021252qvr.19.1611752350663; Wed, 27 Jan 2021 04:59:10 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:35 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-3-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 02/20] abg-ir: elf_symbol: add is_in_ksymtab field To: libabigail@sourceware.org X-Spam-Status: No, score=-22.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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Being exported through a ksymtab (in case of Linux Kernel binaries) is actually a property of the Elf symbol itself and we can therefore track it along with the symbol that we collect from symtab. While tracking is currently done by keeping separate symbol lists and maps for symtab and ksymtab symbols, they can be consolidated having a property to indicate whether this symbol also appeared as a ksymtab entry. Hence, and for future changes in this area, add this property and update all references. The flag is false initially unless otherwise specified. * include/abg-ir.h (elf_symbol::elf_symbol): Add is_in_ksymtab parameter. (elf_symbol::create): Likewise. (elf_symbol::is_in_ksymtab): New getter declaration. (elf_symbol::set_is_in_ksymtab): New setter declaration. * src/abg-ir.cc (elf_symbol::priv::priv): Add is_in_ksymtab parameter. (elf_symbol::priv::is_in_ksymtab_): New field. (elf_symbol::elf_symbol): Add is_in_ksymtab parameter. (elf_symbol::create): Likewise. (elf_symbol::is_in_ksymtab): New getter implementation. (elf_symbol::set_is_in_ksymtab): New setter implementation. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-ir.h | 34 +++++++++------ src/abg-ir.cc | 105 +++++++++++++++++++++++++++++------------------ 2 files changed, 86 insertions(+), 53 deletions(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index c32b2f7fe989..d82c83592f82 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -837,8 +837,9 @@ private: bool d, bool c, const version& ve, - visibility vi, - bool is_linux_string_cst = false); + visibility vi, + bool is_linux_string_cst = false, + bool is_in_ksymtab = false); elf_symbol(const elf_symbol&); @@ -851,17 +852,18 @@ public: create(); static elf_symbol_sptr - create(const environment* e, - size_t i, - size_t s, - const string& n, - type t, - binding b, - bool d, - bool c, - const version& ve, - visibility vi, - bool is_linux_string_cst = false); + create(const environment* e, + size_t i, + size_t s, + const string& n, + type t, + binding b, + bool d, + bool c, + const version& ve, + visibility vi, + bool is_linux_string_cst = false, + bool is_in_ksymtab = false); const environment* get_environment() const; @@ -929,6 +931,12 @@ public: bool is_variable() const; + bool + is_in_ksymtab() const; + + void + set_is_in_ksymtab(bool is_in_ksymtab); + const elf_symbol_sptr get_main_symbol() const; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index d1d02f3aad5d..22532cc87dfd 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -1310,6 +1310,7 @@ struct elf_symbol::priv // STT_COMMON definition of that name that has the largest size. bool is_common_; bool is_linux_string_cst_; + bool is_in_ksymtab_; elf_symbol_wptr main_symbol_; elf_symbol_wptr next_alias_; elf_symbol_wptr next_common_instance_; @@ -1324,20 +1325,22 @@ struct elf_symbol::priv visibility_(elf_symbol::DEFAULT_VISIBILITY), is_defined_(false), is_common_(false), - is_linux_string_cst_(false) + is_linux_string_cst_(false), + is_in_ksymtab_(false) {} - priv(const environment* e, - size_t i, - size_t s, - const string& n, - elf_symbol::type t, - elf_symbol::binding b, - bool d, - bool c, - const elf_symbol::version& ve, - elf_symbol::visibility vi, - bool is_linux_string_cst) + priv(const environment* e, + size_t i, + size_t s, + const string& n, + elf_symbol::type t, + elf_symbol::binding b, + bool d, + bool c, + const elf_symbol::version& ve, + elf_symbol::visibility vi, + bool is_linux_string_cst, + bool is_in_ksymtab) : env_(e), index_(i), size_(s), @@ -1348,7 +1351,8 @@ struct elf_symbol::priv visibility_(vi), is_defined_(d), is_common_(c), - is_linux_string_cst_(is_linux_string_cst) + is_linux_string_cst_(is_linux_string_cst), + is_in_ksymtab_(is_in_ksymtab) { if (!is_common_) is_common_ = type_ == COMMON_TYPE; @@ -1394,19 +1398,30 @@ 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. -elf_symbol::elf_symbol(const environment* e, - size_t i, - size_t s, - const string& n, - type t, - binding b, - bool d, - bool c, - const version& ve, - visibility vi, - bool is_linux_string_cst) - : priv_(new priv(e, i, s, n, t, b, d, - c, ve, vi, is_linux_string_cst)) +elf_symbol::elf_symbol(const environment* e, + size_t i, + size_t s, + const string& n, + type t, + binding b, + bool d, + bool c, + const version& ve, + visibility vi, + bool is_linux_string_cst, + bool is_in_ksymtab) + : priv_(new priv(e, + i, + s, + n, + t, + b, + d, + c, + ve, + vi, + is_linux_string_cst, + is_in_ksymtab)) {} /// Factory of instances of @ref elf_symbol. @@ -1453,20 +1468,22 @@ elf_symbol::create() /// @return a (smart) pointer to a newly created instance of @ref /// elf_symbol. elf_symbol_sptr -elf_symbol::create(const environment* e, - size_t i, - size_t s, - const string& n, - type t, - binding b, - bool d, - bool c, - const version& ve, - visibility vi, - bool is_linux_string_cst) -{ - elf_symbol_sptr sym(new elf_symbol(e, i, s, n, t, b, d, c, ve, - vi, is_linux_string_cst)); +elf_symbol::create(const environment* e, + size_t i, + size_t s, + const string& n, + type t, + binding b, + bool d, + bool c, + const version& ve, + visibility vi, + bool is_linux_string_cst, + bool is_in_ksymtab) +{ + elf_symbol_sptr sym(new elf_symbol(e, i, s, n, t, b, d, c, ve, vi, + is_linux_string_cst, + is_in_ksymtab)); sym->priv_->main_symbol_ = sym; return sym; } @@ -1686,6 +1703,14 @@ bool elf_symbol::is_variable() const {return get_type() == OBJECT_TYPE || get_type() == TLS_TYPE;} +bool +elf_symbol::is_in_ksymtab() const +{return priv_->is_in_ksymtab_;} + +void +elf_symbol::set_is_in_ksymtab(bool is_in_ksymtab) +{priv_->is_in_ksymtab_ = is_in_ksymtab;} + /// @name Elf symbol aliases /// /// An alias A for an elf symbol S is a symbol that is defined at the From patchwork Wed Jan 27 12:58:36 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: 41837 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 8C9CC3971830; Wed, 27 Jan 2021 12:59:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8C9CC3971830 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752355; bh=284iQNR8hS3qvWB1uODjpQ+ZEyfRumfCSXRi94FHAzM=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=jvoYZ5rgIjHe5osNlBEqEu9BL5GMqtd4EqXSr9xM13XHorlC7eU//wVhcyllC8Vxi I41oUh1IwpH3QmFU3gvUrEJ01U1+uwYW/UkXMC3eCIrqvE3i2jX5Vz3Y+HN3PFiHGc NRj+6wlpfWmpC68GVd67uzkJmtju4NpSG+pZKtoE= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by sourceware.org (Postfix) with ESMTPS id 651443972827 for ; Wed, 27 Jan 2021 12:59:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 651443972827 Received: by mail-qk1-x749.google.com with SMTP id l124so1378841qke.7 for ; Wed, 27 Jan 2021 04:59:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=284iQNR8hS3qvWB1uODjpQ+ZEyfRumfCSXRi94FHAzM=; b=NsIm6tgq1lwynTtoTsXkQ/XRZYc7KfZ3QDRdOkL53UGLrYjfNPewFdfUXb9pA/Zgwj IKmjPYtyUxthc0bD90oRphOArFN4zbcq94yJdkmr7QF9r0KFEEcHmI52jn4WVtIa9DB5 QUaSTqkRfAuBiwe7XAK2dlkl5xOpnX9SYjoamYvD4k9g8tDczcR9H/iD8NQIMzjDdeBT ndccarLZOsMtj1RKVk1LUSojeZ+outd2gmw5QkZAEnwG3/UWT4n2ZVdnTxrQs6qeVlX9 IXToq1Mn01/Y5Fyw0cFuNTli+NNVpv6WTwdohY6hJ6knWJRRFldwUveaPC9CVzoSVjBS 1XaA== X-Gm-Message-State: AOAM531EBaC/FScl+wUTnXNmp9asjtAtKUE/gb/SNtRsE6n5Z3x0Eloe 7rRQICWmCyOEIOJ1tO1DcsV6ugaem8pngRNnQyrGVM5gwFu9YJKw07ZUWomgxOgu/4oFAyV1eEK T5zU5Rl6I//jqn5Otqe5PlGSXW/q+KXxC2Q9Y7mcUvcuNjyrm/zQJqvHkX9uYepxlnPlvGiU= X-Google-Smtp-Source: ABdhPJwEJoNYFLkkRTS8se/4uDf65sj4bZL6vTsFHZRZmAmZWsxg9bB/awhWPaAZEW+JhhMuT2xSLhj9hXwUqw== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:8365:: with SMTP id j92mr10365042qva.19.1611752352954; Wed, 27 Jan 2021 04:59:12 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:36 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-4-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 03/20] abg-ir: elf_symbol: add is_suppressed field To: libabigail@sourceware.org X-Spam-Status: No, score=-22.7 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" In the context of libabigail and a single library run (when reading from dwarf or from xml), a symbol is either suppressed or it is not. While one could argue that this is a property of the read_context, the read_context might not be around anymore when the symbol still is. Hence, persist the 'is_suppressed' state along with the symbol itself. * include/abg-ir.h (elf_symbol::elf_symbol): Add is_suppressed parameter. (elf_symbol::create): Likewise. (elf_symbol::is_suppressed): New getter declaration. (elf_symbol::set_is_suppressed): New setter declaration. * src/abg-ir.cc (elf_symbol::priv::priv): Add is_suppressed parameter. (elf_symbol::priv::is_suppressed_): New field. (elf_symbol::elf_symbol): Add is_suppressed parameter. (elf_symbol::create): Likewise. (elf_symbol::is_suppressed): New getter implementation. (elf_symbol::set_is_suppressed): New setter implementation. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-ir.h | 12 ++++++++++-- src/abg-ir.cc | 29 ++++++++++++++++++++++------- 2 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/abg-ir.h b/include/abg-ir.h index d82c83592f82..23ba16bd327b 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -839,7 +839,8 @@ private: const version& ve, visibility vi, bool is_linux_string_cst = false, - bool is_in_ksymtab = false); + bool is_in_ksymtab = false, + bool is_suppressed = false); elf_symbol(const elf_symbol&); @@ -863,7 +864,8 @@ public: const version& ve, visibility vi, bool is_linux_string_cst = false, - bool is_in_ksymtab = false); + bool is_in_ksymtab = false, + bool is_suppressed = false); const environment* get_environment() const; @@ -937,6 +939,12 @@ public: void set_is_in_ksymtab(bool is_in_ksymtab); + bool + is_suppressed() const; + + void + set_is_suppressed(bool is_suppressed); + const elf_symbol_sptr get_main_symbol() const; diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 22532cc87dfd..1ba95dd6c14f 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -1311,6 +1311,7 @@ struct elf_symbol::priv bool is_common_; bool is_linux_string_cst_; bool is_in_ksymtab_; + bool is_suppressed_; elf_symbol_wptr main_symbol_; elf_symbol_wptr next_alias_; elf_symbol_wptr next_common_instance_; @@ -1326,7 +1327,8 @@ struct elf_symbol::priv is_defined_(false), is_common_(false), is_linux_string_cst_(false), - is_in_ksymtab_(false) + is_in_ksymtab_(false), + is_suppressed_(false) {} priv(const environment* e, @@ -1340,7 +1342,8 @@ struct elf_symbol::priv const elf_symbol::version& ve, elf_symbol::visibility vi, bool is_linux_string_cst, - bool is_in_ksymtab) + bool is_in_ksymtab, + bool is_suppressed) : env_(e), index_(i), size_(s), @@ -1352,7 +1355,8 @@ struct elf_symbol::priv is_defined_(d), is_common_(c), is_linux_string_cst_(is_linux_string_cst), - is_in_ksymtab_(is_in_ksymtab) + is_in_ksymtab_(is_in_ksymtab), + is_suppressed_(is_suppressed) { if (!is_common_) is_common_ = type_ == COMMON_TYPE; @@ -1409,7 +1413,8 @@ elf_symbol::elf_symbol(const environment* e, const version& ve, visibility vi, bool is_linux_string_cst, - bool is_in_ksymtab) + bool is_in_ksymtab, + bool is_suppressed) : priv_(new priv(e, i, s, @@ -1421,7 +1426,8 @@ elf_symbol::elf_symbol(const environment* e, ve, vi, is_linux_string_cst, - is_in_ksymtab)) + is_in_ksymtab, + is_suppressed)) {} /// Factory of instances of @ref elf_symbol. @@ -1479,11 +1485,12 @@ elf_symbol::create(const environment* e, const version& ve, visibility vi, bool is_linux_string_cst, - bool is_in_ksymtab) + bool is_in_ksymtab, + bool is_suppressed) { elf_symbol_sptr sym(new elf_symbol(e, i, s, n, t, b, d, c, ve, vi, is_linux_string_cst, - is_in_ksymtab)); + is_in_ksymtab, is_suppressed)); sym->priv_->main_symbol_ = sym; return sym; } @@ -1711,6 +1718,14 @@ void elf_symbol::set_is_in_ksymtab(bool is_in_ksymtab) {priv_->is_in_ksymtab_ = is_in_ksymtab;} +bool +elf_symbol::is_suppressed() const +{return priv_->is_suppressed_;} + +void +elf_symbol::set_is_suppressed(bool is_suppressed) +{priv_->is_suppressed_ = is_suppressed;} + /// @name Elf symbol aliases /// /// An alias A for an elf symbol S is a symbol that is defined at the From patchwork Wed Jan 27 12:58:37 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: 41838 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 D17963971C3C; Wed, 27 Jan 2021 12:59:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D17963971C3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752358; bh=IEj+VDlJ6TcTEtpciyhJQZfM3Vt/s/2x1yOHuFtKw/o=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=tkbjx7a53FD4HiAzCTGR+Dn5UFAjK8ARP4piqIWeCJ/8M7B+ZDEVn54FRlNFGGzRe Blf8pmIBr4OR/Pfl3ZOqYCmRIXu6rCJOyoJw056yswJ9Kw/URrAEUp8NLegP6ZJU1S hDXRbkrQ5c9+6p5qSImeqTIvYAtIp8MEAHQwNj3M= 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 8CEB43971C3C for ; Wed, 27 Jan 2021 12:59:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8CEB43971C3C Received: by mail-qt1-x849.google.com with SMTP id f5so1011413qtf.15 for ; Wed, 27 Jan 2021 04:59:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=IEj+VDlJ6TcTEtpciyhJQZfM3Vt/s/2x1yOHuFtKw/o=; b=GG1D3YPiWBKU6W3nfJvXU4meiGcli11ogPL4QnAkYj2DPxag6TO7R58UgsiPnMCi78 vu8/8sk6qBq0JPlq5GTc6iFHtBPCLEGH2k5h3Ug+HomOj4pWwuaZNRPNLcYED1OQh3Y1 9E9+Fc8IYetn668akVlbof/UP7Ky9RP9awMvDbr2me3Dd1Ve+Z/tiVNjkxt9iDwjKlAV QQQw4JU0q/tSL4nJGMM3ahf6QLGozEYXSGZtkt5MxY05AdGJA9G/u9Og9qQMBzkH0pF2 gjX2B/0ltWqJLKAz5CGbCN/6z36M3ya/dIdZcNPxCzIMRXOALYwbptCmhOEws9ESS3rk +NnQ== X-Gm-Message-State: AOAM532iGa7G+LZyeJW7FifT5dEEEjYUM72TDHnJ/SfJhySpTk0iQoBy tRxOwlPXbFdTzTPi3fsNt7xeUFJUadGS/H3urXTCxzYAOw8Xu5UPT8kdXWb1+o3t6pV3vhnUr+X TMWGnK6OAz+G4eAAwyteT7IHUZzB9lhsI8bMI5KTGCGL9y0m1VjX6Hid/h9JN/6XwSba4U48= X-Google-Smtp-Source: ABdhPJy5MmP8lUHwTxg4xTULSfjKSurWpBxw0vlGdsg8g1I+KmQ0GunaBGEdPaQreFtn3ESo7fCSOLEyn01Qzg== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:c30e:: with SMTP id f14mr10184150qvi.48.1611752355002; Wed, 27 Jan 2021 04:59:15 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:37 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-5-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 04/20] dwarf-reader split: create abg-symtab-reader.{h, cc} and test case To: libabigail@sourceware.org X-Spam-Status: No, score=-22.2 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" abg-symtab-reader.{h,cc} shall contain the refactored symtab reader. Create the stub files, an empty unit test and hook everything up in the make system. * src/abg-symtab-reader.h: New header file. * src/abg-symtab-reader.cc: New source file. * src/Makefile.am: Add new source files. * tests/Makefile.am: Add new test case runtestsymtabreader. * tests/test-symtab-reader.cc: New test source file. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/Makefile.am | 2 ++ src/abg-symtab-reader.cc | 21 +++++++++++++++++++++ src/abg-symtab-reader.h | 24 ++++++++++++++++++++++++ tests/Makefile.am | 4 ++++ tests/test-symtab-reader.cc | 15 +++++++++++++++ 5 files changed, 66 insertions(+) create mode 100644 src/abg-symtab-reader.cc create mode 100644 src/abg-symtab-reader.h create mode 100644 tests/test-symtab-reader.cc diff --git a/src/Makefile.am b/src/Makefile.am index 26fc4d1566ca..86877635be03 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,6 +38,8 @@ abg-tools-utils.cc \ abg-elf-helpers.h \ abg-elf-helpers.cc \ abg-regex.cc \ +abg-symtab-reader.h \ +abg-symtab-reader.cc \ $(VIZ_SOURCES) libabigail_la_LIBADD = $(DEPS_LIBS) diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc new file mode 100644 index 000000000000..a6c8ca0ef548 --- /dev/null +++ b/src/abg-symtab-reader.cc @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// -*- Mode: C++ -*- +// +// Copyright (C) 2020 Google, Inc. +// +// Author: Matthias Maennich + +/// @file +/// +/// This contains the definition of the symtab reader + +#include "abg-symtab-reader.h" + +namespace abigail +{ + +namespace symtab_reader +{ + +} // end namespace symtab_reader +} // end namespace abigail diff --git a/src/abg-symtab-reader.h b/src/abg-symtab-reader.h new file mode 100644 index 000000000000..a929166b83ef --- /dev/null +++ b/src/abg-symtab-reader.h @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// -*- Mode: C++ -*- +// +// Copyright (C) 2020 Google, Inc. +// +// Author: Matthias Maennich + +/// @file +/// +/// This contains the declarations for the symtab reader. + +#ifndef __ABG_SYMTAB_READER_H__ +#define __ABG_SYMTAB_READER_H__ + +namespace abigail +{ + +namespace symtab_reader +{ + +} // end namespace symtab_reader +} // end namespace abigail + +#endif // __ABG_SYMTAB_READER_H__ diff --git a/tests/Makefile.am b/tests/Makefile.am index 655facb19ec1..533cc23680ce 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -46,6 +46,7 @@ runtestkmiwhitelist \ runtestlookupsyms \ runtestreadwrite \ runtestsymtab \ +runtestsymtabreader \ runtesttoolsutils \ runtestsvg \ $(FEDABIPKGDIFF_TEST) \ @@ -156,6 +157,9 @@ runtestcxxcompat_LDADD = libcatch.la $(top_builddir)/src/libabigail.la runtestsymtab_SOURCES = test-symtab.cc runtestsymtab_LDADD = libtestutils.la libcatch.la $(top_builddir)/src/libabigail.la +runtestsymtabreader_SOURCES = test-symtab-reader.cc +runtestsymtabreader_LDADD = libcatch.la $(top_builddir)/src/libabigail.la + runtestsvg_SOURCES=test-svg.cc runtestsvg_LDADD=$(top_builddir)/src/libabigail.la diff --git a/tests/test-symtab-reader.cc b/tests/test-symtab-reader.cc new file mode 100644 index 000000000000..1bd37572f4d7 --- /dev/null +++ b/tests/test-symtab-reader.cc @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// -*- Mode: C++ -*- +// +// Copyright (C) 2020 Google, Inc. +// +// Author: Matthias Maennich + +/// @file +/// +/// This program tests libabigail's symtab reader. + +#include "lib/catch.hpp" + +#include "abg-symtab-reader.h" + From patchwork Wed Jan 27 12:58:38 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: 41839 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 26EF53972827; Wed, 27 Jan 2021 12:59:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26EF53972827 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752362; bh=NL5VusAhaxB7NQAPdqJZJyyOGstyDNFXX/J5YX7cqFI=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=OazQDl+KRE1J+ASoipJse54jQQkAuha+U11m2ijnjq7vK5CEI77SlDWgeTYTtSdui /1zE/M5gUbmVMqMFTYcXrCw2BqgDqUv+jCUA9gqTuL+qV6sR+BVy67q+PP2dwZMek+ k3Gyn16t4UPMj19Yn9KufPxfni3dMiqaOcsD/uCM= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x749.google.com (mail-qk1-x749.google.com [IPv6:2607:f8b0:4864:20::749]) by sourceware.org (Postfix) with ESMTPS id E9CD33971830 for ; Wed, 27 Jan 2021 12:59:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E9CD33971830 Received: by mail-qk1-x749.google.com with SMTP id m64so1368613qke.12 for ; Wed, 27 Jan 2021 04:59:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=NL5VusAhaxB7NQAPdqJZJyyOGstyDNFXX/J5YX7cqFI=; b=XWI/5UDtkhOUNXr54QF1Tuh0UIYcVvd4IeKHSxMUjDjzbzR+YN1aHoITHaYMfHP9g/ QQriIasVzKr2QcuEXB8vnnoRoH3fqOqOc+7PEd7LiJRyFW5mZjsHm1CK//BP/vKtnXzG 8ObcdXDaAxqZt4zxsbA27jhi2/X3wVK8HkFkPPWXxJv4xWzpMYKzv9p8i9BmvHNRoHjK DxkHeBXup9t4cnZTqgTHncS6rxGHxiuxHdptN2H330qghx2iff2VDATE+rHbqEUZObuz 88NJrZrcMAJIDycjB/zrRNTkW7aWLFZvgnM3/Fw8uD9DgkN6d5EF0drR+NtNrGcc2GhF mSHQ== X-Gm-Message-State: AOAM5317S+vKG8CbzlsR9JSeQrg/f9zf3LxJp2Hf4TpzAAYuSvrel2SY bTSLrVMswggDE3YwpB5XsBaUv2AkoCaA4tb/77pY5rBogMNriTFSpOTl2a2CDx/VIgWr11JLGS4 UENc1q8SbKO/WQfXq92U/LYtbUYqJG3PvrfZJOAf4JzxLe/69IvIcQSfeOYVJ+VBea2nSPCA= X-Google-Smtp-Source: ABdhPJwxLvxi4g+Jya9oAOfhBLkzarnXioUDwX0uHFAvilBTZLosqqKskmWCbSxHqfJPp4nHppa+taL93tK/wQ== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:fd64:: with SMTP id k4mr10118522qvs.3.1611752357494; Wed, 27 Jan 2021 04:59:17 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:38 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-6-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 05/20] Refactor ELF symbol table reading by adding a new symtab reader To: libabigail@sourceware.org X-Spam-Status: No, score=-22.6 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Based on existing functionality, implement the reading of ELF symbol tables as a separate component. This reduces the complexity of abg-dwarf-reader's read_context by separating and delegating the functionality. This also allows dedicated testing. The new namespace symtab_reader contains a couple of new components that work loosely coupled together. Together they allow for a consistent view on a symbol table. With filter criteria those views can be restricted, iterated and consistent lookup maps can be built on top of them. While this implementation tries to address some shortcomings of the previous model, it still provides the high level interfaces to the symbol table contents through sorted iterating and name/address mapped access. symtab_reader::symtab While the other classes in the same namespace are merely helpers, this is the main implementation of symtab reading and storage. Symtab objects are factory created to ensure a consistent construction and valid invariants. Thus a symtab will be loaded by either passing an ELF handle (when reading from binary) or by passing a set of function/variable symbol maps (when reading from XML). When constructed they are considered const and are not writable anymore. As such, all public methods are const. The load reuses the existing implementation for loading symtab sections, but since the new implementation does not distinguish between functions and variables, the code could be simplified. The support for ppc64 function entry addresses has been deferred to a later commit. Linux Kernel symbol tables are now directly loaded by name when encountering symbols prefixed with the __ksymtab_ as per convention. This has been tricky in the past due to various different binary layouts (relocations, position relative relocations, symbol namespaces, CFI indirections, differences between vmlinux and kernel modules). Thus the new implementation is much simpler and is less vulnerable to future ksymtab changes. As we are also not looking up the Kernel symbols by addresses, we could resolve shortcomings with symbol aliasing: Previously a symbol and its alias were indistinguishable as they are having the same symbol address. We could not identify the one that is actually exported via ksymtab. One major architectural difference of this implementation is that we do not early discard suppressed symbols. While we keep them out of the vector of exported symbols, we still make them available for lookup. That helps addressing issues when looking up a symbol by address (e.g. from the ksymtab read implementation) that is suppressed. That would fail in the existing implementation. Still, we intend to only instantiate each symbol once and pass around shared_ptr instances to refer to it from the vector as well as from the lookup maps. For reading, there are two access paths that serve the existing patterns: 1) lookup_symbol: either via a name or an address 2) filtered iteration with begin(), end() The former is used for direct access with a clue in hand (like a name or an address), the latter is used for iteration (e.g. when emitting the XML). symtab_reader::symtab_iterator The symtab_iterator is an STL compatible iterator that is returned from begin() and end() of the symtab. It allows usual forward iterator operations and can optionally take a filter predicate to skip non matching elements. symtab_reader::symtab_filter The symtab_filter serves as a predicate for the symtab_iterator by providing a matches(const elf_symbol_sptr&) function. The predicate is built by ANDing together several conditions on attributes a symbol can have. The filter conditions are implemented in terms of std::optional members to allow a tristate: "needs to have the condition set", "must not have it set" and "don't care". symtab_reader::filtered_symtab The filtered_symtab is a convenience zero cost abstraction that allows prepopulating the symtab_filter (call it a capture) such that begin() and end() are now accessible without the need to pass the filter again. Argumentless begin() and end() are a requirement for range-for loops and other STL based algorithms. * src/abg-symtab-reader.h (symtab_filter): New class. (symtab_iterator): Likewise. (symtab): Likewise. (filtered_symtab): Likewise. * src/abg-symtab-reader.cc (symtab_filter::matches): New. (symtab::make_filter): Likewise. (symtab::lookup_symbol): Likewise. (symbol_sort): Likewise. (symtab::load): Likewise. (symtab::load_): Likewise. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-symtab-reader.cc | 347 +++++++++++++++++++++++++++++++++++++++ src/abg-symtab-reader.h | 277 ++++++++++++++++++++++++++++++- 2 files changed, 623 insertions(+), 1 deletion(-) diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc index a6c8ca0ef548..4576be2a0b42 100644 --- a/src/abg-symtab-reader.cc +++ b/src/abg-symtab-reader.cc @@ -1,6 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // -*- Mode: C++ -*- // +// Copyright (C) 2013-2020 Red Hat, Inc. // Copyright (C) 2020 Google, Inc. // // Author: Matthias Maennich @@ -9,7 +10,20 @@ /// /// This contains the definition of the symtab reader +#include +#include +#include + +#include "abg-elf-helpers.h" +#include "abg-fwd.h" +#include "abg-internal.h" +#include "abg-tools-utils.h" + +// Though this is an internal header, we need to export the symbols to be able +// to test this code. TODO: find a way to export symbols just for unit tests. +ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-symtab-reader.h" +ABG_END_EXPORT_DECLARATIONS namespace abigail { @@ -17,5 +31,338 @@ namespace abigail namespace symtab_reader { +/// symtab_filter implementations + +/// Determine whether a symbol is matching the filter criteria of this filter +/// object. In terms of a filter functionality, you would _not_ filter out +/// this symbol if it passes this (i.e. returns true). +/// +/// @param symbol The Elf symbol under test. +/// +/// @return whether the symbol matches all relevant / required criteria +bool +symtab_filter::matches(const elf_symbol& symbol) const +{ + if (functions_ && *functions_ != symbol.is_function()) + return false; + if (variables_ && *variables_ != symbol.is_variable()) + return false; + if (public_symbols_ && *public_symbols_ != symbol.is_public()) + return false; + if (undefined_symbols_ && *undefined_symbols_ == symbol.is_defined()) + return false; + if (kernel_symbols_ && *kernel_symbols_ != symbol.is_in_ksymtab()) + return false; + + return true; +} + +/// symtab implementations + +/// Obtain a suitable default filter for iterating this symtab object. +/// +/// The symtab_filter obtained is populated with some sensible default +/// settings, such as public_symbols(true) and kernel_symbols(true) if the +/// binary has been identified as Linux Kernel binary. +/// +/// @return a symtab_filter with sensible populated defaults +symtab_filter +symtab::make_filter() const +{ + symtab_filter filter; + filter.set_public_symbols(); + if (is_kernel_binary_) + filter.set_kernel_symbols(); + return filter; +} + +/// Get a vector of symbols that are associated with a certain name +/// +/// @param name the name the symbols need to match +/// +/// @return a vector of symbols, empty if no matching symbols have been found +const elf_symbols& +symtab::lookup_symbol(const std::string& name) const +{ + static const elf_symbols empty_result; + const auto it = name_symbol_map_.find(name); + if (it != name_symbol_map_.end()) + return it->second; + return empty_result; +} + +/// Lookup a symbol by its address +/// +/// @param symbol_addr the starting address of the symbol +/// +/// @return a symbol if found, else an empty sptr +const elf_symbol_sptr& +symtab::lookup_symbol(GElf_Addr symbol_addr) const +{ + static const elf_symbol_sptr empty_result; + const auto it = addr_symbol_map_.find(symbol_addr); + if (it != addr_symbol_map_.end()) + return it->second; + return empty_result; +} + +/// A symbol sorting functor. +static struct +{ + bool + operator()(const elf_symbol_sptr& left, const elf_symbol_sptr& right) + { 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. +symtab_ptr +symtab::load(Elf* elf_handle, + ir::environment* env, + symbol_predicate is_suppressed) +{ + ABG_ASSERT(elf_handle); + ABG_ASSERT(env); + + symtab_ptr result(new symtab); + if (!result->load_(elf_handle, env, is_suppressed)) + return {}; + + return result; +} + +/// Construct a symtab object from existing name->symbol lookup maps. +/// They were possibly read from a different representation (XML maybe). +symtab_ptr +symtab::load(string_elf_symbols_map_sptr function_symbol_map, + string_elf_symbols_map_sptr variables_symbol_map) +{ + symtab_ptr result(new symtab); + if (!result->load_(function_symbol_map, variables_symbol_map)) + return {}; + + return result; +} + +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. +/// +/// This method iterates over the entries of .symtab and collects all +/// interesting symbols (functions and variables). +/// +/// In case of a Linux Kernel binary, it also collects information about the +/// symbols exported via EXPORT_SYMBOL in the Kernel that would then end up +/// having a corresponding __ksymtab entry. +/// +/// Symbols that are suppressed will be omitted from the symbols_ vector, but +/// still be discoverable through the name->symbol and addr->symbol lookup +/// maps. +bool +symtab::load_(Elf* elf_handle, + ir::environment* env, + symbol_predicate is_suppressed) +{ + + Elf_Scn* symtab_section = elf_helpers::find_symbol_table_section(elf_handle); + if (!symtab_section) + { + std::cerr << "No symbol table found: Skipping symtab load.\n"; + return false; + } + + GElf_Shdr symtab_sheader; + gelf_getshdr(symtab_section, &symtab_sheader); + + // check for bogus section header + if (symtab_sheader.sh_entsize == 0) + { + std::cerr << "Invalid symtab header found: Skipping symtab load.\n"; + return false; + } + + const size_t number_syms = + symtab_sheader.sh_size / symtab_sheader.sh_entsize; + + Elf_Data* symtab = elf_getdata(symtab_section, 0); + if (!symtab) + { + std::cerr << "Could not load elf symtab: Skipping symtab load.\n"; + return false; + } + + const bool is_kernel = elf_helpers::is_linux_kernel(elf_handle); + std::unordered_set exported_kernel_symbols; + + for (size_t i = 0; i < number_syms; ++i) + { + GElf_Sym *sym, sym_mem; + sym = gelf_getsym(symtab, i, &sym_mem); + if (!sym) + { + std::cerr << "Could not load symbol with index " << i + << ": Skipping symtab load.\n"; + return false; + } + + const char* const name_str = + elf_strptr(elf_handle, symtab_sheader.sh_link, sym->st_name); + + // no name, no game + if (!name_str) + continue; + + const std::string name = name_str; + if (name.empty()) + continue; + + // Handle ksymtab entries. Every symbol entry that starts with __ksymtab_ + // indicates that the symbol in question is exported through ksymtab. We + // do not know whether this is ksymtab_gpl or ksymtab, but that is good + // enough for now. + // + // We could follow up with this entry: + // + // symbol_value -> ksymtab_entry in either ksymtab_gpl or ksymtab + // -> addr/name/namespace (in case of PREL32: offset) + // + // That way we could also detect ksymtab<>ksymtab_gpl changes or changes + // of the symbol namespace. + // + // As of now this lookup is fragile, as occasionally ksymtabs are empty + // (seen so far for kernel modules and LTO builds). Hence we stick to the + // fairly safe assumption that ksymtab exported entries are having an + // appearence as __ksymtab_ in the symtab. + if (is_kernel && name.rfind("__ksymtab_", 0) == 0) + { + ABG_ASSERT(exported_kernel_symbols.insert(name.substr(10)).second); + continue; + } + + // filter out uninteresting entries and only keep functions/variables for + // now. The rest might be interesting in the future though. + const int sym_type = GELF_ST_TYPE(sym->st_info); + if (!(sym_type == STT_FUNC + || sym_type == STT_GNU_IFUNC + // If the symbol is for an OBJECT, the index of the + // section it refers to cannot be absolute. + // Otherwise that OBJECT is not a variable. + || (sym_type == STT_OBJECT && sym->st_shndx != SHN_ABS) + || sym_type == STT_TLS)) + continue; + + const bool sym_is_defined = sym->st_shndx != SHN_UNDEF; + // this occurs in relocatable files. + const bool sym_is_common = sym->st_shndx == SHN_COMMON; + + 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 + + // We do not take suppressed symbols into our symbol vector to avoid + // accidental leakage. But we ensure supressed symbols are otherwise set + // up for lookup. + if (!(is_suppressed && is_suppressed(symbol_sptr))) + // add to the symbol vector + symbols_.push_back(symbol_sptr); + else + symbol_sptr->set_is_suppressed(true); + + // add to the name->symbol lookup + name_symbol_map_[name].push_back(symbol_sptr); + + // add to the addr->symbol lookup + if (symbol_sptr->is_common_symbol()) + { + const auto it = name_symbol_map_.find(name); + ABG_ASSERT(it != name_symbol_map_.end()); + const elf_symbols& common_sym_instances = it->second; + ABG_ASSERT(!common_sym_instances.empty()); + if (common_sym_instances.size() > 1) + { + elf_symbol_sptr main_common_sym = common_sym_instances[0]; + ABG_ASSERT(main_common_sym->get_name() == name); + ABG_ASSERT(main_common_sym->is_common_symbol()); + ABG_ASSERT(symbol_sptr.get() != main_common_sym.get()); + main_common_sym->add_common_instance(symbol_sptr); + } + } + else if (symbol_sptr->is_defined()) + { + const GElf_Addr symbol_value = + elf_helpers::maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle, + sym); + + const auto result = + addr_symbol_map_.emplace(symbol_value, symbol_sptr); + if (!result.second) + result.first->second->get_main_symbol()->add_alias(symbol_sptr); + } + } + + is_kernel_binary_ = elf_helpers::is_linux_kernel(elf_handle); + + // Now apply the ksymtab_exported attribute to the symbols we collected. + for (const auto& symbol : exported_kernel_symbols) + { + const auto r = name_symbol_map_.find(symbol); + if (r == name_symbol_map_.end()) + continue; + + for (const auto& elf_symbol : r->second) + if (elf_symbol->is_public()) + elf_symbol->set_is_in_ksymtab(true); + has_ksymtab_entries_ = true; + } + + // sort the symbols for deterministic output + std::sort(symbols_.begin(), symbols_.end(), symbol_sort); + + return true; +} + +/// Load the symtab representation from a function/variable lookup map pair. +/// +/// 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. +bool +symtab::load_(string_elf_symbols_map_sptr function_symbol_map, + string_elf_symbols_map_sptr variables_symbol_map) + +{ + if (function_symbol_map) + for (const auto& symbol_map_entry : *function_symbol_map) + { + symbols_.insert(symbols_.end(), symbol_map_entry.second.begin(), + symbol_map_entry.second.end()); + ABG_ASSERT(name_symbol_map_.insert(symbol_map_entry).second); + } + + if (variables_symbol_map) + for (const auto& symbol_map_entry : *variables_symbol_map) + { + symbols_.insert(symbols_.end(), symbol_map_entry.second.begin(), + symbol_map_entry.second.end()); + ABG_ASSERT(name_symbol_map_.insert(symbol_map_entry).second); + } + + // sort the symbols for deterministic output + std::sort(symbols_.begin(), symbols_.end(), symbol_sort); + + return true; +} + } // end namespace symtab_reader } // end namespace abigail diff --git a/src/abg-symtab-reader.h b/src/abg-symtab-reader.h index a929166b83ef..4c5e3b85c22d 100644 --- a/src/abg-symtab-reader.h +++ b/src/abg-symtab-reader.h @@ -12,12 +12,287 @@ #ifndef __ABG_SYMTAB_READER_H__ #define __ABG_SYMTAB_READER_H__ +#include + +#include +#include +#include +#include +#include + +#include "abg-cxx-compat.h" // for abg_compat::optional +#include "abg-ir.h" + namespace abigail { - namespace symtab_reader { +/// The symtab filter is the object passed to the symtab object in order to +/// iterate over the symbols in the symtab while applying filters. +/// +/// The general idea is that it consists of a set of optionally enforced flags, +/// such as 'functions' or 'variables'. If not set, those are not filtered for, +/// neither inclusive nor exclusive. If set they are all ANDed together. +class symtab_filter +{ +public: + // Default constructor disabling all features. + symtab_filter() {} + + bool + matches(const elf_symbol& symbol) const; + + void + set_functions(bool new_value = true) + { functions_ = new_value; }; + + void + set_variables(bool new_value = true) + { variables_ = new_value; }; + + void + set_public_symbols(bool new_value = true) + { public_symbols_ = new_value; }; + + void + set_undefined_symbols(bool new_value = true) + { undefined_symbols_ = new_value; }; + + void + set_kernel_symbols(bool new_value = true) + { kernel_symbols_ = new_value; }; + +private: + // The symbol is a function (FUNC) + abg_compat::optional functions_; + + // The symbol is a variables (OBJECT) + abg_compat::optional variables_; + + // The symbol is publicly accessible (global/weak with default/protected + // visibility) + abg_compat::optional public_symbols_; + + // The symbols is not defined (declared) + abg_compat::optional undefined_symbols_; + + // The symbol is listed in the ksymtab (for Linux Kernel binaries). + abg_compat::optional kernel_symbols_; +}; + +/// Base iterator for our custom iterator based on whatever the const_iterator +/// is for a vector of symbols. +/// As of writing this, std::vector::const_iterator. +typedef elf_symbols::const_iterator base_iterator; + +/// An iterator to walk a vector of elf_symbols filtered by symtab_filter. +/// +/// The implementation inherits all properties from the vector's +/// const_iterator, but intercepts where necessary to allow effective +/// filtering. This makes it a STL compatible iterator for general purpose +/// usage. +class symtab_iterator : public base_iterator +{ +public: + typedef base_iterator::value_type value_type; + typedef base_iterator::reference reference; + typedef base_iterator::pointer pointer; + typedef base_iterator::difference_type difference_type; + typedef std::forward_iterator_tag iterator_category; + + /// 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). + symtab_iterator(base_iterator begin, + base_iterator end, + const symtab_filter& filter = symtab_filter()) + : base_iterator(begin), end_(end), filter_(filter) + { skip_to_next(); } + + /// Pre-increment operator to advance to the next matching element. + symtab_iterator& + operator++() + { + base_iterator::operator++(); + skip_to_next(); + return *this; + } + + /// Post-increment operator to advance to the next matching element. + symtab_iterator + operator++(int) + { + symtab_iterator result(*this); + ++(*this); + return result; + } + +private: + /// The end of the underlying iterator. + const base_iterator end_; + + /// The symtab_filter used to determine when to advance. + const symtab_filter& filter_; + + /// Skip to the next element that matches the filter criteria (if any). Hold + /// off when reaching the end of the underlying iterator. + void + skip_to_next() + { + while (*this != end_ && !filter_.matches(***this)) + ++(*this); + } +}; + +/// Convenience declaration of a unique_ptr +class symtab; +typedef std::unique_ptr symtab_ptr; + +/// symtab is the actual data container of the symtab_reader implementation. +/// +/// The symtab is instantiated either via an Elf handle (from binary) or from a +/// set of existing symbol maps (usually when instantiated from XML). It will +/// then discover the symtab, possibly the ksymtab (for Linux Kernel binaries) +/// and setup the data containers and lookup maps for later perusal. +/// +/// The symtab is supposed to be used in a const context as all information is +/// already computed at construction time. Symbols are stored sorted to allow +/// deterministic reading of the entries. +/// +/// An example use of the symtab class is +/// +/// const auto symtab = symtab::load(elf_handle, env); +/// symtab_filter filter = symtab->make_filter(); +/// filter.set_public_symbols(); +/// filter.set_functions(); +/// +/// for (const auto& symbol : filtered_symtab(*symtab, filter)) +/// { +/// std::cout << symbol->get_name() << "\n"; +/// } +/// +/// This uses the filtered_symtab proxy object to capture the filter. +class symtab +{ +public: + typedef std::function symbol_predicate; + + /// Indicate whether any (kernel) symbols have been seen at construction. + /// + /// @return true if there are symbols detected earlier. + bool + has_symbols() const + { return is_kernel_binary_ ? has_ksymtab_entries_ : !symbols_.empty(); } + + symtab_filter + make_filter() const; + + /// The (only) iterator type we offer is a const_iterator implemented by the + /// symtab_iterator. + typedef symtab_iterator const_iterator; + + /// Obtain an iterator to the beginning of the symtab according to the filter + /// criteria. Whenever this iterator advances, it skips elements that do not + /// match the filter criteria. + /// + /// @param filter the symtab_filter to match symbols against + /// + /// @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); } + + /// Obtain an iterator to the end of the symtab. + /// + /// @return an end iterator + const_iterator + end() const + { return symtab_iterator(symbols_.end(), symbols_.end()); } + + const elf_symbols& + lookup_symbol(const std::string& name) const; + + const elf_symbol_sptr& + lookup_symbol(GElf_Addr symbol_addr) const; + + static symtab_ptr + load(Elf* elf_handle, + ir::environment* env, + symbol_predicate is_suppressed = NULL); + + static symtab_ptr + load(string_elf_symbols_map_sptr function_symbol_map, + string_elf_symbols_map_sptr variables_symbol_map); + +private: + /// Default constructor. Private to enforce creation by factory methods. + symtab(); + + /// The vector of symbols we discovered. + elf_symbols symbols_; + + /// Whether this is a Linux Kernel binary + bool is_kernel_binary_; + + /// Whether this kernel_binary has ksymtab entries + /// + /// A kernel module might not have a ksymtab if it does not export any + /// symbols. In order to quickly decide whether the symbol table is empty, we + /// remember whether we ever saw ksymtab entries. + bool has_ksymtab_entries_; + + /// Lookup map name->symbol(s) + typedef std::unordered_map> + name_symbol_map_type; + name_symbol_map_type name_symbol_map_; + + /// Lookup map addr->symbol + typedef std::unordered_map addr_symbol_map_type; + addr_symbol_map_type addr_symbol_map_; + + bool + load_(Elf* elf_handle, ir::environment* env, symbol_predicate is_suppressed); + + bool + load_(string_elf_symbols_map_sptr function_symbol_map, + string_elf_symbols_map_sptr variables_symbol_map); +}; + +/// Helper class to allow range-for loops on symtabs for C++11 and later code. +/// It serves as a proxy for the symtab iterator and provides a begin() method +/// without arguments, as required for range-for loops (and possibly other +/// iterator based transformations). +/// +/// Example usage: +/// +/// for (const auto& symbol : filtered_symtab(tab, filter)) +/// { +/// std::cout << symbol->get_name() << "\n"; +/// } +/// +class filtered_symtab +{ + const symtab& tab_; + const symtab_filter filter_; + +public: + /// 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) { } + + /// Pass through symtab.begin(), but also pass on the filter. + symtab::const_iterator + begin() const + { return tab_.begin(filter_); } + + /// Pass through symtab.end(). + symtab::const_iterator + end() const + { return tab_.end(); } +}; + } // end namespace symtab_reader } // end namespace abigail From patchwork Wed Jan 27 12:58:39 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: 41840 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 9574B3971C3C; Wed, 27 Jan 2021 12:59:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9574B3971C3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752363; bh=B2FhkSnMPJ+1kl3QChFfkbmSY9GBeOA9IlGL5skJ+kU=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=WYSlps0WNU54Rm+RefQJY8ybf6GLMbxMAu9kWe8ggJ4M4t8hp44lDmtZySoHuNdju 866nEc6fope0PbH+BAUVGtvXriEc/wKZOh9fBUzv1htPDPXUlWLWr36/P71o0zOHoi GcLuP/q7srBWZ7slD+B38UxBIG6gvkA5rpvdLgUA= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by sourceware.org (Postfix) with ESMTPS id 4F3FD3971C3C for ; Wed, 27 Jan 2021 12:59:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 4F3FD3971C3C Received: by mail-qv1-xf4a.google.com with SMTP id l3so1229144qvz.12 for ; Wed, 27 Jan 2021 04:59:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=B2FhkSnMPJ+1kl3QChFfkbmSY9GBeOA9IlGL5skJ+kU=; b=LC3FV5GChbjfq6H26mZfy4hZDAo3fWIxJG8rd1PkTylNNB94LQRramicK2s98LT80G +eFJD0vHti7RVLU3Rn+fBZq3MhVNvFwLwSY+Tk0ATP97rWScR+pCAqA47T/cCecBnGZX l7jG9jjWLdGP1REaHK7JoOsPn40fEgjSHbzXmTfXutfIgwtKmnFZpX9tOAsDPV5qDbEw pWx3OzRloUpU4OKY9v8DjsF5vhjN+LdNTHv+DbpJ0cya2n0Yc5tZYMH5HBpl67tGy3wC M3ZHA+rJgqZcZ7UPGIggFCBMlodyKNwje/GbgDZvO4oQFY6NSL7eb1QgNEsudh4rJBmq d+cg== X-Gm-Message-State: AOAM532NwW2iHM408/VsLx9oKk14NKH5FNSa/94Qpn+H+dv9zhNe13K9 m6GMkwtuUxEQ6TwjnhWX9NAdvlS1/O2VIomKfEncpqxCpoqNymc1r/OCGaF2eNComae+AIUd1It OTfMQevHNrGa4SiP+ttiLvJKT5RVYAFOoEsCK+ZL3I+WXKhb9EHpL16jVoISiXve4kXtccLg= X-Google-Smtp-Source: ABdhPJw7RGdH3l23IHOvUjmYAQ1w7oMBAFPBdWT8D3k9nyUS1tenisv4wJm7Hgiggr/Urgd3VjjUCN6d5V5EJw== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a05:6214:48f:: with SMTP id ay15mr10114427qvb.58.1611752359787; Wed, 27 Jan 2021 04:59:19 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:39 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-7-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 06/20] Integrate new symtab reader into corpus and read_context To: libabigail@sourceware.org X-Spam-Status: No, score=-22.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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" While reading the corpus in the read_context, also load the new type symtab object side-by-side and set it accordingly in the resulting corpus. This is still side by side and passive code that gets active in the following changes. This is applicable for the dwarf reader as well as for the reader that consumes XML. * include/abg-corpus.h (corpus::set_symtab): New method declaration. (corpus::get_symtab): New method declaration. * include/abg-fwd.h (symtab_reader::symtab_sptr): New forward declaration. * src/abg-corpus-priv.h (corpus::priv::symtab_): New data member. * src/abg-corpus.cc (corpus::set_symtab): Likewise. (corpus::get_symtab): Likewise. * src/abg-dwarf-reader.cc (read_context::symtab_): New data member. (read_context::initialize): reset symtab_ as well (read_context::symtab): new method that loads a symtab on first access and returns it. (read_debug_info_into_corpus): also set the new symtab object on the current corpus. (read_corpus_from_elf): Also determine (i.e. load) the new symtab object and contribute to the load status. * src/abg-reader.cc (read_corpus_from_input): also set the new type symtab when reading from xml. * tests/test-symtab.cc: Add test assertions. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-corpus.h | 6 +++++ include/abg-fwd.h | 8 ++++++ src/abg-corpus-priv.h | 2 ++ src/abg-corpus.cc | 9 +++++++ src/abg-dwarf-reader.cc | 25 ++++++++++++++++++ src/abg-reader.cc | 3 +++ tests/data/test-symtab/basic/no_debug_info.c | 2 +- tests/data/test-symtab/basic/no_debug_info.so | Bin 15360 -> 15544 bytes tests/test-symtab.cc | 15 ++++------- 9 files changed, 59 insertions(+), 11 deletions(-) diff --git a/include/abg-corpus.h b/include/abg-corpus.h index e60b5013473b..425702182056 100644 --- a/include/abg-corpus.h +++ b/include/abg-corpus.h @@ -152,6 +152,12 @@ public: bool operator==(const corpus&) const; + void + set_symtab(symtab_reader::symtab_sptr); + + const symtab_reader::symtab_sptr& + get_symtab() const; + void set_fun_symbol_map(string_elf_symbols_map_sptr); diff --git a/include/abg-fwd.h b/include/abg-fwd.h index bb839fe76315..76df1b51dae7 100644 --- a/include/abg-fwd.h +++ b/include/abg-fwd.h @@ -1375,6 +1375,14 @@ typedef vector suppressions_type; } // end namespace suppr +namespace symtab_reader +{ + +class symtab; +typedef std::shared_ptr symtab_sptr; + +} // end namespace symtab_reader + void dump(const decl_base_sptr, std::ostream&); diff --git a/src/abg-corpus-priv.h b/src/abg-corpus-priv.h index a4a97adfd00a..290e19c60e67 100644 --- a/src/abg-corpus-priv.h +++ b/src/abg-corpus-priv.h @@ -17,6 +17,7 @@ #include "abg-internal.h" #include "abg-regex.h" #include "abg-sptr-utils.h" +#include "abg-symtab-reader.h" namespace abigail { @@ -684,6 +685,7 @@ struct corpus::priv string_elf_symbols_map_sptr undefined_var_symbol_map; elf_symbols sorted_var_symbols; elf_symbols sorted_undefined_var_symbols; + symtab_reader::symtab_sptr symtab_; string_elf_symbols_map_sptr fun_symbol_map; string_elf_symbols_map_sptr undefined_fun_symbol_map; elf_symbols sorted_fun_symbols; diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 2c37e253cf88..0d5849ddac5d 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -23,6 +23,7 @@ ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-ir.h" #include "abg-reader.h" #include "abg-sptr-utils.h" +#include "abg-symtab-reader.h" #include "abg-tools-utils.h" #include "abg-writer.h" @@ -850,6 +851,14 @@ corpus::operator==(const corpus& other) const && j == other.get_translation_units().end()); } +void +corpus::set_symtab(symtab_reader::symtab_sptr symtab) +{priv_->symtab_ = symtab;} + +const symtab_reader::symtab_sptr& +corpus::get_symtab() const +{ return priv_->symtab_; } + /// Setter of the function symbols map. /// /// @param map a shared pointer to the new function symbols map. diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 4b39e966e385..9f533e64959c 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -44,6 +44,7 @@ ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-dwarf-reader.h" #include "abg-sptr-utils.h" +#include "abg-symtab-reader.h" #include "abg-tools-utils.h" ABG_END_EXPORT_DECLARATIONS @@ -2259,6 +2260,9 @@ public: bool drop_undefined_syms_; read_context(); +private: + mutable symtab_reader::symtab_sptr symtab_; + public: /// Constructor of read_context. @@ -2408,6 +2412,8 @@ public: dt_soname_.clear(); elf_architecture_.clear(); + symtab_.reset(); + clear_per_translation_unit_data(); memset(&offline_callbacks_, 0, sizeof(offline_callbacks_)); @@ -5870,6 +5876,21 @@ public: return symbol; } + 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); + }); + + if (!symtab_) + std::cerr << "Symbol table of '" << elf_path_ + << "' could not be loaded\n"; + return symtab_; + } + /// Getter for a pointer to the map that associates the address of /// an entry point of a function with the symbol of that function. /// @@ -16012,6 +16033,7 @@ read_debug_info_into_corpus(read_context& ctxt) group->add_corpus(ctxt.current_corpus()); // Set symbols information to the corpus. + ctxt.current_corpus()->set_symtab(ctxt.symtab()); if (!get_ignore_symbol_table(ctxt)) { if (ctxt.load_in_linux_kernel_mode() @@ -17345,6 +17367,9 @@ read_corpus_from_elf(read_context& ctxt, status& status) status |= STATUS_NO_SYMBOLS_FOUND; } + if (!ctxt.symtab() || !ctxt.symtab()->has_symbols()) + status |= STATUS_NO_SYMBOLS_FOUND; + if (// If no elf symbol was found ... status & STATUS_NO_SYMBOLS_FOUND // ... or if debug info was found but not the required alternate diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 1fb0cf7d1074..68b19cf4b65b 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -33,6 +33,7 @@ ABG_BEGIN_EXPORT_DECLARATIONS #include "abg-libxml-utils.h" #include "abg-reader.h" #include "abg-corpus.h" +#include "abg-symtab-reader.h" #ifdef WITH_ZIP_ARCHIVE #include "abg-libzip-utils.h" @@ -1907,6 +1908,8 @@ 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 // fine. + corp.set_symtab(symtab_reader::symtab::load(fn_sym_db, var_sym_db)); + if (fn_sym_db) { corp.set_fun_symbol_map(fn_sym_db); diff --git a/tests/data/test-symtab/basic/no_debug_info.c b/tests/data/test-symtab/basic/no_debug_info.c index 5bb380ba0db8..8ac09016eb4d 100644 --- a/tests/data/test-symtab/basic/no_debug_info.c +++ b/tests/data/test-symtab/basic/no_debug_info.c @@ -1 +1 @@ -// empty! +void exported_function(){} diff --git a/tests/data/test-symtab/basic/no_debug_info.so b/tests/data/test-symtab/basic/no_debug_info.so index 827c1eee3e4e8f326af7e360ea444627ee59bee6..0b2310196a2a3a67369f80eb29e9ecefc22dc704 100755 GIT binary patch delta 1147 zcmZWoOH31C5T3tV9tB!<%cHzPw**bm(Cq`-Vl{1*M`I!w5)LMqVl09tfFOpVCM?DW zhJ&qhFdTd|AsW4SASPgpk#I5|(39dxV>oy)f(G?Kg0tN&N}SF7-_HE=`e*)Mj?a%L z?3Q^iY*PsQV1N*mfh8HV<=OS>j$NNT<1l0~Rmw`HB*SdRXEwQVUGVEvX&Z5vSu2jN zj>ggf#Ek7W;t0FD|IOD}WzFr0h4_JvUAv{Vajf89D27U`EMg^FHZg!mpGu0p>x*?7 zQ>+SmbUi{BDa=&z2Co|A;DWAO=#8Hp8X4`4MNgd{JUM!LXmGBSyIgRK-^l5T+*nN< zUz+>P>kB7XB^RhAKaN;j+u8~dItlv;Hwa}yg^E=GcA*nkoM)8t`c1_;F{ZxA$L0~!keTv z;X}8?jQGyo#udPQN>k4YvBP62H-i}38TK`a49qy;sc!+ur$O%AUnfxqd9azeAlmLP z`e7gdgfxwcMqKw;=yK6o?xh*;xLg_2NZKZbwuYZVw5`1>+7gMjc7~6%L?g|eSkl<~ z{{_TlT{XrVujr%wu@U^{PjQjfXUGCkqd)!B0ZJ*19R~t?4RV7T@f@ZCKEsbjRa&A- Gt$zTQCEAJr delta 769 zcmYjPO=uHA6rPt&tQ(Uy+mLRmfhLHOs?Gl7XR~cF5sGcW9~6V+lp+dMywrnjJTz(j zJKFexS`cbZA_yKrK~Igh9PLT;pqCy6Jy>W((An&6>0{=7^SycV-kUe`zFJ>cNy^0> z+mj;8vxBV2WH!(!B>Zi`-f0VsTPcyqX4GgZqSra&ZG3qwF^|Js#2gKwL-oYf&gaYe z@1AET?rp9f>8ssbT)rK#e63L3iG)|dE6)s~LWx*wQCJQ@_0B#GZCklpe?#8BR$O|} zi+U{5rZ6W#aPL=UZy~ay8qbXEJQ;Sd#Ynm+dvK7u`e9{Jl5RXE7 zge3gqJN+!qnG99GJIL2XyB?>D>@26mg4oa%3gD+cDIDUb=d>`+r4JACsHdI!9oXpl zOQ@w~9{+iIWW>Y#Y=@`ZFI!zNZY=J%GWG{ek4z#G8JUiDb-~i8XTIZ3cA}>;edT=R z`VBO*5o~22Vm`No?Oa&gds;|_A-S!0F^00CNN&SjT)--~y3gWb37Q_p4 X-Patchwork-Id: 41841 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 DD1A73973009; Wed, 27 Jan 2021 12:59:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DD1A73973009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752365; bh=2oMhQD0te+7uH1CsgcygqjHyzCdfmH05pkiKfvpM408=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZOtH1viueCXW/dS3vSN8lZOqbKGmRDsbMV9p2kK03mE/YVjS7xM+gybNKB+kyIhDw 1NXFWY3aYRvtdgova266vQbX/qb9WWKUs5BWJ0K64VkyX2ErmFdEpuJfYslCo+F6UK 4ndeshY7ToRgAPIwMurxdjKGFpZGr3HfOuSs02VU= 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 7A67F3973009 for ; Wed, 27 Jan 2021 12:59:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7A67F3973009 Received: by mail-qt1-x849.google.com with SMTP id d26so1026675qtr.0 for ; Wed, 27 Jan 2021 04:59:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=2oMhQD0te+7uH1CsgcygqjHyzCdfmH05pkiKfvpM408=; b=APQUJ4fyUBe99putKKT1q1bu5BfAIRfHMHRuJXKen/csUVnbFFXxVBTMVLOUM9+d39 i+GU3oJugQMosbQXZZeP4NchQxwBG9a5zuNyufEjGTa0kLwxW8OG1UDEaNYs0w1gp2Cy PN49TzYoSf7FMsvhaXX71iNcLl5ILe1COsphSOTUUY6oHC6+hE4p5cf766xT/zL2jQ7r zzydgkEdLb+uAMLp5ISYGL57iijkMV1H109v61Mf/R8aMrID6keFmWszAjtqUnS1Gbp3 mWzEl6hsvCl4dK6UxEWll4lxUF3UGGozn57CeImT6UXTVUUQyOqMmqcNSbt2Fw1n3X5B gZMA== X-Gm-Message-State: AOAM5314uy+v3D3/TCbD8Kiqw321dWe9yMx2E7SAGASE1tx/TdJ1HGkK hzp/Z7dsKp/Xy1HvoX3KiExaw5GqyY8q64A3eF0c0V6Lh68jzzHsKxPQdBvzMYnPiBrIvgvKU5e 2qc13mPmOOx4uYYzdVcO0gKR/C05bYNffJCCmBwmpaE6xkEpQIYVdnllK0J60FqlLXE19tb8= X-Google-Smtp-Source: ABdhPJwOH07mJoJteeUQ0suIQkCRCiOyji8G3JViv+gFO6tvHxNdBn921v5S+O9/sSPCJoic80vLhn6xe/cBnQ== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:ad4:4f83:: with SMTP id em3mr8736152qvb.28.1611752361986; Wed, 27 Jan 2021 04:59:21 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:40 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-8-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 07/20] corpus: make get_(undefined_)?_(var|fun)_symbols use the new symtab To: libabigail@sourceware.org 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, 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Make the corresponding members an implementation detail of corpus::priv. They get computed based on the new symtab whenever they are accessed first with an atomic instantiation. That simplifies the implementation and homogenizes the access to functions and variables. Sorting does not need to be done as the symtab already gives a guarantee for that. Due to improved alias detection in the new symtab reader, ensure we only write symbol aliases to ksymtab symbols if having a ksymtab main symbol. Test data needed to be adjusted as the new symtab reader is stricter in regards to symbols listed in ksymtab. I.e. init_module is not an exported symbol in the ksymtab of a kernel module. * src/abg-corpus-priv.h (corpus::priv::sorted_var_symbols): make private, mutable and optional. (corpus::sorted_undefined_var_symbols): Likewise. (corpus::sorted_fun_symbols): Likewise. (corpus::sorted_undefined_fun_symbols): Likewise. (corpus::priv::get_sorted_fun_symbols): New method declaration. (corpus::priv::get_sorted_undefined_fun_symbols): Likewise. (corpus::priv::get_sorted_var_symbols): Likewise. (corpus::priv::get_sorted_undefined_var_symbols): Likewise. * src/abg-corpus.cc (corpus::elf_symbol_comp_functor): Delete struct. (corpus::priv::get_sorted_fun_symbols): New method implementation. (corpus::priv::get_sorted_undefined_fun_symbols): Likewise. (corpus::priv::get_sorted_var_symbols): Likewise. (corpus::priv::get_sorted_undefined_var_symbols): Likewise. (corpus::get_sorted_fun_symbols): Proxy call to corpus::priv. (corpus::get_sorted_undefined_fun_symbols): Likewise. (corpus::get_sorted_var_symbols): Likewise. (corpus::get_sorted_undefined_var_symbols): Likewise. * src/abg-writer.cc (write_elf_symbol_aliases): When emitting aliases for a kernel symbol, ensure to only emit exported, public aliases. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: update test data. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-corpus-priv.h | 21 +- src/abg-corpus.cc | 241 +++++++----------- src/abg-writer.cc | 39 ++- .../data/test-read-dwarf/PR25007-sdhci.ko.abi | 3 - 4 files changed, 135 insertions(+), 169 deletions(-) diff --git a/src/abg-corpus-priv.h b/src/abg-corpus-priv.h index 290e19c60e67..282796e1b685 100644 --- a/src/abg-corpus-priv.h +++ b/src/abg-corpus-priv.h @@ -683,13 +683,9 @@ struct corpus::priv vector vars; string_elf_symbols_map_sptr var_symbol_map; string_elf_symbols_map_sptr undefined_var_symbol_map; - elf_symbols sorted_var_symbols; - elf_symbols sorted_undefined_var_symbols; symtab_reader::symtab_sptr symtab_; string_elf_symbols_map_sptr fun_symbol_map; string_elf_symbols_map_sptr undefined_fun_symbol_map; - elf_symbols sorted_fun_symbols; - elf_symbols sorted_undefined_fun_symbols; elf_symbols unrefed_fun_symbols; elf_symbols unrefed_var_symbols; // The type maps contained in this data member are populated if the @@ -711,6 +707,11 @@ struct corpus::priv private: priv(); + mutable abg_compat::optional sorted_var_symbols; + mutable abg_compat::optional sorted_undefined_var_symbols; + mutable abg_compat::optional sorted_fun_symbols; + mutable abg_compat::optional sorted_undefined_fun_symbols; + public: priv(const string & p, environment* e) @@ -730,6 +731,18 @@ public: const type_maps& get_types() const; + const elf_symbols& + get_sorted_fun_symbols() const; + + const elf_symbols& + get_sorted_undefined_fun_symbols() const; + + const elf_symbols& + get_sorted_var_symbols() const; + + const elf_symbols& + get_sorted_undefined_var_symbols() const; + unordered_set* get_public_types_pretty_representations(); diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 0d5849ddac5d..75f897eb72a8 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -438,6 +438,87 @@ const type_maps& corpus::priv::get_types() const {return types_;} +/// 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. +const elf_symbols& +corpus::priv::get_sorted_fun_symbols() const +{ + if (!sorted_fun_symbols) + { + auto filter = symtab_->make_filter(); + filter.set_functions(); + sorted_fun_symbols = elf_symbols(symtab_->begin(filter), symtab_->end()); + } + return *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. +const elf_symbols& +corpus::priv::get_sorted_undefined_fun_symbols() const +{ + if (!sorted_undefined_fun_symbols) + { + auto filter = symtab_->make_filter(); + filter.set_functions(); + filter.set_undefined_symbols(); + filter.set_public_symbols(false); + + sorted_undefined_fun_symbols = + elf_symbols(symtab_->begin(filter), symtab_->end()); + } + return *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::priv::get_sorted_var_symbols() const +{ + if (!sorted_var_symbols) + { + auto filter = symtab_->make_filter(); + filter.set_variables(); + + sorted_var_symbols = elf_symbols(symtab_->begin(filter), symtab_->end()); + } + return *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::priv::get_sorted_undefined_var_symbols() const +{ + if (!sorted_undefined_var_symbols) + { + auto filter = symtab_->make_filter(); + filter.set_variables(); + filter.set_undefined_symbols(); + filter.set_public_symbols(false); + + sorted_undefined_var_symbols = + elf_symbols(symtab_->begin(filter), symtab_->end()); + } + return *sorted_undefined_var_symbols; +} + /// Getter of the set of pretty representation of types that are /// reachable from public interfaces (global functions and variables). /// @@ -933,104 +1014,21 @@ const string_elf_symbols_map_type& corpus::get_undefined_fun_symbol_map() const {return *get_undefined_fun_symbol_map_sptr();} -/// Functor to sort instances of @ref elf_symbol. -struct elf_symbol_comp_functor -{ - - /// Return true if the first argument is less than the second one. - /// - /// @param l the first parameter to consider. - /// - /// @param r the second parameter to consider. - /// - /// @return true if @p l is less than @p r - bool - operator()(elf_symbol& l, elf_symbol& r) - {return (l.get_id_string() < r.get_id_string());} - - /// Return true if the first argument is less than the second one. - /// - /// @param l the first parameter to consider. - /// - /// @param r the second parameter to consider. - /// - /// @return true if @p l is less than @p r - bool - operator()(elf_symbol* l, elf_symbol* r) - {return operator()(*l, *r);} - - /// Return true if the first argument is less than the second one. - /// - /// @param l the first parameter to consider. - /// - /// @param r the second parameter to consider. - /// - /// @return true if @p l is less than @p r - bool - operator()(elf_symbol_sptr l, elf_symbol_sptr r) - {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. const elf_symbols& corpus::get_sorted_fun_symbols() const -{ - if (priv_->sorted_fun_symbols.empty() - && !get_fun_symbol_map().empty()) - { - priv_->sorted_fun_symbols.reserve(get_fun_symbol_map().size()); - for (string_elf_symbols_map_type::const_iterator i = - get_fun_symbol_map().begin(); - i != get_fun_symbol_map().end(); - ++i) - for (elf_symbols::const_iterator s = i->second.begin(); - 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(), - comp); - } - 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. const elf_symbols& corpus::get_sorted_undefined_fun_symbols() const -{ - if (priv_->sorted_undefined_fun_symbols.empty() - && !get_undefined_fun_symbol_map().empty()) - { - priv_->sorted_undefined_fun_symbols.reserve - (get_undefined_fun_symbol_map().size()); - for (string_elf_symbols_map_type::const_iterator i = - get_undefined_fun_symbol_map().begin(); - i != get_undefined_fun_symbol_map().end(); - ++i) - for (elf_symbols::const_iterator s = i->second.begin(); - s != i->second.end(); - ++s) - priv_->sorted_undefined_fun_symbols.push_back(*s); +{ return priv_->get_sorted_undefined_fun_symbols(); } - elf_symbol_comp_functor comp; - std::sort(priv_->sorted_undefined_fun_symbols.begin(), - priv_->sorted_undefined_fun_symbols.end(), - comp); - } - return priv_->sorted_undefined_fun_symbols; -} +const elf_symbols& +corpus::get_sorted_var_symbols() const +{ return priv_->get_sorted_var_symbols(); } + +const elf_symbols& +corpus::get_sorted_undefined_var_symbols() const +{ return priv_->get_sorted_undefined_var_symbols(); } /// Getter for the variable symbols map. /// @@ -1070,65 +1068,6 @@ const string_elf_symbols_map_type& corpus::get_undefined_var_symbol_map() const {return *get_undefined_var_symbol_map_sptr();} -/// 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 -{ - if (priv_->sorted_var_symbols.empty() - && !get_var_symbol_map().empty()) - { - priv_->sorted_var_symbols.reserve(get_var_symbol_map().size()); - for (string_elf_symbols_map_type::const_iterator i = - get_var_symbol_map().begin(); - i != get_var_symbol_map().end(); - ++i) - for (elf_symbols::const_iterator s = i->second.begin(); - s != i->second.end(); ++s) - priv_->sorted_var_symbols.push_back(*s); - - elf_symbol_comp_functor comp; - std::sort(priv_->sorted_var_symbols.begin(), - priv_->sorted_var_symbols.end(), - comp); - } - return priv_->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 -{ - if (priv_->sorted_undefined_var_symbols.empty() - && !get_undefined_var_symbol_map().empty()) - { - priv_->sorted_undefined_var_symbols.reserve - (get_undefined_var_symbol_map().size()); - for (string_elf_symbols_map_type::const_iterator i = - get_undefined_var_symbol_map().begin(); - i != get_undefined_var_symbol_map().end(); - ++i) - for (elf_symbols::const_iterator s = i->second.begin(); - s != i->second.end(); ++s) - priv_->sorted_undefined_var_symbols.push_back(*s); - - elf_symbol_comp_functor comp; - std::sort(priv_->sorted_undefined_var_symbols.begin(), - priv_->sorted_undefined_var_symbols.end(), - comp); - } - return priv_->sorted_undefined_var_symbols; -} - /// Look in the function symbols map for a symbol with a given name. /// /// @param n the name of the symbol to look for. diff --git a/src/abg-writer.cc b/src/abg-writer.cc index d55bbbc166d5..d4d5e5531894 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -1678,26 +1678,43 @@ write_elf_symbol_visibility(elf_symbol::visibility v, ostream& o) /// /// @return true upon successful completion. static bool -write_elf_symbol_aliases(const elf_symbol& sym, ostream& o) +write_elf_symbol_aliases(const elf_symbol& sym, ostream& out) { if (!sym.is_main_symbol() || !sym.has_aliases()) return false; - bool emitted = false; - o << " alias='"; - for (elf_symbol_sptr s = sym.get_next_alias(); - !s->is_main_symbol(); + + std::vector aliases; + for (elf_symbol_sptr s = sym.get_next_alias(); s && !s->is_main_symbol(); s = s->get_next_alias()) { - if (s->get_next_alias()->is_main_symbol()) - o << s->get_id_string() << "'"; - else - o << s->get_id_string() << ","; + if (!s->is_public()) + continue; + + if (s->is_suppressed()) + continue; + + if (sym.is_in_ksymtab() != s->is_in_ksymtab()) + continue; - emitted = true; + aliases.push_back(s->get_id_string()); } - return emitted; + if (!aliases.empty()) + { + out << " alias='"; + std::string separator; + for (const auto& alias : aliases) + { + out << separator << alias; + separator = ","; + } + + out << "'"; + return true; + } + + return false; } /// Write an XML attribute for the reference to a symbol for the diff --git a/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi b/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi index 44e2e608260b..1167e5aa478a 100644 --- a/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi +++ b/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi @@ -2,8 +2,6 @@ - - @@ -40,7 +38,6 @@ - From patchwork Wed Jan 27 12:58:41 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: 41842 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 657A93972827; Wed, 27 Jan 2021 12:59:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 657A93972827 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752368; bh=+ZIL8dWUEp5kHmdoNk0aU93X4+lYLVS0zLjYZyqKjNM=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=K2njGbElmmahQapZZS/UKH0jKceFD8ZQTqhNajC3PnF3bCE2Y4LzzABzoh/Y0IlhL XjjLkM2Wt33X5yTWe7WG2yqH2Z4PwfXwYuWxCgnjqpbSU1h9F8J8JEAkUjk/JYOWxq rvgcj4s7r9+HAB/LO2keZMjgxECYQwruhcog3zps= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wr1-x44a.google.com (mail-wr1-x44a.google.com [IPv6:2a00:1450:4864:20::44a]) by sourceware.org (Postfix) with ESMTPS id 24ABA3971830 for ; Wed, 27 Jan 2021 12:59:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 24ABA3971830 Received: by mail-wr1-x44a.google.com with SMTP id s18so918665wrf.0 for ; Wed, 27 Jan 2021 04:59:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=+ZIL8dWUEp5kHmdoNk0aU93X4+lYLVS0zLjYZyqKjNM=; b=Tcr9G2d3n9r0rMgPdup7ZC2+Y+G/s+nrfjTKSAwjK2+3WawCltTcrSiTqRSodLsgzJ DFrbmmc/UlwNlUHtqryiL+urG2EEcmV3Tf5SgMrRwCxzTn4T6JRGbh3diRxNB+zZzW63 0bZa+gGgDTNyXMMxEqy+VeaExeT3sGw1HgJEuWq5N6287elUrAerBBpRHGd2kLn2bHnD NZk8qsXeqIB/f7eCRJXHZYlI9SD+BQiKrHtOlY8YHTwOFYHTwKLZ/YK95RGIu/mEHjCq O3AyRdI73pvaDVEnL4rQwKwERNh3ld8tvDojFazwtJfCCrODn62/MwVjgRtpRdLWvyym yhlQ== X-Gm-Message-State: AOAM533+nzsJBWLkUuzTnagWZ5AURKveMLJW9CpgcpHOewQCudy7Stdk NBQr2rHLHcU04w+Gxh0ghZ9HLe2swtSq1h2YrwD3uRT7u/DSLfEv/NVmz/Adkz3e1/qbf8cvAGp OulJfrxAGFYDZzwWzGfw+Ah3Cm7QUHDAJ+8U9BxJ1hOqdn2H2XMfrW18X4b4EYpJrcYRYD3Y= X-Google-Smtp-Source: ABdhPJxpxIPCJkvICdrkYCQER2yTpidNlB2zIDRJTpgdFjuzgKhUjB730GlePDETb5FjNBDO5c1Ml0tlN9Q2/A== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a1c:bcd4:: with SMTP id m203mr4107455wmf.120.1611752364199; Wed, 27 Jan 2021 04:59:24 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:41 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-9-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 08/20] corpus: make get_unreferenced_(function|variable)_symbols use the new symtab To: libabigail@sourceware.org X-Spam-Status: No, score=-22.6 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Make the corresponding members an implementation detail of corpus::priv. They get computed based on the new symtab whenever they are accessed first with an atomic instantiation. That simplifies the implementation and homogenizes the access to functions and variables. Sorting does not need to be done as the symtab already gives a guarantee for that. * src/abg-corpus-priv.h (corpus::priv::unrefed_var_symbols): make private, mutable and optional. (corpus::unrefed_fun_symbols): Likewise. (corpus::priv::get_unreferenced_function_symbols): New method declaration. (corpus::priv::get_unreferenced_variable_symbols): Likewise. * src/abg-corpus.cc (corpus::priv::build_unreferenced_symbols_tables): Delete method. (corpus::priv::get_unreferenced_function_symbols): New method implementation. (corpus::priv::get_unreferenced_variable_symbols): Likewise. (corpus::get_unreferenced_function_symbols): Proxy call to corpus::priv. (corpus::get_unreferenced_variable_symbols): Likewise. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-corpus-priv.h | 13 ++- src/abg-corpus.cc | 246 +++++++++++++++++++----------------------- 2 files changed, 116 insertions(+), 143 deletions(-) diff --git a/src/abg-corpus-priv.h b/src/abg-corpus-priv.h index 282796e1b685..c8bf7f9d4cf6 100644 --- a/src/abg-corpus-priv.h +++ b/src/abg-corpus-priv.h @@ -686,8 +686,6 @@ struct corpus::priv symtab_reader::symtab_sptr symtab_; string_elf_symbols_map_sptr fun_symbol_map; string_elf_symbols_map_sptr undefined_fun_symbol_map; - elf_symbols unrefed_fun_symbols; - elf_symbols unrefed_var_symbols; // The type maps contained in this data member are populated if the // corpus follows the One Definition Rule and thus if there is only // one copy of a type with a given name, per corpus. Otherwise, if @@ -709,8 +707,10 @@ private: mutable abg_compat::optional sorted_var_symbols; mutable abg_compat::optional sorted_undefined_var_symbols; + mutable abg_compat::optional unrefed_var_symbols; mutable abg_compat::optional sorted_fun_symbols; mutable abg_compat::optional sorted_undefined_fun_symbols; + mutable abg_compat::optional unrefed_fun_symbols; public: priv(const string & p, @@ -722,9 +722,6 @@ public: pub_type_pretty_reprs_() {} - void - build_unreferenced_symbols_tables(); - type_maps& get_types(); @@ -737,12 +734,18 @@ public: const elf_symbols& get_sorted_undefined_fun_symbols() const; + const elf_symbols& + get_unreferenced_function_symbols() const; + const elf_symbols& get_sorted_var_symbols() const; const elf_symbols& get_sorted_undefined_var_symbols() const; + const elf_symbols& + get_unreferenced_variable_symbols() const; + unordered_set* get_public_types_pretty_representations(); diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index 75f897eb72a8..f9f51a360707 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -302,132 +302,6 @@ struct comp_elf_symbols_functor // - -/// Build the tables of symbols that are not referenced by any -/// function or variables of corpus::get_functions() or -/// corpus::get_variables(). -/// -/// Note that this function considers the list of function and -/// variable symbols to keep, that is provided by -/// corpus::get_sym_ids_of_fns_to_keep() and -/// corpus::get_sym_ids_of_vars_to_keep(). If a given unreferenced -/// function or variable symbol is not in the list of variable and -/// function symbols to keep, then that symbol is dropped and will not -/// be part of the resulting table of unreferenced symbol that is -/// built. -/// -/// The built tables are accessible from -/// corpus::get_unreferenced_function_symbols() and -/// corpus::get_unreferenced_variable_symbols(). -void -corpus::priv::build_unreferenced_symbols_tables() -{ - unordered_map refed_funs, refed_vars; - elf_symbol_sptr sym; - - for (vector::const_iterator f = fns.begin(); - f != fns.end(); - ++f) - if ((sym = (*f)->get_symbol())) - { - refed_funs[sym->get_id_string()] = true; - for (elf_symbol_sptr a = sym->get_next_alias(); - a && !a->is_main_symbol(); - a = a->get_next_alias()) - refed_funs[a->get_id_string()] = true; - } - - for (vector::const_iterator v = vars.begin(); - v != vars.end(); - ++v) - if ((sym = (*v)->get_symbol())) - { - refed_vars[sym->get_id_string()] = true; - for (elf_symbol_sptr a = sym->get_next_alias(); - a && !a->is_main_symbol(); - a = a->get_next_alias()) - refed_vars[a->get_id_string()] = true; - } - - if (fun_symbol_map) - { - // Let's assume that the size of the unreferenced symbols vector - // is roughly smaller than the size of the symbol table. - unrefed_fun_symbols.reserve(fun_symbol_map->size()); - for (string_elf_symbols_map_type::const_iterator i - = fun_symbol_map->begin(); - i != fun_symbol_map->end(); - ++i) - for (elf_symbols::const_iterator s = i->second.begin(); - s != i->second.end(); - ++s) - { - string sym_id = (*s)->get_id_string(); - if (refed_funs.find(sym_id) == refed_funs.end()) - { - bool keep = sym_id_fns_to_keep.empty(); - for (vector::const_iterator i = - sym_id_fns_to_keep.begin(); - i != sym_id_fns_to_keep.end(); - ++i) - { - if (*i == sym_id) - { - keep = true; - break; - } - } - if (keep) - unrefed_fun_symbols.push_back(*s); - } - } - - comp_elf_symbols_functor comp; - std::sort(unrefed_fun_symbols.begin(), - unrefed_fun_symbols.end(), - comp); - } - - if (var_symbol_map) - { - // Let's assume that the size of the unreferenced symbols vector - // is roughly smaller than the size of the symbol table. - unrefed_var_symbols.reserve(var_symbol_map->size()); - for (string_elf_symbols_map_type::const_iterator i - = var_symbol_map->begin(); - i != var_symbol_map->end(); - ++i) - for (elf_symbols::const_iterator s = i->second.begin(); - s != i->second.end(); - ++s) - { - string sym_id = (*s)->get_id_string(); - if (refed_vars.find(sym_id) == refed_vars.end()) - { - bool keep = sym_id_vars_to_keep.empty(); - for (vector::const_iterator i = - sym_id_vars_to_keep.begin(); - i != sym_id_vars_to_keep.end(); - ++i) - { - if (*i == sym_id) - { - keep = true; - break; - } - } - if (keep) - unrefed_var_symbols.push_back(*s); - } - } - - comp_elf_symbols_functor comp; - std::sort(unrefed_var_symbols.begin(), - unrefed_var_symbols.end(), - comp); - } -} - /// Get the maps that associate a name to a certain kind of type. type_maps& corpus::priv::get_types() @@ -478,6 +352,59 @@ corpus::priv::get_sorted_undefined_fun_symbols() const return *sorted_undefined_fun_symbols; } +/// Return a list of symbols that are not referenced by any function of +/// corpus::get_functions(). +/// +/// Note that this function considers the list of function symbols to keep, +/// that is provided by corpus::get_sym_ids_of_fns_to_keep(). If a given +/// 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. +const elf_symbols& +corpus::priv::get_unreferenced_function_symbols() const +{ + if (!unrefed_fun_symbols) + { + unrefed_fun_symbols = elf_symbols(); + if (symtab_) + { + unordered_map refed_funs; + + for (const auto& function : fns) + if (elf_symbol_sptr sym = function->get_symbol()) + { + refed_funs[sym->get_id_string()] = true; + for (elf_symbol_sptr a = sym->get_next_alias(); + a && !a->is_main_symbol(); a = a->get_next_alias()) + refed_funs[a->get_id_string()] = true; + } + + auto filter = symtab_->make_filter(); + filter.set_functions(); + for (const auto& symbol : + symtab_reader::filtered_symtab(*symtab_, filter)) + { + const std::string sym_id = symbol->get_id_string(); + if (refed_funs.find(sym_id) == refed_funs.end()) + { + bool keep = sym_id_fns_to_keep.empty(); + for (const auto& id : sym_id_fns_to_keep) + { + if (id == sym_id) + { + keep = true; + break; + } + } + if (keep) + unrefed_fun_symbols->push_back(symbol); + } + } + } + } + return *unrefed_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 @@ -519,6 +446,59 @@ corpus::priv::get_sorted_undefined_var_symbols() const return *sorted_undefined_var_symbols; } +/// Return a list of symbols that are not referenced by any variable of +/// corpus::get_variables(). +/// +/// Note that this function considers the list of variable symbols to keep, +/// that is provided by corpus::get_sym_ids_of_vars_to_keep(). If a given +/// 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. +const elf_symbols& +corpus::priv::get_unreferenced_variable_symbols() const +{ + if (!unrefed_var_symbols) + { + unrefed_var_symbols = elf_symbols(); + if (symtab_) + { + unordered_map refed_vars; + for (const auto& variable : vars) + if (elf_symbol_sptr sym = variable->get_symbol()) + { + refed_vars[sym->get_id_string()] = true; + for (elf_symbol_sptr a = sym->get_next_alias(); + a && !a->is_main_symbol(); a = a->get_next_alias()) + refed_vars[a->get_id_string()] = true; + } + + auto filter = symtab_->make_filter(); + filter.set_variables(); + for (const auto& symbol : + symtab_reader::filtered_symtab(*symtab_, filter)) + { + const std::string sym_id = symbol->get_id_string(); + if (refed_vars.find(sym_id) == refed_vars.end()) + { + bool keep = sym_id_vars_to_keep.empty(); + for (const auto& id : sym_id_vars_to_keep) + { + if (id == sym_id) + { + keep = true; + break; + } + } + if (keep) + unrefed_var_symbols->push_back(symbol); + } + } + } + } + return *unrefed_var_symbols; +} + + /// Getter of the set of pretty representation of types that are /// reachable from public interfaces (global functions and variables). /// @@ -1310,12 +1290,7 @@ corpus::sort_variables() /// function exported by the current corpus. const elf_symbols& corpus::get_unreferenced_function_symbols() const -{ - if (priv_->unrefed_fun_symbols.empty() - && priv_->unrefed_var_symbols.empty()) - priv_->build_unreferenced_symbols_tables(); - return priv_->unrefed_fun_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. @@ -1328,12 +1303,7 @@ corpus::get_unreferenced_function_symbols() const /// variable exported by the current corpus. const elf_symbols& corpus::get_unreferenced_variable_symbols() const -{ - if (priv_->unrefed_fun_symbols.empty() - && priv_->unrefed_var_symbols.empty()) - priv_->build_unreferenced_symbols_tables(); - return priv_->unrefed_var_symbols; -} +{ return priv_->get_unreferenced_variable_symbols(); } /// Accessor for the regex patterns describing the functions to drop /// from the public decl table. From patchwork Wed Jan 27 12:58:42 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: 41843 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 AD190397282F; Wed, 27 Jan 2021 12:59:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD190397282F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752369; bh=QqwzaSsGg5Abvk8XxC0XCm1qTnuYw619eIX6QL8dsLU=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=BTBs/Rje0pDW4JXdDFZZi2nT0YGkSteV50NeGB2jbj5dL7MtJCB5J+rO4Pge5+F/C exy9W+8/bCN5MGjnLFh678U11YttqliJPbS9KBSj+owQIEw+iFiLfOMsZUe0Y/F1wM 4aJBR3GfOs1tb/DkSDhncqQiArh99cqwozt4tPdQ= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-ej1-x649.google.com (mail-ej1-x649.google.com [IPv6:2a00:1450:4864:20::649]) by sourceware.org (Postfix) with ESMTPS id 8AA773971C3C for ; Wed, 27 Jan 2021 12:59:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8AA773971C3C Received: by mail-ej1-x649.google.com with SMTP id j14so607499eja.15 for ; Wed, 27 Jan 2021 04:59:27 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QqwzaSsGg5Abvk8XxC0XCm1qTnuYw619eIX6QL8dsLU=; b=mHai7/innNgIBGfIeaus25LCk2Zg5VFzmHopR0N6taoFEHnknzwdi+TI77demgb9uV ojQO+zx9Rxt6z55tClxlphJCb0A5/q30/GBwlDiTBQYBb3s8X56dU7QpZptuVqDrQWo7 AttkyddLgmJFbVYhjq+ZrzL9y4bFiMuKUL8vNlAaDRIsBi8d7qddhkh2rfOaki8rRixG V8bjRemrbyW/z2DYEYQVYeahKXh+zTg/unLHaBdFwFWTQqOCQK0/R0tcY+CziMDaE+6z F3xu+ataUp8pKlJ9HJa3Rv7rGEBeFIV/qU/O+1u9/rRvt9LCI57bWlAZA3ziKg731mMp H3Yw== X-Gm-Message-State: AOAM532d14A5IyOZcLVkbLQ7mUlh5yvcY430f6FkxUGxEDXqw0UmV/T2 MgOo0TUz76cK5/dd6KpNUValPiIAfslEhiKWZmvk1SNPgcwADBdfTX/kC/HlS61THHBms1yydmJ HrLRSk1Omx0liLLOic4Xgc3Dr3CXyDB41ZeVuIu0qXpjYJknEYS86eNViJxKzR8t7usvS5dk= X-Google-Smtp-Source: ABdhPJyNGVPUbB2ZExjGcjSfttk/rmUfCIr477MZPNCDP5sNLXcEldVBmsfleHpe702gN99ynhyYchC/O5t7Yw== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:aa7:c94a:: with SMTP id h10mr6824937edt.41.1611752366458; Wed, 27 Jan 2021 04:59:26 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:42 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-10-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 09/20] abg-reader: avoid using the (var|function)_symbol_map To: libabigail@sourceware.org X-Spam-Status: No, score=-21.7 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Instead of using the corpus var|function_symbol_maps for symbol lookups, let build_elf_symbol_from_reference use the symtab::lookup_symbol method. That leads to a shorter implementation and we can drop the indicative parameter. * src/abg-reader.cc (build_elf_symbol_from_reference): drop last parameter indicating the lookup type and use corpus symtab for the lookup (build_function_decl): Adjust accordingly. (build_var_decl): Likewise. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-reader.cc | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 68b19cf4b65b..c26689ae17ca 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -1084,8 +1084,7 @@ static elf_symbol_sptr build_elf_symbol(read_context&, const xmlNodePtr, bool); static elf_symbol_sptr -build_elf_symbol_from_reference(read_context&, const xmlNodePtr, - bool); +build_elf_symbol_from_reference(read_context&, const xmlNodePtr); static string_elf_symbols_map_sptr build_elf_symbol_db(read_context&, const xmlNodePtr, bool); @@ -2818,8 +2817,7 @@ build_elf_symbol(read_context& ctxt, const xmlNodePtr node, /// /// @return a shared pointer the resutling elf_symbol. static elf_symbol_sptr -build_elf_symbol_from_reference(read_context& ctxt, const xmlNodePtr node, - bool function_symbol) +build_elf_symbol_from_reference(read_context& ctxt, const xmlNodePtr node) { elf_symbol_sptr nil; @@ -2838,20 +2836,12 @@ build_elf_symbol_from_reference(read_context& ctxt, const xmlNodePtr node, if (name.empty()) return nil; - string_elf_symbols_map_sptr sym_db = - (function_symbol) - ? ctxt.get_corpus()->get_fun_symbol_map_sptr() - : ctxt.get_corpus()->get_var_symbol_map_sptr(); + const elf_symbols& symbols = + ctxt.get_corpus()->get_symtab()->lookup_symbol(name); - string_elf_symbols_map_type::const_iterator i = sym_db->find(name); - if (i != sym_db->end()) - { - for (elf_symbols::const_iterator s = i->second.begin(); - s != i->second.end(); - ++s) - if ((*s)->get_id_string() == sym_id) - return *s; - } + for (const auto& symbol : symbols) + if (symbol->get_id_string() == sym_id) + return symbol; } return nil; @@ -3102,8 +3092,7 @@ build_function_decl(read_context& ctxt, ctxt.push_decl_to_current_scope(fn_decl, add_to_current_scope); - elf_symbol_sptr sym = build_elf_symbol_from_reference(ctxt, node, - /*function_sym=*/true); + elf_symbol_sptr sym = build_elf_symbol_from_reference(ctxt, node); if (sym) fn_decl->set_symbol(sym); @@ -3334,8 +3323,7 @@ build_var_decl(read_context& ctxt, locus, mangled_name, vis, bind)); - elf_symbol_sptr sym = build_elf_symbol_from_reference(ctxt, node, - /*function_sym=*/false); + elf_symbol_sptr sym = build_elf_symbol_from_reference(ctxt, node); if (sym) decl->set_symbol(sym); From patchwork Wed Jan 27 12:58:43 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: 41844 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 F1B7C397282F; Wed, 27 Jan 2021 12:59:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F1B7C397282F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752372; bh=4xlQWq6ZiNMl4TodJWi/BpVITdNy2BcIlaHLKO+6T6A=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CvfUyZFMh+bep0ae/4Q27pzKidtUJjm1RjYqjGNfpbmCYfi+jLV4PVfzbIKbJeDnJ ryi+NrjC1XGy4zTKSpT3NbWeqrj0qACmqevbMydM6XQwrtAufdz3l8zT8WFNSjq9PS bUcvJFPpDCsthCpl5MypjVoXB2hiaj0E0w/i9A9E= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) by sourceware.org (Postfix) with ESMTPS id A86EF3972827 for ; Wed, 27 Jan 2021 12:59:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A86EF3972827 Received: by mail-wm1-x34a.google.com with SMTP id l21so816585wmj.1 for ; Wed, 27 Jan 2021 04:59:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=4xlQWq6ZiNMl4TodJWi/BpVITdNy2BcIlaHLKO+6T6A=; b=jm8T4Ozq2IltCVJu1fUIuZyPQstM5Rhp5fVMSWtBe1XGX+gzlsS1E2MFzx3g8LiJ89 /BvBXqFfxK+CJzx/2ptzr1r/s7Za2hPMojo41BbQrgFo/cAkYAz0r8An0kvs0oq6c6/i MWYsTDV+qwzkSLnjYNxmy5gdUODKUvw0Kno0EQRlU48Me9w/2rg0CwcC9dUnHMX7s33G UAN6avv6OeCjj96MwsqzOJOi9f7Q00QFDR03kuol43o4t3dn2k79J1IL0I1DFSWgVVmP w22+MwRHTsT2PXx3ZXWuSFwV1lcylgs62hoWHI/yXUeKkviw1RxAZYFnzbAs4w8fJZFu 3jmQ== X-Gm-Message-State: AOAM532FONrbTiDoOa1MsOyLM8cm8v9dS+fylsmh2pBItH/5m/rL6rul dA5wMrhjkEYhI77I0bNlg+7wiQ9hGApHon1zYwY4q++DjZ0t1nV+Ch4oQSjuOocsVivdPuJh75h McfVvllvl5W8NT3NjDPcUXaTr5+Q0xCv2MNjvMPIygoJD05+cyNDE8OVhECnfI9GyGqTwqSw= X-Google-Smtp-Source: ABdhPJxMuslW/0iTq0fG5VUz2oWp2wbHLTkEGAysUl+6rqivBXNfmzhonACMFAzqrEEDIeuYUPcOV3jSMtYllg== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a7b:c7c8:: with SMTP id z8mr4111851wmk.72.1611752368747; Wed, 27 Jan 2021 04:59:28 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:43 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-11-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 10/20] dwarf-reader: read_context: use new symtab in *_symbols_is_exported To: libabigail@sourceware.org X-Spam-Status: No, score=-23.4 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matthias Maennich via Libabigail From: =?utf-8?q?Matthias_M=C3=A4nnich?= Reply-To: Matthias Maennich Cc: maennich@google.com, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Testing whether a symbol is exported can be simplified using the new symtab implementation. The same holds true for whether a symbol is exported via ksymtab in case of linux kernel binaries. So, do that. * src/abg-dwarf-reader.cc (function_symbol_is_exported): Use new symtab implementation. (variable_symbol_is_exported): Likewise. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 9f533e64959c..3a93fe0df5d0 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -5807,11 +5807,11 @@ public: elf_symbol_sptr function_symbol_is_exported(GElf_Addr symbol_address) const { - elf_symbol_sptr symbol = lookup_elf_fn_symbol_from_address(symbol_address); + elf_symbol_sptr symbol = symtab()->lookup_symbol(symbol_address); if (!symbol) return symbol; - if (!symbol->is_public()) + if (!symbol->is_function() || !symbol->is_public()) return elf_symbol_sptr(); address_set_sptr set; @@ -5820,16 +5820,8 @@ public: if (looking_at_linux_kernel_binary) { - if ((set = linux_exported_fn_syms())) - { - if (set->find(symbol_address) != set->end()) - return symbol; - } - if ((set = linux_exported_gpl_fn_syms())) - { - if (set->find(symbol_address) != set->end()) - return symbol; - } + if (symbol->is_in_ksymtab()) + return symbol; return elf_symbol_sptr(); } @@ -5847,11 +5839,11 @@ public: elf_symbol_sptr variable_symbol_is_exported(GElf_Addr symbol_address) const { - elf_symbol_sptr symbol = lookup_elf_var_symbol_from_address(symbol_address); + elf_symbol_sptr symbol = symtab()->lookup_symbol(symbol_address); if (!symbol) return symbol; - if (!symbol->is_public()) + if (!symbol->is_variable() || !symbol->is_public()) return elf_symbol_sptr(); address_set_sptr set; @@ -5860,16 +5852,8 @@ public: if (looking_at_linux_kernel_binary) { - if ((set = linux_exported_var_syms())) - { - if (set->find(symbol_address) != set->end()) - return symbol; - } - if ((set = linux_exported_gpl_var_syms())) - { - if (set->find(symbol_address) != set->end()) - return symbol; - } + if (symbol->is_in_ksymtab()) + return symbol; return elf_symbol_sptr(); } From patchwork Wed Jan 27 12:58:44 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: 41845 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 456F3397282F; Wed, 27 Jan 2021 12:59:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 456F3397282F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752377; bh=AW6PqywtYXcdy82W/FCIAWl0A9/kJfJdysVmE5rtrzI=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=CK3gmgC5ns/FkA1hU3Nyz+zRH5DJh/NNwPcI+y72EUyKGRgCVn519a7MAazMD6YIV nwngwZjChdWayq6nTbqWEj4JDBkGDOLV3mvr+w+bYJLJom+qHl15LdTFCrdFQYRhXb x2LpGm+0vaVwjnMBaJvjFidnqjaVEQ7Uk+QSuIJI= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qv1-xf49.google.com (mail-qv1-xf49.google.com [IPv6:2607:f8b0:4864:20::f49]) by sourceware.org (Postfix) with ESMTPS id 68B523971C3C for ; Wed, 27 Jan 2021 12:59:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 68B523971C3C Received: by mail-qv1-xf49.google.com with SMTP id z8so1216635qva.23 for ; Wed, 27 Jan 2021 04:59:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=AW6PqywtYXcdy82W/FCIAWl0A9/kJfJdysVmE5rtrzI=; b=LF8RmI3snhQDNEF3YcXCwqHhXwKYUfLS2dKU4DzjmhodImww0TCEPgDqaLVaG/oqbR /i6kQVgJL93O6Is1936WvmXNN/f0zo3JhccR0b1vl+4yr1vztBjM/GtaXx5gRP7VSPaM nkfseUXKWG1v9CiPVn+UK5zwqe52tmDe64Y0OzwW1fMFmQx2l9IfW/09NQIIrviR7wG8 g+a+IaB5NEBbXbNXM9ODzzuqp6UUZ7RTjcgW0O0qP0vOWeM9adpRFd3D929HfnqDWJYf GaRcixJRyBKuitvwwRBgTNowXUwb0NGEv4A6H6rPcgenZbyjRTX0dPPI1ZkAEcY4qFI5 dGWg== X-Gm-Message-State: AOAM533mIEUCIXrvMJ3peeGFLOlzYx8BnjxSz+krUY6KsmSCgYTY3STz DJMKsI90rR03q2SZsUvP/mMmvHDlEZkTo6IvMu8CYlOI9qgUEcBOPxilqnUmvmz9Yrx5lhhVh8r XCHPljsnxC+MqVUKZzPOfyXk01tecKM+0oJADIz79DvmUG2MxAhE+jQEIxVoVHWM446sax/Y= X-Google-Smtp-Source: ABdhPJy9quT8q8xZLTVXzSvEpdO+dVBS3vb7l5SQP7R1aHaa/f1Mj5LOR3QvMZZPqAIuL8YBYOysW7uYqZwIlg== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:b414:: with SMTP id u20mr10343223qve.57.1611752370941; Wed, 27 Jan 2021 04:59:30 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:44 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-12-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 11/20] Switch kernel stuff over to new symtab and drop unused code To: libabigail@sourceware.org X-Spam-Status: No, score=-21.6 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Now that the new symtab implementation is capable of reading the ksymtab, we can switch over the implementation to gather information from there and delete all now-obsolete code. * src/abg-dwarf-reader.cc (read_context::ksymtab_format_): Delete. (read_context::ksymtab_entry_size_): Likewise. (read_context::nb_ksymtab_entries_): Likewise. (read_context::nb_ksymtab_gpl_entries_): Likewise. (read_context::ksymtab_section_): Likewise. (read_context::ksymtab_reloc_section_): Likewise. (read_context::ksymtab_gpl_section_): Likewise. (read_context::ksymtab_gpl_reloc_section_): Likewise. (read_context::ksymtab_strings_section_): Likewise. (read_context::linux_exported_fn_syms): Likewise. (read_context::linux_exported_var_syms): Likewise. (read_context::linux_exported_gpl_fn_syms): Likewise. (read_context::linux_exported_gpl_var_syms): Likewise. (read_context::initialize): Remove initializations accordingly. (read_context::find_ksymtab_section): Delete. (read_context::find_ksymtab_gpl_section): Likewise. (read_context::find_ksymtab_reloc_section): Likewise. (read_context::find_ksymtab_gpl_reloc_section): Likewise. (read_context::find_ksymtab_strings_section): Likewise. (read_context::find_any_ksymtab_section): Likewise. (read_context::find_any_ksymtab_reloc_section): Likewise. (read_context::lookup_elf_symbol_from_index): Adjust. (read_context::linux_exported_fn_syms): Delete. (read_context::create_or_get_linux_exported_fn_syms): Likewise. (read_context::linux_exported_var_syms): Likewise. (read_context::create_or_get_linux_exported_var_syms): Likewise. (read_context::linux_exported_gpl_fn_syms): Delete. (read_context::create_or_get_linux_exported_gpl_fn_syms): Likewise. (read_context::linux_exported_gpl_var_syms): Likewise. (read_context::create_or_get_linux_exported_gpl_var_syms): Likewise. (read_context::try_reading_first_ksymtab_entry): Likewise. (read_context::try_reading_first_ksymtab_entry_using_pre_v4_19_format): Likewise. (read_context::try_reading_first_ksymtab_entry_using_v4_19_format): Likewise. (read_context::get_ksymtab_format_module): Likewise. (read_context::get_ksymtab_format): Likewise. (read_context::get_ksymtab_symbol_value_size): Likewise. (read_context::get_ksymtab_entry_size): Likewise. (read_context::get_nb_ksymtab_entries): Likewise. (read_context::get_nb_ksymtab_gpl_entries): Likewise. (read_context::populate_symbol_map_from_ksymtab): Likewise. (read_context::populate_symbol_map_from_ksymtab_reloc): Likewise. (read_context::load_kernel_symbol_table): Likewise. (read_context::load_ksymtab_symbols): Likewise. (read_context::load_ksymtab_gpl_symbols): Likewise. (read_context::load_linux_specific_exported_symbol_maps): Likewise. (read_context::load_symbol_maps): Do not load kernel symbol maps. (read_context::maybe_adjust_sym_address_from_v4_19_ksymtab): Delete. (read_context::add_fn_symbols_to_map): Likewise. (read_context::add_var_symbols_to_map): Likewise. (read_context::read_debug_info_into_corpus): Fill export maps from new symtab. (read_context::lookup_elf_fn_symbol_from_address): Delete. (read_context::lookup_elf_var_symbol_from_address): Likewise. (read_context::lookup_elf_symbol_from_address): Likewise. (read_context::lookup_public_function_symbol_from_elf): Likewise. (read_context::fun_entry_addr_sym_map_sptr): Likewise. (read_context::fun_entry_addr_sym_map): Likewise. (read_context::var_addr_sym_map): Likewise. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 1191 +-------------------------------------- 1 file changed, 19 insertions(+), 1172 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 3a93fe0df5d0..693fae82040e 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2145,26 +2145,6 @@ public: // ppc64 elf v1 binaries. This section contains the procedure // descriptors on that platform. mutable Elf_Scn* opd_section_; - /// The format of the special __ksymtab section from the linux - /// kernel binary. - mutable ksymtab_format ksymtab_format_; - /// The size of one entry of the __ksymtab section. - mutable size_t ksymtab_entry_size_; - /// The number of entries in the __ksymtab section. - mutable size_t nb_ksymtab_entries_; - /// The number of entries in the __ksymtab_gpl section. - mutable size_t nb_ksymtab_gpl_entries_; - /// The special __ksymtab and __ksymtab_gpl sections from linux - /// kernel or module binaries. The former is used to store - /// references to symbols exported using the EXPORT_SYMBOL macro - /// from the linux kernel. The latter is used to store references - /// to symbols exported using the EXPORT_SYMBOL_GPL macro from the - /// linux kernel. - mutable Elf_Scn* ksymtab_section_; - mutable Elf_Scn* ksymtab_reloc_section_; - mutable Elf_Scn* ksymtab_gpl_section_; - mutable Elf_Scn* ksymtab_gpl_reloc_section_; - mutable Elf_Scn* ksymtab_strings_section_; Dwarf_Die* cur_tu_die_; mutable dwarf_expr_eval_context dwarf_expr_eval_context_; // A set of maps (one per kind of die source) that associates a decl @@ -2248,10 +2228,6 @@ public: string_elf_symbols_map_sptr var_syms_; string_elf_symbols_map_sptr undefined_fun_syms_; string_elf_symbols_map_sptr undefined_var_syms_; - address_set_sptr linux_exported_fn_syms_; - address_set_sptr linux_exported_var_syms_; - address_set_sptr linux_exported_gpl_fn_syms_; - address_set_sptr linux_exported_gpl_var_syms_; vector dt_needed_; string dt_soname_; string elf_architecture_; @@ -2350,15 +2326,6 @@ public: elf_path_ = elf_path; symtab_section_ = 0; opd_section_ = 0; - ksymtab_format_ = UNDEFINED_KSYMTAB_FORMAT; - ksymtab_entry_size_ = 0; - nb_ksymtab_entries_ = 0; - nb_ksymtab_gpl_entries_ = 0; - ksymtab_section_ = 0; - ksymtab_reloc_section_ = 0; - ksymtab_gpl_section_ = 0; - ksymtab_gpl_reloc_section_ = 0; - ksymtab_strings_section_ = 0; cur_tu_die_ = 0; exported_decls_builder_ = 0; @@ -2404,10 +2371,6 @@ public: var_syms_.reset(); undefined_fun_syms_.reset(); undefined_var_syms_.reset(); - linux_exported_fn_syms_.reset(); - linux_exported_var_syms_.reset(); - linux_exported_gpl_fn_syms_.reset(); - linux_exported_gpl_var_syms_.reset(); dt_needed_.clear(); dt_soname_.clear(); elf_architecture_.clear(); @@ -5362,97 +5325,6 @@ public: return opd_section_; } - /// Return the __ksymtab section of a linux kernel ELF file (either - /// a vmlinux binary or a kernel module). - /// - /// @return the __ksymtab section if found, nil otherwise. - Elf_Scn* - find_ksymtab_section() const - { - if (!ksymtab_section_) - ksymtab_section_ = elf_helpers::find_ksymtab_section(elf_handle()); - return ksymtab_section_; - } - - /// Return the __ksymtab_gpl section of a linux kernel ELF file - /// (either a vmlinux binary or a kernel module). - /// - /// @return the __ksymtab_gpl section if found, nil otherwise. - Elf_Scn* - find_ksymtab_gpl_section() const - { - if (!ksymtab_gpl_section_) - ksymtab_gpl_section_ = - elf_helpers::find_ksymtab_gpl_section(elf_handle()); - return ksymtab_gpl_section_; - } - - /// Return the .rel{a,}__ksymtab section of a linux kernel ELF file (either - /// a vmlinux binary or a kernel module). - /// - /// @return the .rel{a,}__ksymtab section if found, nil otherwise. - Elf_Scn* - find_ksymtab_reloc_section() const - { - if (!ksymtab_reloc_section_) - ksymtab_reloc_section_ = - find_relocation_section(elf_handle(), find_ksymtab_section()); - return ksymtab_reloc_section_; - } - - /// Return the .rel{a,}__ksymtab_gpl section of a linux kernel ELF file - /// (either a vmlinux binary or a kernel module). - /// - /// @return the .rel{a,}__ksymtab_gpl section if found, nil otherwise. - Elf_Scn* - find_ksymtab_gpl_reloc_section() const - { - if (!ksymtab_gpl_reloc_section_) - ksymtab_gpl_reloc_section_ = - find_relocation_section(elf_handle(), find_ksymtab_gpl_section()); - return ksymtab_gpl_reloc_section_; - } - - /// Return the __ksymtab_strings section of a linux kernel ELF file - /// (either a vmlinux binary or a kernel module). - /// - /// @return the __ksymtab_strings section if found, nil otherwise. - Elf_Scn* - find_ksymtab_strings_section() const - { - if (!ksymtab_strings_section_) - ksymtab_strings_section_ = - dwarf_reader::find_ksymtab_strings_section(elf_handle()); - return ksymtab_strings_section_; - } - - /// Return either a __ksymtab or a __ksymtab_gpl section, in case - /// only the __ksymtab_gpl exists. - /// - /// @return the __ksymtab section if it exists, or the - /// __ksymtab_gpl; or NULL if neither is found. - Elf_Scn* - find_any_ksymtab_section() const - { - Elf_Scn *result = find_ksymtab_section(); - if (!result) - result = find_ksymtab_gpl_section(); - return result; - } - - /// Return either a .rel{a,}__ksymtab or a .rel{a,}__ksymtab_gpl section - /// - /// @return the .rel{a,}__ksymtab section if it exists, or the - /// .rel{a,}__ksymtab_gpl; or NULL if neither is found. - Elf_Scn* - find_any_ksymtab_reloc_section() const - { - Elf_Scn *result = find_ksymtab_reloc_section(); - if (!result) - result = find_ksymtab_gpl_reloc_section(); - return result; - } - /// Lookup an elf symbol, referred to by its index, from the .symtab /// section. /// @@ -5548,7 +5420,7 @@ public: elf_symbol::visibility vis = stv_to_elf_symbol_visibility(GELF_ST_VISIBILITY(native_sym.st_other)); - Elf_Scn *strings_section = find_ksymtab_strings_section(); + Elf_Scn* strings_section = find_ksymtab_strings_section(elf_handle()); size_t strings_ndx = strings_section ? elf_ndxscn(strings_section) : 0; @@ -5710,92 +5582,6 @@ public: return result; } - /// Given the address of the beginning of a function, lookup the - /// symbol of the function, build an instance of @ref elf_symbol out - /// of it and return it. - /// - /// @param symbol_start_addr the address of the beginning of the - /// function to consider. - /// - /// @param sym the resulting symbol. This is set iff the function - /// returns true. - /// - /// @return the elf symbol found at address @p symbol_start_addr, or - /// nil if none was found. - elf_symbol_sptr - lookup_elf_fn_symbol_from_address(GElf_Addr symbol_start_addr) const - { - addr_elf_symbol_sptr_map_type::const_iterator i, - nil = fun_entry_addr_sym_map().end(); - - if ((i = fun_entry_addr_sym_map().find(symbol_start_addr)) == nil) - return elf_symbol_sptr(); - - return i->second; - } - - /// Given the address of a global variable, lookup the symbol of the - /// variable, build an instance of @ref elf_symbol out of it and - /// return it. - /// - /// @param symbol_start_addr the address of the beginning of the - /// variable to consider. - /// - /// @param the symbol found, iff the function returns true. - /// - /// @return the elf symbol found or nil if none was found. - elf_symbol_sptr - lookup_elf_var_symbol_from_address(GElf_Addr symbol_start_addr) const - { - addr_elf_symbol_sptr_map_type::const_iterator i, - nil = var_addr_sym_map().end(); - - if ((i = var_addr_sym_map().find(symbol_start_addr)) == nil) - return elf_symbol_sptr(); - - return i->second; - } - - /// Lookup an elf symbol, knowing its address. - /// - /// This function first looks for a function symbol having this - /// address; if it doesn't find any, then it looks for a variable - /// symbol. - /// - /// @param symbol_addr the address of the symbol of the symbol we - /// are looking for. Note that the address is a relative offset - /// starting from the beginning of the .text section. Addresses - /// that are presen in the symbol table (the one named .symtab). - /// - /// @return the elf symbol if found, or nil otherwise. - elf_symbol_sptr - lookup_elf_symbol_from_address(GElf_Addr symbol_addr) const - { - elf_symbol_sptr result = lookup_elf_fn_symbol_from_address(symbol_addr); - if (!result) - result = lookup_elf_var_symbol_from_address(symbol_addr); - return result; - } - - /// Look in the symbol tables of the underying elf file and see if - /// we find a symbol of a given name of function type. - /// - /// @param sym_name the name of the symbol to look for. - /// - /// @param syms the public function symbols that were found, with - /// the name @p sym_name. - /// - /// @return true iff the symbol was found. - bool - lookup_public_function_symbol_from_elf(const string& sym_name, - vector& syms) - { - return dwarf_reader::lookup_public_function_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 @@ -5894,20 +5680,6 @@ public: 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. - /// - /// Note that on non-"PPC64 ELFv1" binaries, this map is the same as - /// the one that assciates the address of a function with the symbol - /// of that function. - /// - /// @return a pointer to the map that associates the address of an - /// entry point of a function with the symbol of that function. - const addr_elf_symbol_sptr_map_sptr& - fun_entry_addr_sym_map_sptr() const - {return const_cast(this)->fun_entry_addr_sym_map_sptr();} - - /// Getter for the map that associates the address of an entry point /// of a function with the symbol of that function. /// @@ -5921,19 +5693,6 @@ public: fun_entry_addr_sym_map() {return *fun_entry_addr_sym_map_sptr();} - /// Getter for the map that associates the address of an entry point - /// of a function with the symbol of that function. - /// - /// Note that on non-"PPC64 ELFv1" binaries, this map is the same as - /// the one that assciates the address of a function with the symbol - /// of that function. - /// - /// @return the map that associates the address of an entry point of - /// a function with the symbol of that function. - const addr_elf_symbol_sptr_map_type& - fun_entry_addr_sym_map() const - { return *fun_entry_addr_sym_map_sptr();} - /// Getter for the map of function symbols (name -> sym). /// /// @return a shared pointer to the map of function symbols. @@ -5998,130 +5757,6 @@ public: return undefined_var_syms_; } - /// Getter for the set of addresses of function symbols that are - /// explicitely exported, for a linux kernel (module) binary. These - /// are the addresses of function symbols present in the __ksymtab - /// section - address_set_sptr& - linux_exported_fn_syms() - {return linux_exported_fn_syms_;} - - /// Getter for the set of addresses of functions that are - /// explicitely exported, for a linux kernel (module) binary. These - /// are the addresses of function symbols present in the __ksymtab - /// section. - /// - /// @return the set of addresses of exported function symbols. - const address_set_sptr& - linux_exported_fn_syms() const - {return const_cast(this)->linux_exported_fn_syms();} - - /// Create an empty set of addresses of functions exported from a - /// linux kernel (module) binary, or return the one that already - /// exists. - /// - /// @return the set of addresses of exported function symbols. - address_set_sptr& - create_or_get_linux_exported_fn_syms() - { - if (!linux_exported_fn_syms_) - linux_exported_fn_syms_.reset(new address_set_type); - return linux_exported_fn_syms_; - } - - /// Getter for the set of addresses of v ariables that are - /// explicitely exported, for a linux kernel (module) binary. These - /// are the addresses of variable symbols present in the __ksymtab - /// section. - /// - /// @return the set of addresses of exported variable symbols. - address_set_sptr& - linux_exported_var_syms() - {return linux_exported_var_syms_;} - - /// Getter for the set of addresses of variables that are - /// explicitely exported, for a linux kernel (module) binary. These - /// are the addresses of variable symbols present in the __ksymtab - /// section. - /// - /// @return the set of addresses of exported variable symbols. - const address_set_sptr& - linux_exported_var_syms() const - {return const_cast(this)->linux_exported_var_syms();} - - - /// Create an empty set of addresses of variables exported from a - /// linux kernel (module) binary, or return the one that already - /// exists. - /// - /// @return the set of addresses of exported variable symbols. - address_set_sptr& - create_or_get_linux_exported_var_syms() - { - if (!linux_exported_var_syms_) - linux_exported_var_syms_.reset(new address_set_type); - return linux_exported_var_syms_; - } - - - /// Getter for the set of addresses of function symbols that are - /// explicitely exported as GPL, for a linux kernel (module) binary. - /// These are the addresses of function symbols present in the - /// __ksymtab_gpl section. - address_set_sptr& - linux_exported_gpl_fn_syms() - {return linux_exported_gpl_fn_syms_;} - - /// Getter for the set of addresses of function symbols that are - /// explicitely exported as GPL, for a linux kernel (module) binary. - /// These are the addresses of function symbols present in the - /// __ksymtab_gpl section. - const address_set_sptr& - linux_exported_gpl_fn_syms() const - {return const_cast(this)->linux_exported_gpl_fn_syms();} - - /// Create an empty set of addresses of GPL functions exported from - /// a linux kernel (module) binary, or return the one that already - /// exists. - /// - /// @return the set of addresses of exported function symbols. - address_set_sptr& - create_or_get_linux_exported_gpl_fn_syms() - { - if (!linux_exported_gpl_fn_syms_) - linux_exported_gpl_fn_syms_.reset(new address_set_type); - return linux_exported_gpl_fn_syms_; - } - - /// Getter for the set of addresses of variable symbols that are - /// explicitely exported as GPL, for a linux kernel (module) binary. - /// These are the addresses of variable symbols present in the - /// __ksymtab_gpl section. - address_set_sptr& - linux_exported_gpl_var_syms() - {return linux_exported_gpl_var_syms_;} - - /// Getter for the set of addresses of variable symbols that are - /// explicitely exported as GPL, for a linux kernel (module) binary. - /// These are the addresses of variable symbols present in the - /// __ksymtab_gpl section. - const address_set_sptr& - linux_exported_gpl_var_syms() const - {return const_cast(this)->linux_exported_gpl_var_syms();} - - /// Create an empty set of addresses of GPL variables exported from - /// a linux kernel (module) binary, or return the one that already - /// exists. - /// - /// @return the set of addresses of exported variable symbols. - address_set_sptr& - create_or_get_linux_exported_gpl_var_syms() - { - if (!linux_exported_gpl_var_syms_) - linux_exported_gpl_var_syms_.reset(new address_set_type); - return linux_exported_gpl_var_syms_; - } - /// Getter for the ELF dt_needed tag. const vector& dt_needed() const @@ -6137,28 +5772,6 @@ public: elf_architecture() const {return elf_architecture_;} - /// Getter for the map of global variables symbol address -> global - /// variable symbol index. - /// - /// @return the map. Note that this initializes the map once when - /// its nedded. - const addr_elf_symbol_sptr_map_type& - var_addr_sym_map() const - {return const_cast(this)->var_addr_sym_map();} - - /// Getter for the map of global variables symbol address -> global - /// variable symbol index. - /// - /// @return the map. Note that this initializes the map once when - /// its nedded. - addr_elf_symbol_sptr_map_type& - var_addr_sym_map() - { - if (!var_addr_sym_map_) - maybe_load_symbol_maps(); - return *var_addr_sym_map_; - } - /// Load the maps address -> function symbol, address -> variable /// symbol and the maps of function and variable undefined symbols. /// @@ -6383,364 +5996,6 @@ public: return true; } - /// Try reading the first __ksymtab section entry. - /// - /// We lookup the symbol from the raw section passed as an argument. For - /// that, consider endianess and adjust for potential Elf relocations before - /// looking up the symbol in the .symtab section. - // - /// Optionally, support position relative relocations by considering the - /// ksymtab entry as 32 bit and applying the relocation relative to the - /// section header (i.e. the symbol position as we are reading the first - /// symbol). - /// - /// @param section the ksymtab section to consider. - /// - /// @param position_relative_relocations if true, then consider that - /// the section designated by @p section contains position-relative - /// relocated symbol addresses. - /// - /// @param symbol_offset if different from zero - /// If symbol_offset is != 0, adjust the position we consider the section - /// start. That is useful to read the ksymtab with a slight offset. - /// - /// Note, this function does not support relocatable ksymtab entries (as for - /// example in kernel modules). Using this function for ksymtabs where - /// relocations need to be applied for the entries we are reading here, will - /// yield wrong results. - /// - /// @return the symbol resulting from the lookup of the symbol address we - /// got from reading the first entry of the ksymtab or null if no such entry - /// could be found. - elf_symbol_sptr - try_reading_first_ksymtab_entry(Elf_Scn* section, - bool position_relative_relocations, - int symbol_offset = 0) const - { - Elf_Data* elf_data = elf_rawdata(section, 0); - uint8_t* bytes = reinterpret_cast(elf_data->d_buf); - bool is_big_endian = architecture_is_big_endian(elf_handle()); - elf_symbol_sptr symbol; - GElf_Addr symbol_address = 0; - - unsigned char symbol_value_size; - if (position_relative_relocations) - symbol_value_size = sizeof(int32_t); - else - symbol_value_size = get_architecture_word_size(elf_handle()); - - const int read_offset = (symbol_offset * symbol_value_size); - bytes += read_offset; - - if (position_relative_relocations) - { - int32_t offset = 0; - ABG_ASSERT(read_int_from_array_of_bytes(bytes, symbol_value_size, - is_big_endian, offset)); - GElf_Shdr section_header; - gelf_getshdr(section, §ion_header); - // the actual symbol address is relative to its position. Since we do - // not know the position, we take the beginning of the section, add the - // read_offset that we might have and finally apply the offset we - // read from the section. - symbol_address = section_header.sh_addr + read_offset + offset; - } - else - ABG_ASSERT(read_int_from_array_of_bytes(bytes, symbol_value_size, - is_big_endian, symbol_address)); - - symbol_address = maybe_adjust_fn_sym_address(symbol_address); - symbol = lookup_elf_symbol_from_address(symbol_address); - return symbol; - } - - /// Try reading the first __ksymtab section entry as if it is in the - /// pre-v4_19 format, that is without position relative relocations. - /// - /// @return the symbol resulting from the lookup of the symbol - /// address we got from reading the first entry of the ksymtab - /// section assuming the pre-v4.19 format. If null, it means the - /// __ksymtab section is not in the pre-v4.19 format. - elf_symbol_sptr - try_reading_first_ksymtab_entry_using_pre_v4_19_format() const - { - Elf_Scn *section = find_any_ksymtab_section(); - return try_reading_first_ksymtab_entry(section, false); - } - - /// Try reading the first __ksymtab section entry as if it is in the - /// v4_19 format, that is with position relative relocations. - /// - /// @return the symbol resulting from the lookup of the symbol - /// address we got from reading the first entry of the ksymtab - /// section assuming the v4.19 format. If null, it means the - /// __ksymtab section is not in the v4.19 format. - elf_symbol_sptr - try_reading_first_ksymtab_entry_using_v4_19_format() const - { - Elf_Scn *section = find_any_ksymtab_section(); - return try_reading_first_ksymtab_entry(section, true); - } - - /// Try to determine the format of the __ksymtab and __ksymtab_gpl - /// sections of Linux kernel modules. - /// - /// This is important because we need to know the format of these - /// sections to be able to read from them. - /// - /// @return the format the __ksymtab[_gpl] sections. - enum ksymtab_format - get_ksymtab_format_module() const - { - Elf_Scn *section = find_any_ksymtab_reloc_section(); - - ABG_ASSERT(section); - - // Libdwfl has a weird quirk where, in the process of obtaining an Elf - // descriptor via dwfl_module_getelf(), it will apply all relocations it - // knows how to and it will zero the relocation info after applying it. If - // the .rela__ksymtab* section contained only simple (absolute) relocations, - // they will have been all applied and sh_size will be 0. For arches that - // support relative ksymtabs, simple relocations only appear in pre-4.19 - // kernel modules. - GElf_Shdr section_mem; - GElf_Shdr *section_shdr = gelf_getshdr(section, §ion_mem); - if (section_shdr->sh_size == 0) - return PRE_V4_19_KSYMTAB_FORMAT; - - bool is_relasec = (section_shdr->sh_type == SHT_RELA); - - // If we still have a normal non-zeroed relocation section, we can guess - // what format the ksymtab is in depending on what types of relocs it - // contains. - - uint64_t type; - Elf_Data *section_data = elf_getdata(section, 0); - if (is_relasec) - { - GElf_Rela rela; - gelf_getrela(section_data, 0, &rela); - type = GELF_R_TYPE(rela.r_info); - } - else - { - GElf_Rel rel; - gelf_getrel(section_data, 0, &rel); - type = GELF_R_TYPE(rel.r_info); - } - - // Sigh, I dislike the arch-dependent code here, but this seems to be a - // reliable heuristic for kernel modules for now. Relative ksymtabs only - // supported on x86 and arm64 as of v4.19. - ksymtab_format format; - switch (type) - { - case R_X86_64_64: // Same as R_386_32, fallthrough -#ifdef HAVE_R_AARCH64_ABS64_MACRO - case R_AARCH64_ABS64: -#endif - format = PRE_V4_19_KSYMTAB_FORMAT; - break; - case R_X86_64_PC32: // Same as R_386_PC32, fallthrough -#ifdef HAVE_R_AARCH64_PREL32_MACRO - case R_AARCH64_PREL32: -#endif - format = V4_19_KSYMTAB_FORMAT; - break; - default: - // Fall back to other methods of determining the ksymtab format. - format = UNDEFINED_KSYMTAB_FORMAT; - break; - } - return format; - } - - /// Determine the format of the __ksymtab and __ksymtab_gpl - /// sections. - /// - /// This is important because we need the know the format of these - /// sections to be able to read from them. - /// - /// @return the format the __ksymtab[_gpl] sections. - enum ksymtab_format - get_ksymtab_format() const - { - if (!find_any_ksymtab_section()) - ksymtab_format_ = UNDEFINED_KSYMTAB_FORMAT; - else - { - if (ksymtab_format_ == UNDEFINED_KSYMTAB_FORMAT) - { - // Since Linux kernel modules are relocatable, we can first try - // using a heuristic based on relocations to guess the ksymtab format. - if (is_linux_kernel_module(elf_handle())) - { - ksymtab_format_ = get_ksymtab_format_module(); - if (ksymtab_format_ != UNDEFINED_KSYMTAB_FORMAT) - return ksymtab_format_; - } - - // If it's not a kernel module or we couldn't determine its format - // with relocations, fall back to the heuristics below. - - // OK this is a dirty little heuristic to determine the - // format of the ksymtab section. - // - // We try to read the first ksymtab entry assuming a - // pre-v4.19 format. If that succeeds then we are in the - // pr-v4.19 format. Otherwise, try reading it assuming a - // v4.19 format. For now, we just support - // PRE_V4_19_KSYMTAB_FORMAT and V4_19_KSYMTAB_FORMAT. - if (try_reading_first_ksymtab_entry_using_pre_v4_19_format()) - ksymtab_format_ = PRE_V4_19_KSYMTAB_FORMAT; - else if (try_reading_first_ksymtab_entry_using_v4_19_format()) - ksymtab_format_ = V4_19_KSYMTAB_FORMAT; - else - // If a new format emerges, then we need to add its - // support above. - ABG_ASSERT_NOT_REACHED; - } - } - return ksymtab_format_; - } - - /// Getter of the size of the symbol value part of an entry of the - /// ksymtab section. - /// - /// @return the size of the symbol value part of the entry of the - /// ksymtab section. - unsigned char - get_ksymtab_symbol_value_size() const - { - unsigned char result = 0; - ksymtab_format format = get_ksymtab_format(); - if (format == UNDEFINED_KSYMTAB_FORMAT) - ; - else if (format == PRE_V4_19_KSYMTAB_FORMAT) - result = get_architecture_word_size(elf_handle()); - else if (format == V4_19_KSYMTAB_FORMAT) - result = 4; - else - ABG_ASSERT_NOT_REACHED; - - return result; - } - - /// Getter of the size of one entry of the ksymtab section. - /// - /// @return the size of one entry of the ksymtab section. - unsigned char - get_ksymtab_entry_size() const - { - if (ksymtab_entry_size_ == 0) - { - const unsigned char symbol_size = get_ksymtab_symbol_value_size(); - Elf_Scn* ksymtab = find_any_ksymtab_section(); - if (ksymtab) - { - GElf_Shdr ksymtab_shdr; - gelf_getshdr(ksymtab, &ksymtab_shdr); - - // ksymtab entries have the following layout - // - // struct { - // T symbol_address; // .symtab entry - // T name_address; // .strtab entry - // } - // - // with T being a suitable type to represent the absolute, - // relocatable or position relative value of the address. T's size - // is determined by get_ksymtab_symbol_value_size(). - // - // Since Kernel v5.4, the entries have the following layout - // - // struct { - // T symbol_address; // .symtab entry - // T name_address; // .strtab entry - // T namespace; // .strtab entry - // } - // - // To determine the ksymtab entry size, find the next entry that - // refers to a valid .symtab entry. The offset to that one is what - // we are searching for. - for (unsigned entries = 2; entries <= 3; ++entries) - { - const unsigned candidate_size = entries * symbol_size; - - // if there is exactly one entry, section size == entry size - // (this looks like an optimization, but in fact it prevents - // from illegal reads if there is actually only one entry) - if (ksymtab_shdr.sh_size == candidate_size) - { - ksymtab_entry_size_ = candidate_size; - break; - } - - // otherwise check whether the symbol following the candidate - // number of entries is a valid ELF symbol. For that we read - // the ksymtab with the given offset and if the symbol is - // valid, we found our entry size. - const ksymtab_format format = get_ksymtab_format(); - if (try_reading_first_ksymtab_entry - (ksymtab, format == V4_19_KSYMTAB_FORMAT, entries)) - { - ksymtab_entry_size_ = candidate_size; - break; - } - } - ABG_ASSERT(ksymtab_entry_size_ != 0); - } - } - - return ksymtab_entry_size_; - } - - /// Getter of the number of entries that are present in the ksymtab - /// section. - /// - /// @return the number of entries that are present in the ksymtab - /// section. - size_t - get_nb_ksymtab_entries() const - { - if (nb_ksymtab_entries_ == 0) - { - Elf_Scn *section = find_ksymtab_section(); - if (section) - { - GElf_Shdr header_mem; - GElf_Shdr *section_header = gelf_getshdr(section, &header_mem); - size_t entry_size = get_ksymtab_entry_size(); - ABG_ASSERT(entry_size); - nb_ksymtab_entries_ = section_header->sh_size / entry_size; - } - } - return nb_ksymtab_entries_; - } - - /// Getter of the number of entries that are present in the - /// ksymtab_gpl section. - /// - /// @return the number of entries that are present in the - /// ksymtab_gpl section. - size_t - get_nb_ksymtab_gpl_entries() - { - if (nb_ksymtab_gpl_entries_ == 0) - { - Elf_Scn *section = find_ksymtab_gpl_section(); - if (section) - { - GElf_Shdr header_mem; - GElf_Shdr *section_header = gelf_getshdr(section, &header_mem); - size_t entry_size = get_ksymtab_entry_size(); - ABG_ASSERT(entry_size); - nb_ksymtab_gpl_entries_ = section_header->sh_size / entry_size; - } - } - return nb_ksymtab_gpl_entries_; - } - /// Test if a given ELF symbol was suppressed by a suppression /// specification. /// @@ -6756,328 +6011,6 @@ public: symbol->get_type())); } - /// Populate the symbol map by reading exported symbols from the - /// ksymtab directly. - /// - /// @param section the ksymtab section to read from - /// - /// @param exported_fns_set the set of exported functions - /// - /// @param exported_vars_set the set of exported variables - /// - /// @param nb_entries the number of ksymtab entries to read - /// - /// @return true upon successful completion, false otherwise. - bool - populate_symbol_map_from_ksymtab(Elf_Scn *section, - address_set_sptr exported_fns_set, - address_set_sptr exported_vars_set, - size_t nb_entries) - { - // The data of the section. - Elf_Data *elf_data = elf_rawdata(section, 0); - - // An array-of-bytes view of the elf data above. Something we can - // actually program with. Phew. - uint8_t *bytes = reinterpret_cast(elf_data->d_buf); - - // This is where to store an address of a symbol that we read from - // the section. - GElf_Addr symbol_address = 0, adjusted_symbol_address = 0; - - // So the section is an array of entries. Each entry describes a - // symbol. Each entry is made of two words. - // - // The first word is the address of a symbol. The second one is - // the address of a static global variable symbol which value is - // the string representing the symbol name. That string is in the - // __ksymtab_strings section. Here, we are only interested in the - // first entry. - // - // Lets thus walk the array of entries, and let's read just the - // symbol address part of each entry. - bool is_big_endian = architecture_is_big_endian(elf_handle()); - elf_symbol_sptr symbol; - unsigned char symbol_value_size = get_ksymtab_symbol_value_size(); - - for (size_t i = 0, entry_offset = 0; - i < nb_entries; - ++i, entry_offset = get_ksymtab_entry_size() * i) - { - symbol_address = 0; - ABG_ASSERT(read_int_from_array_of_bytes(&bytes[entry_offset], - symbol_value_size, - is_big_endian, - symbol_address)); - - // Starting from linux kernel v4.19, it can happen that the - // address value read from the ksymtab[_gpl] section might - // need some decoding to get the real symbol address that has - // a meaning in the .symbol section. - symbol_address = - maybe_adjust_sym_address_from_v4_19_ksymtab(symbol_address, - entry_offset, section); - - // We might also want to adjust the symbol address, depending - // on if we are looking at an ET_REL, an executable or a - // shared object binary. - adjusted_symbol_address = maybe_adjust_fn_sym_address(symbol_address); - - if (adjusted_symbol_address == 0) - // The resulting symbol address is zero, not sure this - // valid; ignore it. - continue; - - // OK now the symbol address should be in a suitable form to - // be used to look the symbol up in the usual .symbol section - // (aka ELF symbol table). - symbol = lookup_elf_symbol_from_address(adjusted_symbol_address); - if (!symbol) - { - adjusted_symbol_address = - maybe_adjust_var_sym_address(symbol_address); - symbol = lookup_elf_symbol_from_address(adjusted_symbol_address); - if (!symbol) - // This must be a symbol that is of type neither FUNC - // (function) nor OBJECT (variable). There are for intance, - // symbols of type 'NOTYPE' in the ksymtab symbol table. I - // am not sure what those are. - continue; - } - - // If the symbol was suppressed by a suppression - // specification then drop it on the floor. - if (is_elf_symbol_suppressed(symbol)) - continue; - - address_set_sptr set; - if (symbol->is_function()) - { - ABG_ASSERT(lookup_elf_fn_symbol_from_address - (adjusted_symbol_address)); - set = exported_fns_set; - } - else if (symbol->is_variable()) - { - ABG_ASSERT(lookup_elf_var_symbol_from_address - (adjusted_symbol_address)); - set = exported_vars_set; - } - else - ABG_ASSERT_NOT_REACHED; - set->insert(adjusted_symbol_address); - } - return true; - } - - /// Populate the symbol map by extracting the exported symbols from a - /// ksymtab rela section. - /// - /// @param section the ksymtab section to read from - /// - /// @param exported_fns_set the set of exported functions - /// - /// @param exported_vars_set the set of exported variables - /// - /// @return true upon successful completion, false otherwise. - bool - populate_symbol_map_from_ksymtab_reloc(Elf_Scn *reloc_section, - address_set_sptr exported_fns_set, - address_set_sptr exported_vars_set) - { - GElf_Shdr reloc_section_mem; - GElf_Shdr *reloc_section_shdr = gelf_getshdr(reloc_section, - &reloc_section_mem); - size_t reloc_count = - reloc_section_shdr->sh_size / reloc_section_shdr->sh_entsize; - - Elf_Data *reloc_section_data = elf_getdata(reloc_section, 0); - - bool is_relasec = (reloc_section_shdr->sh_type == SHT_RELA); - elf_symbol_sptr symbol; - GElf_Sym native_symbol; - for (unsigned int i = 0; i < reloc_count; i++) - { - if (is_relasec) - { - GElf_Rela rela; - gelf_getrela(reloc_section_data, i, &rela); - symbol = lookup_elf_symbol_from_index(GELF_R_SYM(rela.r_info), - native_symbol); - } - else - { - GElf_Rel rel; - gelf_getrel(reloc_section_data, i, &rel); - symbol = lookup_elf_symbol_from_index(GELF_R_SYM(rel.r_info), - native_symbol); - } - - ABG_ASSERT(symbol); - - // If the symbol is a linux string constant then ignore it. - if (symbol->get_is_linux_string_cst()) - continue; - - if (!symbol->is_function() && !symbol->is_variable()) - { - if (do_log()) - { - if (symbol->get_type() == elf_symbol::NOTYPE_TYPE) - cerr << "skipping NOTYPE symbol " - << symbol->get_name() - << " shndx: " - << symbol->get_index() - << " @" - << elf_path() - << "\n"; - else if (symbol->get_type() == elf_symbol::SECTION_TYPE) - cerr << "skipping SECTION symbol " - << "shndx: " - << symbol->get_index() - << " @" - << elf_path() - << "\n"; - } - continue; - } - - // If the symbol was suppressed by a suppression - // specification then drop it on the floor. - if (is_elf_symbol_suppressed(symbol)) - continue; - - // If we are looking at an ET_REL (relocatable) binary, then - // the symbol value of native_symbol is relative to the - // section that symbol is defined in. We need to translate it - // into an absolute (okay, binary-relative, rather) address. - GElf_Addr symbol_address = - maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle(), - &native_symbol); - - address_set_sptr set; - if (symbol->is_function()) - { - ABG_ASSERT(lookup_elf_fn_symbol_from_address(symbol_address)); - set = exported_fns_set; - } - else if (symbol->is_variable()) - { - ABG_ASSERT(lookup_elf_var_symbol_from_address(symbol_address)); - set = exported_vars_set; - } - else - ABG_ASSERT_NOT_REACHED; - set->insert(symbol_address); - } - return true; - } - - /// Load a given kernel symbol table. - /// - /// One can thus retrieve the resulting symbols by using the - /// accessors read_context::linux_exported_fn_syms(), - /// read_context::linux_exported_var_syms(), - /// read_context::linux_exported_gpl_fn_syms(), or - /// read_context::linux_exported_gpl_var_syms(). - /// - /// @param kind the kind of kernel symbol table to load. - /// - /// @return true upon successful completion, false otherwise. - bool - load_kernel_symbol_table(kernel_symbol_table_kind kind) - { - Elf_Scn *section = 0, *reloc_section = 0; - address_set_sptr linux_exported_fns_set, linux_exported_vars_set; - - switch (kind) - { - case KERNEL_SYMBOL_TABLE_KIND_UNDEFINED: - break; - case KERNEL_SYMBOL_TABLE_KIND_KSYMTAB: - section = find_ksymtab_section(); - reloc_section = find_ksymtab_reloc_section(); - linux_exported_fns_set = create_or_get_linux_exported_fn_syms(); - linux_exported_vars_set = create_or_get_linux_exported_var_syms(); - break; - case KERNEL_SYMBOL_TABLE_KIND_KSYMTAB_GPL: - section = find_ksymtab_gpl_section(); - reloc_section = find_ksymtab_gpl_reloc_section(); - linux_exported_fns_set = create_or_get_linux_exported_gpl_fn_syms(); - linux_exported_vars_set = create_or_get_linux_exported_gpl_var_syms(); - break; - } - - if (!linux_exported_vars_set || !linux_exported_fns_set || !section) - return false; - - ksymtab_format format = get_ksymtab_format(); - - // Although pre-v4.19 kernel modules can have a relocation section for the - // __ksymtab section, libdwfl zeroes the rela section after applying - // "simple" absolute relocations via dwfl_module_getelf(). For v4.19 and - // above, we get PC-relative relocations so dwfl_module_getelf() doesn't - // apply those relocations and we're safe to read the relocation section to - // determine which exported symbols are in the ksymtab. - if (!reloc_section || format == PRE_V4_19_KSYMTAB_FORMAT) - { - size_t nb_entries = 0; - if (kind == KERNEL_SYMBOL_TABLE_KIND_KSYMTAB) - nb_entries = get_nb_ksymtab_entries(); - else if (kind == KERNEL_SYMBOL_TABLE_KIND_KSYMTAB_GPL) - nb_entries = get_nb_ksymtab_gpl_entries(); - - if (!nb_entries) - return false; - - return populate_symbol_map_from_ksymtab( - section, linux_exported_fns_set, linux_exported_vars_set, - nb_entries); - } - else - return populate_symbol_map_from_ksymtab_reloc(reloc_section, - linux_exported_fns_set, - linux_exported_vars_set); - } - - /// Load the special __ksymtab section. This is for linux kernel - /// (module) files. - /// - /// @return true upon successful completion, false otherwise. - bool - load_ksymtab_symbols() - { - return load_kernel_symbol_table(KERNEL_SYMBOL_TABLE_KIND_KSYMTAB); - } - - /// Load the special __ksymtab_gpl section. This is for linux kernel - /// (module) files. - /// - /// @return true upon successful completion, false otherwise. - bool - load_ksymtab_gpl_symbols() - { - return load_kernel_symbol_table(KERNEL_SYMBOL_TABLE_KIND_KSYMTAB_GPL); - } - - /// Load linux kernel (module) specific exported symbol sections. - /// - /// @return true upon successful completion, false otherwise. - bool - load_linux_specific_exported_symbol_maps() - { - bool loaded = false; - if (!linux_exported_fn_syms_ - || !linux_exported_var_syms_) - loaded |= load_ksymtab_symbols(); - - if (!linux_exported_gpl_fn_syms_ - || !linux_exported_gpl_var_syms_) - loaded |= load_ksymtab_gpl_symbols(); - - return loaded; - } - /// Load the maps of function symbol address -> function symbol, /// global variable symbol address -> variable symbol and also the /// maps of function and variable undefined symbols. @@ -7120,11 +6053,7 @@ public: load_var_map, load_undefined_fun_map, load_undefined_var_map)) - { - if (load_in_linux_kernel_mode() && is_linux_kernel(elf_handle())) - return load_linux_specific_exported_symbol_maps(); return true; - } return false; } return true; @@ -7204,36 +6133,6 @@ public: load_elf_architecture(); } - /// Convert the value of the symbol address part of a post V4.19 - /// ksymtab entry (that contains place-relative addresses) into its - /// corresponding symbol value in the .symtab section. The value of - /// the symbol in .symtab equals to addr_offset + address-of-ksymtab - /// + addr. - /// - /// @param addr the address read from the ksymtab section. - /// - /// @param addr_offset the offset at which @p addr was read. - /// - /// @param ksymtab_section the kymstab section @p addr was read - /// from. - GElf_Addr - maybe_adjust_sym_address_from_v4_19_ksymtab(GElf_Addr addr, - size_t addr_offset, - Elf_Scn *ksymtab_section) const - { - GElf_Addr result = addr; - - if (get_ksymtab_format() == V4_19_KSYMTAB_FORMAT) - { - int32_t offset = addr; - GElf_Shdr mem; - GElf_Shdr *section_header = gelf_getshdr(ksymtab_section, &mem); - result = offset + section_header->sh_addr + addr_offset; - } - - return result; - } - /// This is a sub-routine of maybe_adjust_fn_sym_address and /// maybe_adjust_var_sym_address. /// @@ -15903,34 +14802,6 @@ build_function_decl(read_context& ctxt, return result; } -/// Add a set of addresses (representing function symbols) to a -/// function symbol name -> symbol map. -/// -/// For a given symbol address, the function retrieves the name of the -/// symbol as well as the symbol itself and inserts an entry {symbol -/// name, symbol} into a map of symbol name -> symbol map. -/// -/// @param syms the set of symbol addresses to consider. -/// -/// @param map the map to populate. -/// -/// @param ctxt the context in which we are loading a given ELF file. -static void -add_fn_symbols_to_map(address_set_type& syms, - string_elf_symbols_map_type& map, - read_context& ctxt) -{ - for (address_set_type::iterator i = syms.begin(); i != syms.end(); ++i) - { - elf_symbol_sptr sym = ctxt.lookup_elf_fn_symbol_from_address(*i); - ABG_ASSERT(sym); - string_elf_symbols_map_type::iterator it = - ctxt.fun_syms().find(sym->get_name()); - ABG_ASSERT(it != ctxt.fun_syms().end()); - map.insert(*it); - } -} - /// Add a symbol to a symbol map. /// /// @param sym the symbol to add. @@ -15954,34 +14825,6 @@ add_symbol_to_map(const elf_symbol_sptr& sym, it->second.push_back(sym); } -/// Add a set of addresses (representing variable symbols) to a -/// variable symbol name -> symbol map. -/// -/// For a given symbol address, the variable retrieves the name of the -/// symbol as well as the symbol itself and inserts an entry {symbol -/// name, symbol} into a map of symbol name -> symbol map. -/// -/// @param syms the set of symbol addresses to consider. -/// -/// @param map the map to populate. -/// -/// @param ctxt the context in which we are loading a given ELF file. -static void -add_var_symbols_to_map(address_set_type& syms, - string_elf_symbols_map_type& map, - read_context& ctxt) -{ - for (address_set_type::iterator i = syms.begin(); i != syms.end(); ++i) - { - elf_symbol_sptr sym = ctxt.lookup_elf_var_symbol_from_address(*i); - ABG_ASSERT(sym); - string_elf_symbols_map_type::iterator it = - ctxt.var_syms().find(sym->get_name()); - ABG_ASSERT(it != ctxt.var_syms().end()); - map.insert(*it); - } -} - /// Read all @ref abigail::translation_unit possible from the debug info /// accessible through a DWARF Front End Library handle, and stuff /// them into a libabigail ABI Corpus. @@ -16025,22 +14868,26 @@ read_debug_info_into_corpus(read_context& ctxt) { string_elf_symbols_map_sptr exported_fn_symbols_map (new string_elf_symbols_map_type); - add_fn_symbols_to_map(*ctxt.linux_exported_fn_syms(), - *exported_fn_symbols_map, - ctxt); - add_fn_symbols_to_map(*ctxt.linux_exported_gpl_fn_syms(), - *exported_fn_symbols_map, - ctxt); + auto filter = ctxt.symtab()->make_filter(); + filter.set_functions(); + + for (const auto& symbol : + symtab_reader::filtered_symtab(*ctxt.symtab(), filter)) + { + (*exported_fn_symbols_map)[symbol->get_name()].push_back(symbol); + } + ctxt.current_corpus()->set_fun_symbol_map(exported_fn_symbols_map); - string_elf_symbols_map_sptr exported_var_symbols_map - (new string_elf_symbols_map_type); - add_var_symbols_to_map(*ctxt.linux_exported_var_syms(), - *exported_var_symbols_map, - ctxt); - add_var_symbols_to_map(*ctxt.linux_exported_gpl_var_syms(), - *exported_var_symbols_map, - ctxt); + string_elf_symbols_map_sptr exported_var_symbols_map( + new string_elf_symbols_map_type); + filter = ctxt.symtab()->make_filter(); + filter.set_variables(); + for (const auto& symbol : + symtab_reader::filtered_symtab(*ctxt.symtab(), filter)) + { + (*exported_var_symbols_map)[symbol->get_name()].push_back(symbol); + } ctxt.current_corpus()->set_var_symbol_map(exported_var_symbols_map); } else From patchwork Wed Jan 27 12:58:45 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: 41846 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 984033972827; Wed, 27 Jan 2021 12:59:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 984033972827 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752377; bh=BB7rkhQWHrLI3ZRS7W2Gfg1lpUdW13Q1RJames8VjK0=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=pHsuytpr8nSJHdnqSBQxCZyKGxAvlRMASSCoTrdxMu3Lpe0tzc4kPHkxq7XNZj81g GQFpYqlXtufe6J7JNHaxPF3IO4q9+qK14iFsV4KK7fa3y2WkG1VZUposC4+avmxoaw KUILkxeiUnuS8jKOoBdeBDwK3rnPrKslaYgrTA9k= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by sourceware.org (Postfix) with ESMTPS id 1AE6C3972827 for ; Wed, 27 Jan 2021 12:59:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 1AE6C3972827 Received: by mail-wr1-x449.google.com with SMTP id n14so910107wru.6 for ; Wed, 27 Jan 2021 04:59:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=BB7rkhQWHrLI3ZRS7W2Gfg1lpUdW13Q1RJames8VjK0=; b=fEGC6awxtgPi9JzioDrNPZXHc6/fhABDuubQiSaRRUYtp9raSwc2/8lg+EPDFqi7t0 gco1B2ZLj41Ybd2xlwCQnHpnVFRPx8Fav77WNE3MfUmG/ZfNeILTaktgrwYNxhruaRVZ unv1DbsnZjCtCv77gJSHHnLcLW1BjA/B+ZkctQIwykdNKRgJ82eHKPk/9J42j40ziAnB SnVHNQVhNafjGygN76E3wz+R2Ej6mj5gdrBmzEOYkBVi6ZsCADgx8wwmwXm0YI/Hmpt0 gfI7BWwXs5PgLozoxE0DwnIsid9VeAwShRKfHLrbfWstgQ+mOxdoC/LaSd1CzFw9gmEm fpdg== X-Gm-Message-State: AOAM532llNbb8eA14bTSDV9Tusj80O2pM78HsWl6y3Ur3hwhSs39wkhf Zr/XM3VoG42AhIzZ3X5+a0pilelFYghsrRAPSTwiOoW63rRhgcq8CrtLKVgKuE3TgqqwU2HBJLy jCF738Dam6SqwHPJi1oBEOYz1KhIfal1Xt8Ajcj/mqFwCkWcRsnnwB/mS/MYS2s1wvqLy9x8= X-Google-Smtp-Source: ABdhPJx98fcbZ+REFVEnqOQmYeUUrankvlkvSwJR8KXCMgDQiqqKv0eiSlm/rT1Dr5dms9Y8YJu7SpfGZiI6ZQ== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a05:600c:258:: with SMTP id 24mr4091531wmj.161.1611752373182; Wed, 27 Jan 2021 04:59:33 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:45 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-13-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 12/20] abg-elf-helpers: migrate ppc64 specific helpers To: libabigail@sourceware.org X-Spam-Status: No, score=-23.2 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" This migrates more helpers to abg-elf-helpers: lookup_ppc64_elf_fn_entry_point_address with dependencies read_uint64_from_array_of_bytes read_int_from_array_of_bytes address_is_in_opd_section with dependency address_is_in_section read_context::find_opd_section and read_context::opd_section_ are obsolete. * src/abg-dwarf-reader.cc (read_context::opd_section_): Delete. (read_context::find_opd_section): Delete. (read_context::read_uint64_from_array_of_bytes): Delete. (read_context::read_int_from_array_of_bytes): Delete. (read_context::lookup_ppc64_elf_fn_entry_point_address): Delete. (read_context::address_is_in_opd_section): Delete. (read_context::address_is_in_section): Delete. (read_context::load_symbol_maps_from_symtab_section): Adjust. * src/abg-elf-helpers.cc (read_int_from_array_of_bytes): New. (read_uint64_from_array_of_bytes): New. (lookup_ppc64_elf_fn_entry_point_address): New. (address_is_in_section): New. (address_is_in_opd_section): New. * src/abg-elf-helpers.h (lookup_ppc64_elf_fn_entry_point_address): New declaration. (address_is_in_opd_section): New declaration. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 208 +--------------------------------------- src/abg-elf-helpers.cc | 186 +++++++++++++++++++++++++++++++++++ src/abg-elf-helpers.h | 8 ++ 3 files changed, 198 insertions(+), 204 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 693fae82040e..b2a7144afe9d 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -2141,10 +2141,6 @@ public: mutable Elf* elf_handle_; string elf_path_; mutable Elf_Scn* symtab_section_; - // The "Official procedure descriptor section, aka .opd", used in - // ppc64 elf v1 binaries. This section contains the procedure - // descriptors on that platform. - mutable Elf_Scn* opd_section_; Dwarf_Die* cur_tu_die_; mutable dwarf_expr_eval_context dwarf_expr_eval_context_; // A set of maps (one per kind of die source) that associates a decl @@ -2325,7 +2321,6 @@ public: elf_handle_ = 0; elf_path_ = elf_path; symtab_section_ = 0; - opd_section_ = 0; cur_tu_die_ = 0; exported_decls_builder_ = 0; @@ -5312,19 +5307,6 @@ public: return symtab_section_; } - /// Return the "Official Procedure descriptors section." This - /// section is named .opd, and is usually present only on PPC64 - /// ELFv1 binaries. - /// - /// @return the .opd section, if found. Return nil otherwise. - Elf_Scn* - find_opd_section() const - { - if (!opd_section_) - opd_section_ = elf_helpers::find_opd_section(elf_handle()); - return opd_section_; - } - /// Lookup an elf symbol, referred to by its index, from the .symtab /// section. /// @@ -5436,152 +5418,6 @@ public: return sym; } - /// Read 8 bytes and convert their value into an uint64_t. - /// - /// @param bytes the array of bytes to read the next 8 bytes from. - /// Note that this array must be at least 8 bytes long. - /// - /// @param result where to store the resuting uint64_t that was read. - /// - /// @param is_big_endian if true, read the 8 bytes in Big Endian - /// mode, otherwise, read them in Little Endian. - /// - /// @param true if the 8 bytes could be read, false otherwise. - bool - read_uint64_from_array_of_bytes(const uint8_t *bytes, - bool is_big_endian, - uint64_t &result) const - { - return read_int_from_array_of_bytes(bytes, 8, is_big_endian, result); - } - - /// Read N bytes and convert their value into an integer type T. - /// - /// Note that N cannot be bigger than 8 for now. The type passed needs to be - /// at least of the size of number_of_bytes. - /// - /// @param bytes the array of bytes to read the next 8 bytes from. - /// Note that this array must be at least 8 bytes long. - /// - /// @param number_of_bytes the number of bytes to read. This number - /// cannot be bigger than 8. - /// - /// @param is_big_endian if true, read the 8 bytes in Big Endian - /// mode, otherwise, read them in Little Endian. - /// - /// @param result where to store the resuting integer that was read. - /// - /// - /// @param true if the 8 bytes could be read, false otherwise. - template - bool - read_int_from_array_of_bytes(const uint8_t *bytes, - unsigned char number_of_bytes, - bool is_big_endian, - T &result) const - { - if (!bytes) - return false; - - ABG_ASSERT(number_of_bytes <= 8); - ABG_ASSERT(number_of_bytes <= sizeof(T)); - - T res = 0; - - const uint8_t *cur = bytes; - if (is_big_endian) - { - // In Big Endian, the most significant byte is at the lowest - // address. - const uint8_t* msb = cur; - res = *msb; - - // Now read the remaining least significant bytes. - for (uint i = 1; i < number_of_bytes; ++i) - res = (res << 8) | ((T)msb[i]); - } - else - { - // In Little Endian, the least significant byte is at the - // lowest address. - const uint8_t* lsb = cur; - res = *lsb; - // Now read the remaining most significant bytes. - for (uint i = 1; i < number_of_bytes; ++i) - res = res | (((T)lsb[i]) << i * 8); - } - - result = res; - return true; - } - - /// Lookup the address of the function entry point that corresponds - /// to the address of a given function descriptor. - /// - /// On PPC64, a function pointer is the address of a function - /// descriptor. Function descriptors are located in the .opd - /// section. Each function descriptor is a triplet of three - /// addresses, each one on 64 bits. Among those three address only - /// the first one is of any interest to us: the address of the entry - /// point of the function. - /// - /// This function returns the address of the entry point of the - /// function whose descriptor's address is given. - /// - /// http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES - /// - /// https://www.ibm.com/developerworks/community/blogs/5894415f-be62-4bc0-81c5-3956e82276f3/entry/deeply_understand_64_bit_powerpc_elf_abi_function_descriptors?lang=en - /// - /// @param fn_desc_address the address of the function descriptor to - /// consider. - /// - /// @return the address of the entry point of the function whose - /// descriptor has the address @p fn_desc_address. If there is no - /// .opd section (e.g because we are not on ppc64) or more generally - /// if the function descriptor could not be found then this function - /// just returns the address of the fuction descriptor. - GElf_Addr - lookup_ppc64_elf_fn_entry_point_address(GElf_Addr fn_desc_address) const - { - if (!elf_handle()) - return fn_desc_address; - - if (!architecture_is_ppc64(elf_handle())) - return fn_desc_address; - - bool is_big_endian = architecture_is_big_endian(elf_handle()); - - Elf_Scn *opd_section = find_opd_section(); - if (!opd_section) - return fn_desc_address; - - GElf_Shdr header_mem; - // The section header of the .opd section. - GElf_Shdr *opd_sheader = gelf_getshdr(opd_section, &header_mem); - - // The offset of the function descriptor entry, in the .opd - // section. - size_t fn_desc_offset = fn_desc_address - opd_sheader->sh_addr; - Elf_Data *elf_data = elf_rawdata(opd_section, 0); - - // Ensure that the opd_section has at least 8 bytes, starting from - // the offset we want read the data from. - if (elf_data->d_size <= fn_desc_offset + 8) - return fn_desc_address; - - // A pointer to the data of the .opd section, that we can actually - // do something with. - uint8_t * bytes = (uint8_t*) elf_data->d_buf; - - // The resulting address we are looking for is going to be formed - // in this variable. - GElf_Addr result = 0; - ABG_ASSERT(read_uint64_from_array_of_bytes(bytes + fn_desc_offset, - is_big_endian, result)); - - return result; - } - /// Test if a given function symbol has been exported. /// /// @param symbol_address the address of the symbol we are looking @@ -5890,13 +5726,15 @@ 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(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); if (it2 == fun_entry_addr_sym_map().end()) fun_entry_addr_sym_map()[fn_entry_point_addr] = symbol; - else if (address_is_in_opd_section(fn_desc_addr)) + else if (address_is_in_opd_section(elf_handle(), + fn_desc_addr)) { // Either // @@ -6059,24 +5897,6 @@ public: return true; } - /// Return true if an address is in the ".opd" section that is - /// present on the ppc64 platform. - /// - /// @param addr the address to consider. - /// - /// @return true iff @p addr is designates a word that is in the - /// ".opd" section. - bool - address_is_in_opd_section(Dwarf_Addr addr) - { - Elf_Scn * opd_section = find_opd_section(); - if (!opd_section) - return false; - if (address_is_in_section(addr, opd_section)) - return true; - return false; - } - /// Load the symbol maps if necessary. /// /// @return true iff the symbol maps has been loaded by this @@ -6227,26 +6047,6 @@ public: return addr; } - /// Test if a given address is in a given section. - /// - /// @param addr the address to consider. - /// - /// @param section the section to consider. - bool - address_is_in_section(Dwarf_Addr addr, Elf_Scn* section) const - { - if (!section) - return false; - - GElf_Shdr sheader_mem; - GElf_Shdr* sheader = gelf_getshdr(section, &sheader_mem); - - if (sheader->sh_addr <= addr && addr <= sheader->sh_addr + sheader->sh_size) - return true; - - return false; - } - /// 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} diff --git a/src/abg-elf-helpers.cc b/src/abg-elf-helpers.cc index 5130e5b64f7a..fb9f3af67bfc 100644 --- a/src/abg-elf-helpers.cc +++ b/src/abg-elf-helpers.cc @@ -848,6 +848,153 @@ architecture_is_big_endian(Elf* elf_handle) return is_big_endian; } +/// Read N bytes and convert their value into an integer type T. +/// +/// Note that N cannot be bigger than 8 for now. The type passed needs to be at +/// least of the size of number_of_bytes. +/// +/// @param bytes the array of bytes to read the next 8 bytes from. +/// Note that this array must be at least 8 bytes long. +/// +/// @param number_of_bytes the number of bytes to read. This number +/// cannot be bigger than 8. +/// +/// @param is_big_endian if true, read the 8 bytes in Big Endian +/// mode, otherwise, read them in Little Endian. +/// +/// @param result where to store the resuting integer that was read. +/// +/// +/// @param true if the 8 bytes could be read, false otherwise. +template +bool +read_int_from_array_of_bytes(const uint8_t* bytes, + unsigned char number_of_bytes, + bool is_big_endian, + T& result) +{ + if (!bytes) + return false; + + ABG_ASSERT(number_of_bytes <= 8); + ABG_ASSERT(number_of_bytes <= sizeof(T)); + + T res = 0; + + const uint8_t* cur = bytes; + if (is_big_endian) + { + // In Big Endian, the most significant byte is at the lowest + // address. + const uint8_t* msb = cur; + res = *msb; + + // Now read the remaining least significant bytes. + for (uint i = 1; i < number_of_bytes; ++i) + res = (res << 8) | ((T)msb[i]); + } + else + { + // In Little Endian, the least significant byte is at the + // lowest address. + const uint8_t* lsb = cur; + res = *lsb; + // Now read the remaining most significant bytes. + for (uint i = 1; i < number_of_bytes; ++i) + res = res | (((T)lsb[i]) << i * 8); + } + + result = res; + return true; +} + +/// Read 8 bytes and convert their value into an uint64_t. +/// +/// @param bytes the array of bytes to read the next 8 bytes from. +/// Note that this array must be at least 8 bytes long. +/// +/// @param result where to store the resuting uint64_t that was read. +/// +/// @param is_big_endian if true, read the 8 bytes in Big Endian +/// mode, otherwise, read them in Little Endian. +/// +/// @param true if the 8 bytes could be read, false otherwise. +bool +read_uint64_from_array_of_bytes(const uint8_t* bytes, + bool is_big_endian, + uint64_t& result) +{ + return read_int_from_array_of_bytes(bytes, 8, is_big_endian, result); +} + + +/// Lookup the address of the function entry point that corresponds +/// to the address of a given function descriptor. +/// +/// On PPC64, a function pointer is the address of a function +/// descriptor. Function descriptors are located in the .opd +/// section. Each function descriptor is a triplet of three +/// addresses, each one on 64 bits. Among those three address only +/// the first one is of any interest to us: the address of the entry +/// point of the function. +/// +/// This function returns the address of the entry point of the +/// function whose descriptor's address is given. +/// +/// http://refspecs.linuxfoundation.org/ELF/ppc64/PPC-elf64abi.html#FUNC-DES +/// +/// https://www.ibm.com/developerworks/community/blogs/5894415f-be62-4bc0-81c5-3956e82276f3/entry/deeply_understand_64_bit_powerpc_elf_abi_function_descriptors?lang=en +/// +/// @param fn_desc_address the address of the function descriptor to +/// consider. +/// +/// @return the address of the entry point of the function whose +/// descriptor has the address @p fn_desc_address. If there is no +/// .opd section (e.g because we are not on ppc64) or more generally +/// if the function descriptor could not be found then this function +/// just returns the address of the fuction descriptor. +GElf_Addr +lookup_ppc64_elf_fn_entry_point_address(Elf* elf_handle, GElf_Addr fn_desc_address) +{ + if (!elf_handle) + return fn_desc_address; + + if (!architecture_is_ppc64(elf_handle)) + return fn_desc_address; + + bool is_big_endian = architecture_is_big_endian(elf_handle); + + Elf_Scn* opd_section = find_opd_section(elf_handle); + if (!opd_section) + return fn_desc_address; + + GElf_Shdr header_mem; + // The section header of the .opd section. + GElf_Shdr* opd_sheader = gelf_getshdr(opd_section, &header_mem); + + // The offset of the function descriptor entry, in the .opd + // section. + size_t fn_desc_offset = fn_desc_address - opd_sheader->sh_addr; + Elf_Data* elf_data = elf_rawdata(opd_section, 0); + + // Ensure that the opd_section has at least 8 bytes, starting from + // the offset we want read the data from. + if (elf_data->d_size <= fn_desc_offset + 8) + return fn_desc_address; + + // A pointer to the data of the .opd section, that we can actually + // do something with. + uint8_t* bytes = (uint8_t*)elf_data->d_buf; + + // The resulting address we are looking for is going to be formed + // in this variable. + GElf_Addr result = 0; + ABG_ASSERT(read_uint64_from_array_of_bytes(bytes + fn_desc_offset, + is_big_endian, result)); + + return result; +} + /// Test if the ELF binary denoted by a given ELF handle is a Linux /// Kernel Module. /// @@ -1012,5 +1159,44 @@ maybe_adjust_et_rel_sym_addr_to_abs_addr(Elf* elf_handle, GElf_Sym* sym) return addr + section_header.sh_addr; } +/// Test if a given address is in a given section. +/// +/// @param addr the address to consider. +/// +/// @param section the section to consider. +bool +address_is_in_section(Dwarf_Addr addr, Elf_Scn* section) +{ + if (!section) + return false; + + GElf_Shdr sheader_mem; + GElf_Shdr* sheader = gelf_getshdr(section, &sheader_mem); + + if (sheader->sh_addr <= addr && addr <= sheader->sh_addr + sheader->sh_size) + return true; + + return false; +} + +/// Return true if an address is in the ".opd" section that is +/// present on the ppc64 platform. +/// +/// @param addr the address to consider. +/// +/// @return true iff @p addr is designates a word that is in the +/// ".opd" section. +bool +address_is_in_opd_section(Elf* elf_handle, Dwarf_Addr addr) +{ + Elf_Scn * opd_section = find_opd_section(elf_handle); + if (!opd_section) + return false; + if (address_is_in_section(addr, opd_section)) + return true; + return false; +} + + } // end namespace elf_helpers } // end namespace abigail diff --git a/src/abg-elf-helpers.h b/src/abg-elf-helpers.h index b4f3293d2bd6..a06232738052 100644 --- a/src/abg-elf-helpers.h +++ b/src/abg-elf-helpers.h @@ -12,6 +12,7 @@ #include "config.h" +#include #include #include @@ -133,6 +134,10 @@ architecture_is_ppc64(Elf* elf_handle); bool architecture_is_big_endian(Elf* elf_handle); +GElf_Addr +lookup_ppc64_elf_fn_entry_point_address(Elf* elf_handle, + GElf_Addr fn_desc_address); + // // Helpers for Linux Kernel Binaries // @@ -162,6 +167,9 @@ is_dso(Elf* elf_handle); GElf_Addr maybe_adjust_et_rel_sym_addr_to_abs_addr(Elf* elf_handle, GElf_Sym* sym); +bool +address_is_in_opd_section(Elf* elf_handle, Dwarf_Addr addr); + } // end namespace elf_helpers } // end namespace abigail From patchwork Wed Jan 27 12:58:46 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: 41847 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 DC6CF397303B; Wed, 27 Jan 2021 12:59:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DC6CF397303B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752377; bh=3UNTVFfJXRA44mQ6KDmlIB5otHyQCbI6yIrMyf/LedE=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=V0Rj94t6GtC8poK7YwV1RMRu0vXMtE8oT32i/F6CAYz9emYUvWrKeozzfLkUzG6/C epIelUlgs5asiIlRyGp/ojld6Zn/0f0wYpK9LZvRaPJ5r6W9Vcp+d8PF0I7he+ob7V fGy/plIJW91wvqAMKDyT+BegTmHzeoI9vvtE9/pk= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by sourceware.org (Postfix) with ESMTPS id 99323397282F for ; Wed, 27 Jan 2021 12:59:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 99323397282F Received: by mail-qk1-x74a.google.com with SMTP id 185so1379900qkl.6 for ; Wed, 27 Jan 2021 04:59:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=3UNTVFfJXRA44mQ6KDmlIB5otHyQCbI6yIrMyf/LedE=; b=uiABgXxlBsq9cymZQLP9ezeN0db0w6jW7jC7qya1U9vTjKwa8Lfxjzgcjxw7fVRmDv QGAHeweJOc+Vmezf3y9XzD8tDj5/KqZytRHRDJ9In8pvSmEwC+sRpnUiUTCjbKvbtG1C NGsca8uq4KaSB2GmNOwj4r+bxUW5KQsSKsPeIL6ddkwwLLEnb5trBO720SMqO5Z/rJ2F 4l8Eu1CCXP162t5wF+YRJFZ5scQEbN6kE3BLrJa/B5jBGpa2TTv5VTlrKOIGeqZGmFW2 nutRmGSYo6140p+352/EnUMFv0ztTPIxEwkwGmVb3jPZ3jvViHNrI/utAba4yclkG5Mc UudQ== X-Gm-Message-State: AOAM531ZnT0bc6rP9i3sOCl0W7TlrZmxR/iBinDCjvbkNCo8/Ti039bz p6lyz0fwPk/uiLh/3i/1uaI55sjgYaBFOK9Zgg7XngroHND5A4Iaf9fNtL9etKZ+EiFHr9k5cae WGAT/ohlF8pTb43O0i5a65q0CJwbthPtp4n0Q5Bz7r7CzuR1vFBdzjc/Ifsf0qdvGwGdjP4Y= X-Google-Smtp-Source: ABdhPJxYuxxLiAVlEtkXMdamB32SLtd4wIgLV3Bf0dEGOh84RVYixeEDlhnCbm+9CUMEUyrxIEs16v1Qwy1QrA== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:b409:: with SMTP id u9mr10322770qve.51.1611752375149; Wed, 27 Jan 2021 04:59:35 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:46 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-14-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 13/20] symtab_reader: add support for ppc64 ELFv1 binaries To: libabigail@sourceware.org X-Spam-Status: No, score=-22.8 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" When loading the symtab from an ppc64 binary, also keep track of the function entry addresses as a key for the symbol lookup. That accommodates the differences in DWARF pointing to the function entry address while the symbol table points to the function pointer. The implementation is mostly copied and adopted from abg-dwarf-reader's read_context to add this functionality also to the new symtab reader. * src/abg-symtab-reader.cc (symtab::lookup_symbol): fall back to lookup the address in entry_addr_symbol_map_. (symtab::load): update the function entry address map for ppc64 targets. (symtab::update_function_entry_address_symbol_map): New function implementation. * src/abg-symtab-reader.h (symtab::entry_addr_symbol_map_): New data member. (symtab::update_function_entry_address_symbol_map): New function declaration. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-symtab-reader.cc | 93 ++++++++++++++++++++++++++++++++++++++-- src/abg-symtab-reader.h | 8 ++++ 2 files changed, 98 insertions(+), 3 deletions(-) diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc index 4576be2a0b42..7318fdfce52e 100644 --- a/src/abg-symtab-reader.cc +++ b/src/abg-symtab-reader.cc @@ -100,9 +100,15 @@ const elf_symbol_sptr& symtab::lookup_symbol(GElf_Addr symbol_addr) const { static const elf_symbol_sptr empty_result; - const auto it = addr_symbol_map_.find(symbol_addr); - if (it != addr_symbol_map_.end()) - return it->second; + const auto addr_it = addr_symbol_map_.find(symbol_addr); + if (addr_it != addr_symbol_map_.end()) + return addr_it->second; + else + { + const auto entry_it = entry_addr_symbol_map_.find(symbol_addr); + if (entry_it != entry_addr_symbol_map_.end()) + return entry_it->second; + } return empty_result; } @@ -197,6 +203,8 @@ 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_ppc64 = elf_helpers::architecture_is_ppc64(elf_handle); + for (size_t i = 0; i < number_syms; ++i) { GElf_Sym *sym, sym_mem; @@ -304,6 +312,10 @@ 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); + const auto result = addr_symbol_map_.emplace(symbol_value, symbol_sptr); if (!result.second) @@ -364,5 +376,80 @@ symtab::load_(string_elf_symbols_map_sptr function_symbol_map, return true; } +void +symtab::update_function_entry_address_symbol_map( + 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, + fn_desc_addr); + + const std::pair& result = + entry_addr_symbol_map_.emplace(fn_entry_point_addr, symbol_sptr); + + const addr_symbol_map_type::const_iterator it = result.first; + const bool was_inserted = result.second; + if (!was_inserted + && elf_helpers::address_is_in_opd_section(elf_handle, fn_desc_addr)) + { + // Either + // + // 'symbol' must have been registered as an alias for + // it->second->get_main_symbol() + // + // Or + // + // if the name of 'symbol' is foo, then the name of it2->second is + // ".foo". That is, foo is the name of the symbol when it refers to the + // function descriptor in the .opd section and ".foo" is an internal name + // for the address of the entry point of foo. + // + // In the latter case, we just want to keep a reference to "foo" as .foo + // is an internal name. + + const bool two_symbols_alias = + it->second->get_main_symbol()->does_alias(*symbol_sptr); + const bool symbol_is_foo_and_prev_symbol_is_dot_foo = + (it->second->get_name() == std::string(".") + symbol_sptr->get_name()); + + ABG_ASSERT(two_symbols_alias + || symbol_is_foo_and_prev_symbol_is_dot_foo); + + if (symbol_is_foo_and_prev_symbol_is_dot_foo) + // Let's just keep a reference of the symbol that the user sees in the + // source code (the one named foo). The symbol which name is prefixed + // with a "dot" is an artificial one. + entry_addr_symbol_map_[fn_entry_point_addr] = symbol_sptr; + } +} + } // end namespace symtab_reader } // end namespace abigail diff --git a/src/abg-symtab-reader.h b/src/abg-symtab-reader.h index 4c5e3b85c22d..2906bab818b0 100644 --- a/src/abg-symtab-reader.h +++ b/src/abg-symtab-reader.h @@ -251,12 +251,20 @@ private: typedef std::unordered_map addr_symbol_map_type; addr_symbol_map_type addr_symbol_map_; + /// Lookup map function entry address -> symbol + addr_symbol_map_type entry_addr_symbol_map_; + bool load_(Elf* elf_handle, ir::environment* env, symbol_predicate is_suppressed); bool load_(string_elf_symbols_map_sptr function_symbol_map, string_elf_symbols_map_sptr variables_symbol_map); + + void + update_function_entry_address_symbol_map(Elf* elf_handle, + GElf_Sym* native_symbol, + const elf_symbol_sptr& symbol_sptr); }; /// Helper class to allow range-for loops on symtabs for C++11 and later code. From patchwork Wed Jan 27 12:58:47 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: 41848 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 C72683971C3C; Wed, 27 Jan 2021 12:59:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C72683971C3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752382; bh=mWWVwPNTlI0pdwpcwUXgN8kgRAkU+s+RqrD4jj3CqOc=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=Dw9oS5TFC0t+7YZQF03Vtb3dQBreFKJzd3B3ZhEB3Th0u9GyD7LxM24aFEPAKgskR QLKfwBrhovcb5Kzfk8Ne2TZboT/+JCzOuwgzfIZI3tOTQiZ6rgbeAJifZDhaHrUfun QMNiktypH4fcpzJCzvcVk3iER89au/n3NUvgk20c= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by sourceware.org (Postfix) with ESMTPS id AEA833973039 for ; Wed, 27 Jan 2021 12:59:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org AEA833973039 Received: by mail-wr1-x449.google.com with SMTP id z9so902062wro.11 for ; Wed, 27 Jan 2021 04:59:38 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mWWVwPNTlI0pdwpcwUXgN8kgRAkU+s+RqrD4jj3CqOc=; b=aZdthjDopUki0kWNugBFs9DXEGmBKVjqQ7Fg6mQC7lrdYf61e2absEeKT1CxqPuYHl ZYErr0uYX4yaHQEQDmmK0Wbur3tyi75qnP71+MIl5udQwG95V/SiEGHXPfSWoetM4/cA NU+BSKzLucZb1PN677O3mfbxVmxoHtha1/UwNUTnckAbD74xmMDXwoLkhXXW8PFyyh1i Pv4T45FbyQ11aEkpTlXv6ysEIqUYPmKmv/53hgKp6Ow7gMAGIZpfDYPro64C8FdrB3uS PiPAcEZPhIQbiGRu3LAFLfum8JgZn+34dsHHoMahGsHat465OSk8Rbg5OCU2WUh8Ff26 0TnQ== X-Gm-Message-State: AOAM530aMmje5SfAvwHvkcH6Q7yBZrPatfqbvP9JV4QAZW/wStJP+bfw AldU45uzTjQEaHQTwocsbt3c8yyfJZBDrYVN9qDc9e+AZ0laB2mOG3MabbBNrYm8mrfCyCY72D8 ebm8fH7hihxTyUSuI4nd5yp+kFTraAg5nSpGD6hFb+3T1TZx8vCvd4wjnsck0QNDec3XzV58= X-Google-Smtp-Source: ABdhPJyECQg5N0xNeNQhPwQqLUPleuC9cHdDwrcu/qyTMimCUxFO5WRc654EWwtHJYWAGO7cU2gWEuqWKL6Rcw== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:adf:dd81:: with SMTP id x1mr11145840wrl.249.1611752377518; Wed, 27 Jan 2021 04:59:37 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:47 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-15-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 14/20] abg-corpus: remove symbol maps and their setters To: libabigail@sourceware.org X-Spam-Status: No, score=-23.2 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" With the prework in previous commits, we are now able to drop the public symbols maps in corpus::priv and replace them by private members with access through getters. The getters use the new symtab implementation to generate the maps on the fly. Setters are not required anymore and are removed. Also remove redundant getters. We could also remove the getters for the symbol maps and the local caching variable and leave it all to lookup_symbol, but this is left for a later change. * include/abg-corpus.h (corpus::set_fun_symbol_map): Remove method declaration. (corpus::set_undefined_fun_symbol_map): Likewise. (corpus::set_var_symbol_map): Likewise. (corpus::set_undefined_var_symbol_map): Likewise. (corpus::get_fun_symbol_map_sptr): Likewise. (corpus::get_undefined_fun_symbol_map_sptr): Likewise. (corpus::get_var_symbol_map_sptr): Likewise. (corpus::get_undefined_var_symbol_map_sptr): Likewise. * src/abg-corpus-priv.h (corpus::priv::var_symbol_map): make private and mutable (corpus::priv::undefined_var_symbol_map): Likewise. (corpus::priv::fun_symbol_map): Likewise. (corpus::priv::undefined_fun_symbol_map): Likewise. (corpus::priv::get_fun_symbol_map): New method declaration. (corpus::priv::get_undefined_fun_symbol_map): Likewise. (corpus::priv::get_var_symbol_map): Likewise. (corpus::priv::get_undefined_var_symbol_map): Likewise. * src/abg-corpus.cc (corpus::priv::get_fun_symbol_map): New method implementation. (corpus::priv::get_undefined_fun_symbol_map): Likewise. (corpus::priv::get_var_symbol_map): Likewise. (corpus::priv::get_undefined_var_symbol_map): Likewise. (corpus::is_empty): depend on symtab only. (corpus::set_fun_symbol_map): Remove method. (corpus::set_undefined_fun_symbol_map): Likewise. (corpus::set_var_symbol_map): Likewise. (corpus::set_undefined_var_symbol_map): Likewise. (corpus::get_fun_symbol_map_sptr): Likewise. (corpus::get_undefined_fun_symbol_map_sptr): Likewise. (corpus::get_var_symbol_map_sptr): Likewise. (corpus::get_undefined_var_symbol_map_sptr): Likewise. (corpus::get_fun_symbol_map): Use corpus::priv proxy method. (corpus::get_undefined_fun_symbol_map): Likewise. (corpus::get_var_symbol_map): Likewise. (corpus::get_undefined_var_symbol_map): Likewise. * src/abg-dwarf-reader.cc (read_debug_info_into_corpus): Do not set corpus symbol maps anymore. * src/abg-reader.cc (read_corpus_from_input): Likewise. * tests/test-symtab.cc (assert_symbol_count): Do not access the corpus symbol maps through sptr anymore. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Adjust expected test output. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-corpus.h | 24 --- src/abg-corpus-priv.h | 21 ++- src/abg-corpus.cc | 139 +++++++----------- src/abg-dwarf-reader.cc | 45 ------ src/abg-reader.cc | 11 -- .../data/test-read-dwarf/PR25007-sdhci.ko.abi | 2 - tests/test-symtab.cc | 15 +- 7 files changed, 79 insertions(+), 178 deletions(-) diff --git a/include/abg-corpus.h b/include/abg-corpus.h index 425702182056..09f057d705f7 100644 --- a/include/abg-corpus.h +++ b/include/abg-corpus.h @@ -158,27 +158,9 @@ public: const symtab_reader::symtab_sptr& get_symtab() const; - void - set_fun_symbol_map(string_elf_symbols_map_sptr); - - void - set_undefined_fun_symbol_map(string_elf_symbols_map_sptr); - - void - set_var_symbol_map(string_elf_symbols_map_sptr); - - void - set_undefined_var_symbol_map(string_elf_symbols_map_sptr); - - const string_elf_symbols_map_sptr - get_fun_symbol_map_sptr() const; - virtual const string_elf_symbols_map_type& get_fun_symbol_map() const; - const string_elf_symbols_map_sptr - get_undefined_fun_symbol_map_sptr() const; - const string_elf_symbols_map_type& get_undefined_fun_symbol_map() const; @@ -188,15 +170,9 @@ public: const elf_symbols& get_sorted_undefined_fun_symbols() const; - const string_elf_symbols_map_sptr - get_var_symbol_map_sptr() const; - virtual const string_elf_symbols_map_type& get_var_symbol_map() const; - const string_elf_symbols_map_sptr - get_undefined_var_symbol_map_sptr() const; - const string_elf_symbols_map_type& get_undefined_var_symbol_map() const; diff --git a/src/abg-corpus-priv.h b/src/abg-corpus-priv.h index c8bf7f9d4cf6..27a6524c8b42 100644 --- a/src/abg-corpus-priv.h +++ b/src/abg-corpus-priv.h @@ -15,6 +15,7 @@ #define __ABG_CORPUS_PRIV_H__ #include "abg-internal.h" +#include "abg-ir.h" #include "abg-regex.h" #include "abg-sptr-utils.h" #include "abg-symtab-reader.h" @@ -681,11 +682,7 @@ struct corpus::priv string_tu_map_type path_tu_map; vector fns; vector vars; - string_elf_symbols_map_sptr var_symbol_map; - string_elf_symbols_map_sptr undefined_var_symbol_map; symtab_reader::symtab_sptr symtab_; - string_elf_symbols_map_sptr fun_symbol_map; - string_elf_symbols_map_sptr undefined_fun_symbol_map; // The type maps contained in this data member are populated if the // corpus follows the One Definition Rule and thus if there is only // one copy of a type with a given name, per corpus. Otherwise, if @@ -706,10 +703,14 @@ private: priv(); mutable abg_compat::optional sorted_var_symbols; + mutable abg_compat::optional var_symbol_map; mutable abg_compat::optional sorted_undefined_var_symbols; + mutable abg_compat::optional undefined_var_symbol_map; mutable abg_compat::optional unrefed_var_symbols; mutable abg_compat::optional sorted_fun_symbols; + mutable abg_compat::optional fun_symbol_map; mutable abg_compat::optional sorted_undefined_fun_symbols; + mutable abg_compat::optional undefined_fun_symbol_map; mutable abg_compat::optional unrefed_fun_symbols; public: @@ -731,18 +732,30 @@ public: const elf_symbols& get_sorted_fun_symbols() const; + const string_elf_symbols_map_type& + get_fun_symbol_map() const; + const elf_symbols& get_sorted_undefined_fun_symbols() const; + const string_elf_symbols_map_type& + get_undefined_fun_symbol_map() const; + const elf_symbols& get_unreferenced_function_symbols() const; const elf_symbols& get_sorted_var_symbols() const; + const string_elf_symbols_map_type& + get_var_symbol_map() const; + const elf_symbols& get_sorted_undefined_var_symbols() const; + const string_elf_symbols_map_type& + get_undefined_var_symbol_map() const; + const elf_symbols& get_unreferenced_variable_symbols() const; diff --git a/src/abg-corpus.cc b/src/abg-corpus.cc index f9f51a360707..94615bc727ff 100644 --- a/src/abg-corpus.cc +++ b/src/abg-corpus.cc @@ -331,6 +331,18 @@ corpus::priv::get_sorted_fun_symbols() const return *sorted_fun_symbols; } +const string_elf_symbols_map_type& +corpus::priv::get_fun_symbol_map() const +{ + if (!fun_symbol_map) + { + fun_symbol_map = string_elf_symbols_map_type(); + for (const auto& symbol : get_sorted_fun_symbols()) + (*fun_symbol_map)[symbol->get_name()].push_back(symbol); + } + return *fun_symbol_map; +} + /// Getter for a sorted vector of the function symbols undefined in /// this corpus. /// @@ -352,6 +364,18 @@ corpus::priv::get_sorted_undefined_fun_symbols() const return *sorted_undefined_fun_symbols; } +const string_elf_symbols_map_type& +corpus::priv::get_undefined_fun_symbol_map() const +{ + if (!undefined_fun_symbol_map) + { + undefined_fun_symbol_map = string_elf_symbols_map_type(); + for (const auto& symbol : get_sorted_undefined_fun_symbols()) + (*undefined_fun_symbol_map)[symbol->get_name()].push_back(symbol); + } + return *undefined_fun_symbol_map; +} + /// Return a list of symbols that are not referenced by any function of /// corpus::get_functions(). /// @@ -425,6 +449,18 @@ corpus::priv::get_sorted_var_symbols() const return *sorted_var_symbols; } +const string_elf_symbols_map_type& +corpus::priv::get_var_symbol_map() const +{ + if (!var_symbol_map) + { + var_symbol_map = string_elf_symbols_map_type(); + for (const auto& symbol : get_sorted_var_symbols()) + (*var_symbol_map)[symbol->get_name()].push_back(symbol); + } + return *var_symbol_map; +} + /// Getter for a sorted vector of the variable symbols undefined in /// this corpus. /// @@ -446,6 +482,18 @@ corpus::priv::get_sorted_undefined_var_symbols() const return *sorted_undefined_var_symbols; } +const string_elf_symbols_map_type& +corpus::priv::get_undefined_var_symbol_map() const +{ + if (!undefined_var_symbol_map) + { + undefined_var_symbol_map = string_elf_symbols_map_type(); + for (const auto& symbol : get_sorted_undefined_var_symbols()) + (*undefined_var_symbol_map)[symbol->get_name()].push_back(symbol); + } + return *undefined_var_symbol_map; +} + /// Return a list of symbols that are not referenced by any variable of /// corpus::get_variables(). /// @@ -883,10 +931,7 @@ corpus::is_empty() const } } return (members_empty - && priv_->fun_symbol_map - && priv_->fun_symbol_map->empty() - && priv_->var_symbol_map - && priv_->var_symbol_map->empty() + && !get_symtab()->has_symbols() && priv_->soname.empty() && priv_->needed.empty()); } @@ -920,69 +965,12 @@ const symtab_reader::symtab_sptr& corpus::get_symtab() const { return priv_->symtab_; } -/// Setter of the function symbols map. -/// -/// @param map a shared pointer to the new function symbols map. -void -corpus::set_fun_symbol_map(string_elf_symbols_map_sptr map) -{priv_->fun_symbol_map = map;} - -/// Setter for the map of function symbols that are undefined in this -/// corpus. -/// -/// @param map a new map for function symbols not defined in this -/// corpus. The key of the map is the name of the function symbol. -/// The value is a vector of all the function symbols that have the -/// same name. -void -corpus::set_undefined_fun_symbol_map(string_elf_symbols_map_sptr map) -{priv_->undefined_fun_symbol_map = map;} - -/// Setter of the variable symbols map. -/// -/// @param map a shared pointer to the new variable symbols map. -void -corpus::set_var_symbol_map(string_elf_symbols_map_sptr map) -{priv_->var_symbol_map = map;} - -/// Setter for the map of variable symbols that are undefined in this -/// corpus. -/// -/// @param map a new map for variable symbols not defined in this -/// corpus. The key of the map is the name of the variable symbol. -/// The value is a vector of all the variable symbols that have the -/// same name. -void -corpus::set_undefined_var_symbol_map(string_elf_symbols_map_sptr map) -{priv_->undefined_var_symbol_map = map;} - -/// Getter for the function symbols map. -/// -/// @return a shared pointer to the function symbols map. -const string_elf_symbols_map_sptr -corpus::get_fun_symbol_map_sptr() const -{ - if (!priv_->fun_symbol_map) - priv_->fun_symbol_map.reset(new string_elf_symbols_map_type); - return priv_->fun_symbol_map; -} - /// Getter for the function symbols map. /// /// @return a reference to the function symbols map. const string_elf_symbols_map_type& corpus::get_fun_symbol_map() const -{return *get_fun_symbol_map_sptr();} - -/// Getter for the map of function symbols that are undefined in this -/// corpus. -/// -/// @return the map of function symbols not defined in this corpus. -/// The key of the map is the name of the function symbol. The value -/// is a vector of all the function symbols that have the same name. -const string_elf_symbols_map_sptr -corpus::get_undefined_fun_symbol_map_sptr() const -{return priv_->undefined_fun_symbol_map;} +{return priv_->get_fun_symbol_map();} /// Getter for the map of function symbols that are undefined in this /// corpus. @@ -992,7 +980,7 @@ corpus::get_undefined_fun_symbol_map_sptr() const /// is a vector of all the function symbols that have the same name. const string_elf_symbols_map_type& corpus::get_undefined_fun_symbol_map() const -{return *get_undefined_fun_symbol_map_sptr();} +{return priv_->get_undefined_fun_symbol_map();} const elf_symbols& corpus::get_sorted_fun_symbols() const @@ -1010,33 +998,12 @@ const elf_symbols& corpus::get_sorted_undefined_var_symbols() const { return priv_->get_sorted_undefined_var_symbols(); } -/// Getter for the variable symbols map. -/// -/// @return a shared pointer to the variable symbols map. -const string_elf_symbols_map_sptr -corpus::get_var_symbol_map_sptr() const -{ - if (!priv_->var_symbol_map) - priv_->var_symbol_map.reset(new string_elf_symbols_map_type); - return priv_->var_symbol_map; -} - /// Getter for the variable symbols map. /// /// @return a reference to the variabl symbols map. const string_elf_symbols_map_type& corpus::get_var_symbol_map() const -{return *get_var_symbol_map_sptr();} - -/// Getter for the map of variable symbols that are undefined in this -/// corpus. -/// -/// @return the map of variable symbols not defined in this corpus. -/// The key of the map is the name of the variable symbol. The value -/// is a vector of all the variable symbols that have the same name. -const string_elf_symbols_map_sptr -corpus::get_undefined_var_symbol_map_sptr() const -{return priv_->undefined_var_symbol_map;} +{return priv_->get_var_symbol_map();} /// Getter for the map of variable symbols that are undefined in this /// corpus. @@ -1046,7 +1013,7 @@ corpus::get_undefined_var_symbol_map_sptr() const /// is a vector of all the variable symbols that have the same name. const string_elf_symbols_map_type& corpus::get_undefined_var_symbol_map() const -{return *get_undefined_var_symbol_map_sptr();} +{return priv_->get_undefined_var_symbol_map();} /// Look in the function symbols map for a symbol with a given name. /// diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index b2a7144afe9d..6d4e8ae23c53 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -14661,51 +14661,6 @@ read_debug_info_into_corpus(read_context& ctxt) // Set symbols information to the corpus. ctxt.current_corpus()->set_symtab(ctxt.symtab()); - if (!get_ignore_symbol_table(ctxt)) - { - if (ctxt.load_in_linux_kernel_mode() - && is_linux_kernel(ctxt.elf_handle())) - { - string_elf_symbols_map_sptr exported_fn_symbols_map - (new string_elf_symbols_map_type); - auto filter = ctxt.symtab()->make_filter(); - filter.set_functions(); - - for (const auto& symbol : - symtab_reader::filtered_symtab(*ctxt.symtab(), filter)) - { - (*exported_fn_symbols_map)[symbol->get_name()].push_back(symbol); - } - - ctxt.current_corpus()->set_fun_symbol_map(exported_fn_symbols_map); - - string_elf_symbols_map_sptr exported_var_symbols_map( - new string_elf_symbols_map_type); - filter = ctxt.symtab()->make_filter(); - filter.set_variables(); - for (const auto& symbol : - symtab_reader::filtered_symtab(*ctxt.symtab(), filter)) - { - (*exported_var_symbols_map)[symbol->get_name()].push_back(symbol); - } - ctxt.current_corpus()->set_var_symbol_map(exported_var_symbols_map); - } - else - { - ctxt.current_corpus()->set_fun_symbol_map(ctxt.fun_syms_sptr()); - ctxt.current_corpus()->set_var_symbol_map(ctxt.var_syms_sptr()); - } - - ctxt.current_corpus()->set_undefined_fun_symbol_map - (ctxt.undefined_fun_syms_sptr()); - ctxt.current_corpus()->set_undefined_var_symbol_map - (ctxt.undefined_var_syms_sptr()); - } - else - { - ctxt.current_corpus()->set_fun_symbol_map(ctxt.fun_syms_sptr()); - ctxt.current_corpus()->set_var_symbol_map(ctxt.var_syms_sptr()); - } // Get out now if no debug info is found. if (!ctxt.dwarf()) diff --git a/src/abg-reader.cc b/src/abg-reader.cc index c26689ae17ca..296e1e2115d1 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -1908,17 +1908,6 @@ read_corpus_from_input(read_context& ctxt) // are nil, due to potential suppression specifications. That's // fine. corp.set_symtab(symtab_reader::symtab::load(fn_sym_db, var_sym_db)); - - if (fn_sym_db) - { - corp.set_fun_symbol_map(fn_sym_db); - fn_sym_db.reset(); - } - if (var_sym_db) - { - corp.set_var_symbol_map(var_sym_db); - var_sym_db.reset(); - } } ctxt.get_environment()->canonicalization_is_done(false); diff --git a/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi b/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi index 1167e5aa478a..4c9a766f1c7c 100644 --- a/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi +++ b/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi @@ -37,8 +37,6 @@ - - diff --git a/tests/test-symtab.cc b/tests/test-symtab.cc index ff467d8ad345..2df766de1c5c 100644 --- a/tests/test-symtab.cc +++ b/tests/test-symtab.cc @@ -89,17 +89,19 @@ assert_symbol_count(const std::string& path, REQUIRE((status & dwarf_reader::STATUS_OK)); const corpus& corpus = *corpus_ptr; + size_t total_symbols = 0; + if (function_symbols != N) { CHECK(corpus.get_sorted_fun_symbols().size() == function_symbols); CHECK(corpus.get_fun_symbol_map().size() == function_symbols); - CHECK(corpus.get_fun_symbol_map_sptr()->size() == function_symbols); + total_symbols += function_symbols; } if (variable_symbols != N) { CHECK(corpus.get_sorted_var_symbols().size() == variable_symbols); CHECK(corpus.get_var_symbol_map().size() == variable_symbols); - CHECK(corpus.get_var_symbol_map_sptr()->size() == variable_symbols); + total_symbols += variable_symbols; } if (undefined_variable_symbols != N) { @@ -107,8 +109,7 @@ assert_symbol_count(const std::string& path, == undefined_function_symbols); CHECK(corpus.get_undefined_fun_symbol_map().size() == undefined_function_symbols); - CHECK(corpus.get_undefined_fun_symbol_map_sptr()->size() - == undefined_function_symbols); + total_symbols += undefined_function_symbols; } if (undefined_function_symbols != N) { @@ -116,10 +117,12 @@ assert_symbol_count(const std::string& path, == undefined_variable_symbols); CHECK(corpus.get_undefined_var_symbol_map().size() == undefined_variable_symbols); - CHECK(corpus.get_undefined_var_symbol_map_sptr()->size() - == undefined_variable_symbols); + total_symbols += undefined_variable_symbols; } + // assert the corpus reports being empty consistently with the symbol count + CHECK(corpus.is_empty() == (total_symbols == 0)); + return corpus_ptr; } From patchwork Wed Jan 27 12:58:48 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: 41849 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 1E989397303B; Wed, 27 Jan 2021 12:59:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1E989397303B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752385; bh=mSOfuSB+cMfD+WsDnzY7Ou1pU0ypNDQuUIauBM0bb6M=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=nmFBpvVPO9OYyzqqdo/CAX9aQcPbZZ8pRMsf3naitQOqrwN4ryIxMPaNRmBG79Xru K7dN0DI9v8EvIvmcO3jgwUM5IvA076oPmona90M3gN2m9Z1UEUAtK07FbFtPr8xgPD BnYWzLkX83SYvZ4XJrFM6S/nB6AEdw2kRvuaKrs4= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by sourceware.org (Postfix) with ESMTPS id 7860439730F8 for ; Wed, 27 Jan 2021 12:59:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7860439730F8 Received: by mail-qk1-x74a.google.com with SMTP id s66so1373009qkh.10 for ; Wed, 27 Jan 2021 04:59:40 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=mSOfuSB+cMfD+WsDnzY7Ou1pU0ypNDQuUIauBM0bb6M=; b=DgOXWBRROKdezxNv4Qpj1pkwtk/JrYg/MrIG71svvDBaYV3qzDyJ2u9wV3xVipzwdB G+mUDISFT896nTEMIAnKHhyYUhz5qHLbV5GmjtYI5iLAUGldRgph4JhOHr3AsTyjTzU/ hhNUX/GFTOKZUWr71oqrIIxOaINlYeP1+R3Rf+6/k3T1rkA9wDx1LOJ1Zi87qyxOkVLY DEzf5RZsYe0jopaAE1VokNs+ehb0lmGhUlQZuqJQ4uI1JGoJQrt0qX6tc6qOOyJkMdhD 3CaGE3grSbENKnD8olhH10hcOb235BIRx0nh/Xx27OR2MO59i6CPTAPdE7TSa0kpStUZ 105w== X-Gm-Message-State: AOAM533ExMDRDh2SGJJLlGGRQhOFrVWMfJq4LmEqzIWIX5EhLgYGs2nj 3lBDv5uoQCKTqh7X7gCZ3LUSYyv8NmYOD060UHt3bSC2faaML67jDtuztJvvHqLr/CxxlW+/Ve/ jHqJxpc641nBG/iVD/qlP9A8UP9mCdzuEe5M1x8j/VqTKoyb29lXqYZHSnKluOxuDkl/baY8= X-Google-Smtp-Source: ABdhPJzpeAUo3syRDxu6YUmIw1HQXi3Kg11p6gSumBTrvIYm9U359eBFwn+PhmvyphTp0kwwQqqJkMY51rJRng== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:ad4:576a:: with SMTP id r10mr9774619qvx.29.1611752379958; Wed, 27 Jan 2021 04:59:39 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:48 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-16-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 15/20] dwarf reader: drop (now) unused code related to symbol table reading To: libabigail@sourceware.org X-Spam-Status: No, score=-22.0 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_STOCKGEN, 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" The introduction of the new symtab reader incorporated much of the existing functionality. Now that the most code parts are migrated to the new symtab reader, we can safely remove the old code paths. Ignoring the symbol table is not a thing anymore. The new symtab reader does read the symtab unconditionally for consistency reasons. Hence also remove all functionality around conditional symtab reading. * include/abg-dwarf-reader.h (set_ignore_symbol_table): Remove. (get_ignore_symbol_table): Likewise. * src/abg-dwarf-reader.cc (add_symbol_to_map): Likewise. (read_context::options_type::ignore_symbol_table): Likewise. (read_context::options_type): Adjust. (read_context::fun_addr_sym_map_): Remove. (read_context::fun_entry_addr_sym_map_): Likewise. (read_context::fun_syms_): Likewise. (read_context::var_addr_sym_map_): Likewise. (read_context::var_syms_): Likewise. (read_context::undefined_fun_syms_): Likewise. (read_context::undefined_var_syms_): Likewise. (read_context::initialize): Adjust. (read_context::lookup_elf_symbol_from_index): Remove. (read_context::fun_entry_addr_sym_map_sptr): Likewise. (read_context::fun_entry_addr_sym_map): Likewise. (read_context::fun_syms_sptr): Likewise. (read_context::fun_syms): Likewise. (read_context::var_syms_sptr): Likewise. (read_context::var_syms): Likewise. (read_context::undefined_fun_syms_sptr): Likewise. (read_context::undefined_var_syms_sptr): Likewise. (read_context::load_symbol_maps_from_symtab_section): Likewise. (read_context::load_symbol_maps): Likewise. (read_context::maybe_load_symbol_maps): Likewise. (set_ignore_symbol_table): Likewise. (get_ignore_symbol_table): Likewise. (create_default_var_sym): Likewise. (build_var_decl): Adjust. (function_is_suppressed): Likewise. (variable_is_suppressed): Likewise. (build_function_decl): Likewise. (add_symbol_to_map): Remove. (read_corpus_from_elf): Adjust. (build_corpus_group_from_kernel_dist_under): Likewise. * tools/abidw.cc (main): Likewise. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-dwarf-reader.h | 6 - src/abg-dwarf-reader.cc | 742 +------------------------------------ src/abg-tools-utils.cc | 13 - tools/abidw.cc | 2 - 4 files changed, 12 insertions(+), 751 deletions(-) diff --git a/include/abg-dwarf-reader.h b/include/abg-dwarf-reader.h index c80956ac7ac0..a328fb0e741b 100644 --- a/include/abg-dwarf-reader.h +++ b/include/abg-dwarf-reader.h @@ -180,12 +180,6 @@ set_drop_undefined_syms(read_context& ctxt, void set_do_log(read_context& ctxt, bool f); -void -set_ignore_symbol_table(read_context &ctxt, bool f); - -bool -get_ignore_symbol_table(const read_context &ctxt); - void set_environment(read_context& ctxt, ir::environment*); diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 6d4e8ae23c53..91451208ef11 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -282,10 +282,6 @@ static bool operator<(const imported_unit_point& l, const imported_unit_point& r) {return l.offset_of_import < r.offset_of_import;} -static void -add_symbol_to_map(const elf_symbol_sptr& sym, - string_elf_symbols_map_type& map); - static bool get_parent_die(const read_context& ctxt, const Dwarf_Die* die, @@ -1902,92 +1898,6 @@ struct dwarf_expr_eval_context // // --------------------------------------- -/// An enum for the diffent kinds of linux kernel specific symbol -/// tables. -enum kernel_symbol_table_kind -{ - /// This is for an undefined kind of kernel symbol table. - KERNEL_SYMBOL_TABLE_KIND_UNDEFINED, - - /// The __ksymtab symbol table. - KERNEL_SYMBOL_TABLE_KIND_KSYMTAB, - - /// The __ksymtab_gpl symbol table. - KERNEL_SYMBOL_TABLE_KIND_KSYMTAB_GPL -}; - -/// An enum which specifies the format of the kernel symbol table -/// (__ksymtab or __ksymtab_gpl). -enum ksymtab_format -{ - /// This enumerator means that no __ksymtab format has been - /// determined yet. - UNDEFINED_KSYMTAB_FORMAT, - - /// Before Linux v4.19, the format of the __ksymtab (and the - /// __ksymtab_gpl) section was the following. - /// - /// It's an array of entries. Each entry describes a symbol. Each - /// entry is made of two words. each is of the word size of the - /// architecture. (8-bytes on a 64 bits arch and 4-bytes on a 32 - /// bits arch) The first word is the address of a symbol. The - /// second one is the address of a static global variable symbol - /// which value is the string representing the symbol name. That - /// string is in the __ksymtab_strings section. - /// - /// So we are mostly interested in the symbol address part of each - /// entry. - /// - /// Thus this enumerator means that we have the pre v4.19 __ksymtab - /// section format. - PRE_V4_19_KSYMTAB_FORMAT, - - /// Since, Linux v4.19, the format of the __ksymtab section has - /// changed. The commit that changed is - /// https://github.com/torvalds/linux/commit/7290d58095712a89f845e1bca05334796dd49ed2. - /// - /// The __ksymtab and __ksymtab_gpl sections each are an array of - /// entries. Each entry describes a symbol. Each entry is made of - /// two words. Each word is 4-bytes length. The first word is the - /// 'place-relative' address of a symbol. The second one is the - /// 'place-relative' address of a static global variable symbol - /// which value is the string representing the symbol name. That - /// string is in the __ksymtab_strings section. - /// - /// Below is the description of what a "place-relative address" - /// means. For that, we are going to define the meaning of four - /// values: 'N', 'S', 'O', and 'A'. - /// - /// *** 'N' and '0' *** - /// Suppose 'N' is the value of the number stored at offset 'O' (big - /// oh, not zero) in the __ksymtab section. - /// - /// *** 'S'*** - /// That N designates a symbol in the symtab section which value is - /// S. So S is the symbol value (in the .symtab symbol table) - /// referred to by the number N found at offset 'O'. - /// - /// *** 'A' *** - /// Also, suppose the __ksymtab section will be loaded at memory - /// address A, as indicated by the 'address' field of the section - /// header describing the __ksymtab section. - /// - /// So here is the formula that gives us S, from N: - /// - /// S = N + O + A. - /// - /// Storing addresses this way does away with the need to have - /// relocations for the __ksymtab section. So in effect, vmlinux - /// binaries implementing this new format of __ksymtab won't have - /// any .rela__ksymtab relocation section for the __ksymtab section - /// in particular (nor any relocation section at all). - /// - /// - /// Note that we are mostly interested in the symbol address part of - /// each entry. - V4_19_KSYMTAB_FORMAT -}; // end enum ksymtab_format - /// The context used to build ABI corpus from debug info in DWARF /// format. /// @@ -2006,7 +1916,6 @@ public: environment* env; bool load_in_linux_kernel_mode; bool load_all_types; - bool ignore_symbol_table; bool show_stats; bool do_log; @@ -2014,7 +1923,6 @@ public: : env(), load_in_linux_kernel_mode(), load_all_types(), - ignore_symbol_table(), show_stats(), do_log() {} @@ -2211,19 +2119,6 @@ public: offset_offset_map_type alternate_die_parent_map_; offset_offset_map_type type_section_die_parent_map_; list var_decls_to_add_; - addr_elf_symbol_sptr_map_sptr fun_addr_sym_map_; - // On PPC64, the function entry point address is different from the - // GElf_Sym::st_value value, which is the address of the descriptor - // of the function. The map below thus associates the address of - // the entry point to the function symbol. If we are not on ppc64, - // then this map ought to be empty. Only the fun_addr_sym_map_ is - // used in that case. On ppc64, though, both maps are used. - addr_elf_symbol_sptr_map_sptr fun_entry_addr_sym_map_; - string_elf_symbols_map_sptr fun_syms_; - addr_elf_symbol_sptr_map_sptr var_addr_sym_map_; - string_elf_symbols_map_sptr var_syms_; - string_elf_symbols_map_sptr undefined_fun_syms_; - string_elf_symbols_map_sptr undefined_var_syms_; vector dt_needed_; string dt_soname_; string elf_architecture_; @@ -2359,13 +2254,6 @@ public: alternate_die_parent_map_.clear(); type_section_die_parent_map_.clear(); var_decls_to_add_.clear(); - fun_addr_sym_map_.reset(); - fun_entry_addr_sym_map_.reset(); - fun_syms_.reset(); - var_addr_sym_map_.reset(); - var_syms_.reset(); - undefined_fun_syms_.reset(); - undefined_var_syms_.reset(); dt_needed_.clear(); dt_soname_.clear(); elf_architecture_.clear(); @@ -5336,88 +5224,6 @@ public: return true; } - /// Given the index of a symbol into the symbol table of an ELF - /// file, look the symbol up, build an instace of @ref elf_symbol - /// and return it. - /// - /// @param symbol_index the index of the symbol into the symbol - /// table of the current elf file. - /// - /// @return the elf symbol found or nil if none was found. - elf_symbol_sptr - lookup_elf_symbol_from_index(size_t symbol_index) - { - GElf_Sym s; - elf_symbol_sptr result = - lookup_elf_symbol_from_index(symbol_index, s); - return result; - } - - /// Lookup an ELF symbol given its index into the .symtab section. - /// - /// This function returns both the native symbol (from libelf) and - /// the @p abigail::ir::elf_symbol instance, which is the - /// libabigail-specific representation of the symbol. - /// - /// @param symbol_index the index of the symbol to look for. - /// - /// @param native_sym output parameter. This is set to the native - /// ELF symbol found iff the function returns a non-nil value. - /// - /// @return an instance of libabigail::ir::elf_symbol representing - /// the ELF symbol found, iff one was found. Otherwise, returns - /// nil. - elf_symbol_sptr - lookup_elf_symbol_from_index(size_t symbol_index, - GElf_Sym &native_sym) - { - if (!lookup_native_elf_symbol_from_index(symbol_index, native_sym)) - return elf_symbol_sptr(); - - Elf_Scn* symtab_section = find_symbol_table_section(); - if (!symtab_section) - return elf_symbol_sptr(); - - GElf_Shdr header_mem; - GElf_Shdr* symtab_sheader = gelf_getshdr(symtab_section, - &header_mem); - - Elf_Data* symtab = elf_getdata(symtab_section, 0); - ABG_ASSERT(symtab); - - bool sym_is_defined = native_sym.st_shndx != SHN_UNDEF; - bool sym_is_common = native_sym.st_shndx == SHN_COMMON; // this occurs in - // relocatable - // files. - const char* name_str = elf_strptr(elf_handle(), - symtab_sheader->sh_link, - native_sym.st_name); - if (name_str == 0) - name_str = ""; - - elf_symbol::version ver; - elf_helpers::get_version_for_symbol(elf_handle(), symbol_index, - sym_is_defined, ver); - - elf_symbol::visibility vis = - stv_to_elf_symbol_visibility(GELF_ST_VISIBILITY(native_sym.st_other)); - - Elf_Scn* strings_section = find_ksymtab_strings_section(elf_handle()); - size_t strings_ndx = strings_section - ? elf_ndxscn(strings_section) - : 0; - - elf_symbol_sptr sym = - elf_symbol::create(env(), symbol_index, native_sym.st_size, - name_str, stt_to_elf_symbol_type - (GELF_ST_TYPE(native_sym.st_info)), - stb_to_elf_symbol_binding - (GELF_ST_BIND(native_sym.st_info)), - sym_is_defined, sym_is_common, ver, vis, - native_sym.st_shndx == strings_ndx); - return sym; - } - /// Test if a given function symbol has been exported. /// /// @param symbol_address the address of the symbol we are looking @@ -5497,102 +5303,6 @@ public: return symtab_; } - /// Getter for a pointer to the map that associates the address of - /// an entry point of a function with the symbol of that function. - /// - /// Note that on non-"PPC64 ELFv1" binaries, this map is the same as - /// the one that assciates the address of a function with the symbol - /// of that function. - /// - /// @return a pointer to the map that associates the address of an - /// entry point of a function with the symbol of that function. - addr_elf_symbol_sptr_map_sptr& - fun_entry_addr_sym_map_sptr() - { - if (!fun_entry_addr_sym_map_ && !fun_addr_sym_map_) - maybe_load_symbol_maps(); - if (architecture_is_ppc64(elf_handle())) - return fun_entry_addr_sym_map_; - return fun_addr_sym_map_; - } - - /// Getter for the map that associates the address of an entry point - /// of a function with the symbol of that function. - /// - /// Note that on non-"PPC64 ELFv1" binaries, this map is the same as - /// the one that assciates the address of a function with the symbol - /// of that function. - /// - /// @return the map that associates the address of an entry point of - /// a function with the symbol of that function. - addr_elf_symbol_sptr_map_type& - fun_entry_addr_sym_map() - {return *fun_entry_addr_sym_map_sptr();} - - /// Getter for the map of function symbols (name -> sym). - /// - /// @return a shared pointer to the map of function symbols. - const string_elf_symbols_map_sptr& - fun_syms_sptr() const - { - maybe_load_symbol_maps(); - return fun_syms_; - } - - /// Getter for the map of function symbols (name -> sym). - /// - /// @return a reference to the map of function symbols. - string_elf_symbols_map_type& - fun_syms() - { - maybe_load_symbol_maps(); - return *fun_syms_; - } - - /// Getter for the map of variable symbols (name -> sym) - /// - /// @return a shared pointer to the map of variable symbols. - const string_elf_symbols_map_sptr - var_syms_sptr() const - { - maybe_load_symbol_maps(); - return var_syms_; - } - - /// Getter for the map of variable symbols (name -> sym) - /// - /// @return a reference to the map of variable symbols. - string_elf_symbols_map_type& - var_syms() - { - maybe_load_symbol_maps(); - return *var_syms_; - } - - /// Getter for the map of undefined function symbols (name -> vector - /// of symbols). - /// - /// @return a (smart) pointer to the map of undefined function - /// symbols. - const string_elf_symbols_map_sptr& - undefined_fun_syms_sptr() const - { - maybe_load_symbol_maps(); - return undefined_fun_syms_; - } - - /// Getter for the map of undefined variable symbols (name -> vector - /// of symbols). - /// - /// @return a (smart) pointer to the map of undefined variable - /// symbols. - const string_elf_symbols_map_sptr& - undefined_var_syms_sptr() const - { - maybe_load_symbol_maps(); - return undefined_var_syms_; - } - /// Getter for the ELF dt_needed tag. const vector& dt_needed() const @@ -5608,232 +5318,6 @@ public: elf_architecture() const {return elf_architecture_;} - /// Load the maps address -> function symbol, address -> variable - /// symbol and the maps of function and variable undefined symbols. - /// - /// @param load_fun_map whether to load the address to function map. - /// - /// @param load_var_map whether to laod the address to variable map. - /// - /// @param load_undefined_fun_map whether to load the undefined - /// function map. - /// - /// @param load_undefined_var_map whether to laod the undefined - /// variable map. - /// - /// @return return true iff the maps have be loaded. - bool - load_symbol_maps_from_symtab_section(bool load_fun_map, - bool load_var_map, - bool load_undefined_fun_map, - bool load_undefined_var_map) - { - Elf_Scn* symtab_section = find_symbol_table_section(); - if (!symtab_section) - return false; - - GElf_Shdr header_mem; - GElf_Shdr* symtab_sheader = gelf_getshdr(symtab_section, - &header_mem); - - // check for bogus section header - if (symtab_sheader->sh_entsize == 0) - return false; - - size_t nb_syms = symtab_sheader->sh_size / symtab_sheader->sh_entsize; - - Elf_Data* symtab = elf_getdata(symtab_section, 0); - if (!symtab) - return false; - - GElf_Ehdr elf_header; - ABG_ASSERT(gelf_getehdr(elf_handle(), &elf_header)); - - bool is_ppc64 = architecture_is_ppc64(elf_handle()); - - for (size_t i = 0; i < nb_syms; ++i) - { - GElf_Sym* sym, sym_mem; - sym = gelf_getsym(symtab, i, &sym_mem); - ABG_ASSERT(sym); - - if ((load_fun_map || load_undefined_fun_map) - && (GELF_ST_TYPE(sym->st_info) == STT_FUNC - || GELF_ST_TYPE(sym->st_info) == STT_GNU_IFUNC)) - { - elf_symbol_sptr symbol = lookup_elf_symbol_from_index(i); - ABG_ASSERT(symbol); - ABG_ASSERT(symbol->is_function()); - - // If the symbol was suppressed by a suppression - // specification then drop it on the floor. - if (is_elf_symbol_suppressed(symbol)) - continue; - - if (load_fun_map && symbol->is_public()) - { - (*fun_syms_)[symbol->get_name()].push_back(symbol); - - { - GElf_Addr symbol_value = - maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle(), - sym); - - addr_elf_symbol_sptr_map_type::const_iterator it = - fun_addr_sym_map_->find(symbol_value); - if (it == fun_addr_sym_map_->end()) - (*fun_addr_sym_map_)[symbol_value] = symbol; - else //if (sym->st_value != 0) - it->second->get_main_symbol()->add_alias(symbol); - - if (is_ppc64) - { - // 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 enty 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. - 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); - addr_elf_symbol_sptr_map_type::const_iterator it2 = - fun_entry_addr_sym_map().find(fn_entry_point_addr); - - if (it2 == fun_entry_addr_sym_map().end()) - fun_entry_addr_sym_map()[fn_entry_point_addr] = symbol; - else if (address_is_in_opd_section(elf_handle(), - fn_desc_addr)) - { - // Either - // - // 'symbol' must have been registered as an - // alias for it2->second->get_main_symbol(), - // right before the "if (ppc64)" statement. - // - // Or - // - // if the name of 'symbol' is foo, then the - // name of it2->second is ".foo". That is, - // foo is the name of the symbol when it - // refers to the function descriptor in the - // .opd section and ".foo" is an internal - // name for the address of the entry point - // of foo. - // - // In the latter case, we just want to keep - // a refernce to "foo" as .foo is an - // internal name. - - bool two_symbols_alias = - it2->second->get_main_symbol()->does_alias(*symbol); - bool symbol_is_foo_and_prev_symbol_is_dot_foo = - (it2->second->get_name() - == string(".") + symbol->get_name()); - - ABG_ASSERT(two_symbols_alias - || symbol_is_foo_and_prev_symbol_is_dot_foo); - - if (symbol_is_foo_and_prev_symbol_is_dot_foo) - // Let's just keep a reference of the - // symbol that the user sees in the source - // code (the one named foo). The symbol - // which name is prefixed with a "dot" is - // an artificial one. - fun_entry_addr_sym_map()[fn_entry_point_addr] = symbol; - } - } - } - } - else if (load_undefined_fun_map && !symbol->is_defined()) - (*undefined_fun_syms_)[symbol->get_name()].push_back(symbol); - } - else if ((load_var_map || load_undefined_var_map) - && (GELF_ST_TYPE(sym->st_info) == STT_OBJECT - || GELF_ST_TYPE(sym->st_info) == STT_TLS) - // If the symbol is for an OBJECT, the index of the - // section it refers to cannot be absolute. - // Otherwise that OBJECT is not a variable. - && (sym->st_shndx != SHN_ABS - || GELF_ST_TYPE(sym->st_info) != STT_OBJECT )) - { - elf_symbol_sptr symbol = lookup_elf_symbol_from_index(i); - ABG_ASSERT(symbol); - ABG_ASSERT(symbol->is_variable()); - - if (load_var_map && symbol->is_public()) - { - (*var_syms_)[symbol->get_name()].push_back(symbol); - - if (symbol->is_common_symbol()) - { - string_elf_symbols_map_type::iterator it = - var_syms_->find(symbol->get_name()); - ABG_ASSERT(it != var_syms_->end()); - const elf_symbols& common_sym_instances = it->second; - ABG_ASSERT(!common_sym_instances.empty()); - if (common_sym_instances.size() > 1) - { - elf_symbol_sptr main_common_sym = - common_sym_instances[0]; - ABG_ASSERT(main_common_sym->get_name() - == symbol->get_name()); - ABG_ASSERT(main_common_sym->is_common_symbol()); - ABG_ASSERT(symbol.get() != main_common_sym.get()); - main_common_sym->add_common_instance(symbol); - } - } - else - { - GElf_Addr symbol_value = - maybe_adjust_et_rel_sym_addr_to_abs_addr(elf_handle(), - sym); - addr_elf_symbol_sptr_map_type::const_iterator it = - var_addr_sym_map_->find(symbol_value); - if (it == var_addr_sym_map_->end()) - (*var_addr_sym_map_)[symbol_value] = symbol; - else - it->second->get_main_symbol()->add_alias(symbol); - } - } - else if (load_undefined_var_map && !symbol->is_defined()) - (*undefined_var_syms_)[symbol->get_name()].push_back(symbol); - } - } - return true; - } - /// Test if a given ELF symbol was suppressed by a suppression /// specification. /// @@ -5849,71 +5333,6 @@ public: symbol->get_type())); } - /// Load the maps of function symbol address -> function symbol, - /// global variable symbol address -> variable symbol and also the - /// maps of function and variable undefined symbols. - /// - /// All these maps are loaded only if they are not loaded already. - /// - /// @return true iff everything went fine. - bool - load_symbol_maps() - { - bool load_fun_map = !fun_addr_sym_map_ ; - bool load_var_map = !var_addr_sym_map_; - bool load_undefined_fun_map = !undefined_fun_syms_; - bool load_undefined_var_map = !undefined_var_syms_; - - if (!fun_syms_) - fun_syms_.reset(new string_elf_symbols_map_type); - - if (!fun_addr_sym_map_) - fun_addr_sym_map_.reset(new addr_elf_symbol_sptr_map_type); - - if (!fun_entry_addr_sym_map_ && architecture_is_ppc64(elf_handle())) - fun_entry_addr_sym_map_.reset(new addr_elf_symbol_sptr_map_type); - - if (!var_syms_) - var_syms_.reset(new string_elf_symbols_map_type); - - if (!var_addr_sym_map_) - var_addr_sym_map_.reset(new addr_elf_symbol_sptr_map_type); - - if (!undefined_fun_syms_) - undefined_fun_syms_.reset(new string_elf_symbols_map_type); - - if (!undefined_var_syms_) - undefined_var_syms_.reset(new string_elf_symbols_map_type); - - if (!options_.ignore_symbol_table) - { - if (load_symbol_maps_from_symtab_section(load_fun_map, - load_var_map, - load_undefined_fun_map, - load_undefined_var_map)) - return true; - return false; - } - return true; - } - - /// Load the symbol maps if necessary. - /// - /// @return true iff the symbol maps has been loaded by this - /// invocation. - bool - maybe_load_symbol_maps() const - { - if (!fun_addr_sym_map_ - || !var_addr_sym_map_ - || !fun_syms_ - || !var_syms_ - || !undefined_fun_syms_ - || !undefined_var_syms_) - return const_cast(this)->load_symbol_maps(); - return false; - } - /// Load the DT_NEEDED and DT_SONAME elf TAGS. /// void @@ -6804,46 +6223,6 @@ void set_do_log(read_context& ctxt, bool f) {ctxt.do_log(f);} -/// Setter of the "set_ignore_symbol_table" flag. -/// -/// This flag tells if we should load information about ELF symbol -/// tables. Not loading the symbol tables is a speed optimization -/// that is done when the set of symbols we care about is provided -/// off-hand. This is the case when we are supposed to analyze a -/// Linux kernel binary. In that case, because we have the white list -/// of functions/variable symbols we care about, we don't need to -/// analyze the symbol table; things are thus faster in that case. -/// -/// By default, the symbol table is analyzed so this boolean is set to -/// false. -/// -/// @param ctxt the read context to consider. -/// -/// @param f the new value of the flag. -void -set_ignore_symbol_table(read_context &ctxt, bool f) -{ctxt.options_.ignore_symbol_table = f;} - -/// Getter of the "set_ignore_symbol_table" flag. -/// -/// This flag tells if we should load information about ELF symbol -/// tables. Not loading the symbol tables is a speed optimization -/// that is done when the set of symbols we care about is provided -/// off-hand. This is the case when we are supposed to analyze a -/// Linux kernel binary. In that case, because we have the white list -/// of functions/variable symbols we care about, we don't need to -/// analyze the symbol table; things are thus faster in that case. -/// -/// By default, the symbol table is analyzed so this boolean is set to -/// false. -/// -/// @param ctxt the read context to consider. -/// -/// @return the value of the flag. -bool -get_ignore_symbol_table(const read_context& ctxt) -{return ctxt.options_.ignore_symbol_table;} - /// Test if a given DIE is anonymous /// /// @param die the DIE to consider. @@ -13967,33 +13346,6 @@ build_or_get_var_decl_if_not_suppressed(read_context& ctxt, return var; } -/// Create a variable symbol with a given name. -/// -/// @param sym_name the name of the variable symbol. -/// -/// @param env the environment to create the default symbol in. -/// -/// @return the newly created symbol. -static elf_symbol_sptr -create_default_var_sym(const string& sym_name, const environment *env) -{ - elf_symbol::version ver; - elf_symbol::visibility vis = elf_symbol::DEFAULT_VISIBILITY; - elf_symbol_sptr result = - elf_symbol::create(env, - /*symbol index=*/ 0, - /*symbol size=*/ 0, - sym_name, - /*symbol type=*/ elf_symbol::OBJECT_TYPE, - /*symbol binding=*/ elf_symbol::GLOBAL_BINDING, - /*symbol is defined=*/ true, - /*symbol is common=*/ false, - /*symbol version=*/ ver, - /*symbol_visibility=*/vis, - /*is_linux_string_cst=*/false); - return result; -} - /// Build a @ref var_decl out of a DW_TAG_variable DIE. /// /// @param ctxt the read context to use. @@ -14065,23 +13417,9 @@ build_var_decl(read_context& ctxt, if (!result->get_symbol()) { elf_symbol_sptr var_sym; - if (get_ignore_symbol_table(ctxt)) - { - string var_name = - result->get_linkage_name().empty() - ? result->get_name() - : result->get_linkage_name(); - - var_sym = create_default_var_sym(var_name, ctxt.env()); - ABG_ASSERT(var_sym); - add_symbol_to_map(var_sym, ctxt.var_syms()); - } - else - { - Dwarf_Addr var_addr; - if (ctxt.get_variable_address(die, var_addr)) - var_sym = var_sym = ctxt.variable_symbol_is_exported(var_addr); - } + Dwarf_Addr var_addr; + if (ctxt.get_variable_address(die, var_addr)) + var_sym = var_sym = ctxt.variable_symbol_is_exported(var_addr); if (var_sym) { @@ -14145,15 +13483,9 @@ function_is_suppressed(const read_context& ctxt, Dwarf_Addr fn_addr; if (!ctxt.get_function_address(function_die, fn_addr)) return true; - if (!get_ignore_symbol_table(ctxt)) - { - // We were not instructed to ignore (avoid loading) the - // symbol table, so we can rely on its presence to see if - // the address corresponds to the address of an exported - // function symbol. - if (!ctxt.function_symbol_is_exported(fn_addr)) - return true; - } + + if (!ctxt.function_symbol_is_exported(fn_addr)) + return true; } return suppr::function_is_suppressed(ctxt, qualified_name, @@ -14260,15 +13592,9 @@ variable_is_suppressed(const read_context& ctxt, Dwarf_Addr var_addr = 0; if (!ctxt.get_variable_address(variable_die, var_addr)) return true; - if (!get_ignore_symbol_table(ctxt)) - { - // We were not instructed to ignore (avoid loading) the - // symbol table, so we can rely on its presence to see if - // the address corresponds to the address of an exported - // variable symbol. - if (!ctxt.variable_symbol_is_exported(var_addr)) - return true; - } + + if (!ctxt.variable_symbol_is_exported(var_addr)) + return true; } return suppr::variable_is_suppressed(ctxt, qualified_name, @@ -14556,23 +13882,9 @@ build_function_decl(read_context& ctxt, if (!result->get_symbol()) { elf_symbol_sptr fn_sym; - if (get_ignore_symbol_table(ctxt)) - { - string fn_name = - result->get_linkage_name().empty() - ? result->get_name() - : result->get_linkage_name(); - - fn_sym = create_default_fn_sym(fn_name, ctxt.env()); - ABG_ASSERT(fn_sym); - add_symbol_to_map(fn_sym, ctxt.fun_syms()); - } - else - { - Dwarf_Addr fn_addr; - if (ctxt.get_function_address(die, fn_addr)) - fn_sym = ctxt.function_symbol_is_exported(fn_addr); - } + Dwarf_Addr fn_addr; + if (ctxt.get_function_address(die, fn_addr)) + fn_sym = ctxt.function_symbol_is_exported(fn_addr); if (fn_sym && !ctxt.symbol_already_belongs_to_a_function(fn_sym)) { @@ -14602,29 +13914,6 @@ build_function_decl(read_context& ctxt, return result; } -/// Add a symbol to a symbol map. -/// -/// @param sym the symbol to add. -/// -/// @param map the symbol map to add the symbol into. -static void -add_symbol_to_map(const elf_symbol_sptr& sym, - string_elf_symbols_map_type& map) -{ - if (!sym) - return; - - string_elf_symbols_map_type::iterator it = map.find(sym->get_name()); - if (it == map.end()) - { - elf_symbols syms; - syms.push_back(sym); - map[sym->get_name()] = syms; - } - else - it->second.push_back(sym); -} - /// Read all @ref abigail::translation_unit possible from the debug info /// accessible through a DWARF Front End Library handle, and stuff /// them into a libabigail ABI Corpus. @@ -15946,13 +15235,6 @@ read_corpus_from_elf(read_context& ctxt, status& status) ctxt.load_elf_properties(); // DT_SONAME, DT_NEEDED, architecture - if (!get_ignore_symbol_table(ctxt)) - { - // Read the symbols for publicly defined decls - if (!ctxt.load_symbol_maps()) - status |= STATUS_NO_SYMBOLS_FOUND; - } - if (!ctxt.symtab() || !ctxt.symtab()->has_symbols()) status |= STATUS_NO_SYMBOLS_FOUND; diff --git a/src/abg-tools-utils.cc b/src/abg-tools-utils.cc index 4d0191326dab..51043ece26dc 100644 --- a/src/abg-tools-utils.cc +++ b/src/abg-tools-utils.cc @@ -2573,12 +2573,6 @@ build_corpus_group_from_kernel_dist_under(const string& root, << t << "\n"; - // If we have been given a whitelist of functions and - // variable symbols to look at, then we can avoid loading - // and analyzing the ELF symbol table. - bool do_ignore_symbol_table = !kabi_wl_paths.empty(); - set_ignore_symbol_table(*ctxt, do_ignore_symbol_table); - group.reset(new corpus_group(env.get(), root)); set_read_context_corpus_group(*ctxt, group); @@ -2618,13 +2612,6 @@ build_corpus_group_from_kernel_dist_under(const string& root, /*read_all_types=*/false, /*linux_kernel_mode=*/true); - // If we have been given a whitelist of functions and - // variable symbols to look at, then we can avoid loading - // and analyzing the ELF symbol table. - bool do_ignore_symbol_table = !kabi_wl_paths.empty(); - - set_ignore_symbol_table(*ctxt, do_ignore_symbol_table); - load_generate_apply_suppressions(*ctxt, suppr_paths, kabi_wl_paths, supprs); diff --git a/tools/abidw.cc b/tools/abidw.cc index bf4de28324d0..22f640b4167b 100644 --- a/tools/abidw.cc +++ b/tools/abidw.cc @@ -814,8 +814,6 @@ main(int argc, char* argv[]) set_show_stats(ctxt, opts.show_stats); set_suppressions(ctxt, opts); abigail::dwarf_reader::set_do_log(ctxt, opts.do_log); - if (!opts.kabi_whitelist_supprs.empty()) - set_ignore_symbol_table(ctxt, true); if (opts.check_alt_debug_info_path) { From patchwork Wed Jan 27 12:58:49 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: 41850 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 6DF72397282F; Wed, 27 Jan 2021 12:59:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6DF72397282F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752385; bh=btT+e2TOQQWb1voUq+eQgwED0vSTA8ORu5/sCBNbdDc=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=wPmF9dNLmKrctgrrENUHQ2z2IZBp9n04mNbkpXaPdSt4CE8a4EKyEJ33r1tg5Ctac xL5Pcee5n2OwYzRpp2g9Lmao6AoiJWMCdaCcDQVuDVceDX9i302JwQkeT6WFyG6is8 8nKT0eVgXKvZYw9zKzXDbvDJBKUvd9ZqRKLiIcvQ= 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 A558339878E2 for ; Wed, 27 Jan 2021 12:59:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org A558339878E2 Received: by mail-qt1-x849.google.com with SMTP id j14so1028094qtv.3 for ; Wed, 27 Jan 2021 04:59:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=btT+e2TOQQWb1voUq+eQgwED0vSTA8ORu5/sCBNbdDc=; b=SyXx8XqLoW833/B/7YnxfhifJpXSrb73THzp2mNcAz3k/zzJl+xSsgFcA+T3ALk9NG XtfJEp4UujVHHTQfO5Mjh9YGqeoS1P5WdYDNCazx/xm6rtEvYWGMGeewU7/gNNn9ndVe vC1psicqPj/k+dOmWsXQgh9QU3kaokbq2LCqPYlC2t7OlnP8k4LfMNqDf5uzYjeP5ec3 jmmfo27urEyuTIW5yqecCy8kVkvmEUPzDgvCfm2aZvKRMYQmuo/AyyxBh96pFMxZrjYs SRYLLbCz6GF8NJNFGGW4BRvdw3LEBYS2r789m2lqIGz7P0oc58bAqYwOFWAOreNRGMZ/ wQvw== X-Gm-Message-State: AOAM5330E2SnGk0E46+bxfRCHbtpfastdlHKRyAoq3mdBTEniNfnztzG e6dBSbk7wvOTV6VQAZcBGPgNp6Rm9qt23sb+WlZCwSqTE774xPJFuJSGcnxQ5xm0RFoTYmjGaST cYcZE66WAWUwunfEkDBGK/fq0i2093Sa8Q0B6g0/NoPrMZeqaEb2SYDrdStBNwNcKjhNAgOg= X-Google-Smtp-Source: ABdhPJxzy/OLe7YwTntJ++M4xk40sYUh5aduNgfyd1DzipsJFntojsEp3yzHlBvkqlxOxnTy2hM/X8enOZ8hXQ== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:c38e:: with SMTP id o14mr10324604qvi.29.1611752382236; Wed, 27 Jan 2021 04:59:42 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:49 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-17-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 16/20] test-symtab: add tests for whitelisted functions To: libabigail@sourceware.org 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, 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" Extend the test functionality in test-symtab to allow processing of KMI whitelists and add additional test cases for whitelist handling. * tests/data/Makefile.am: add new test files * tests/data/test-symtab/basic/one_function_one_variable_all.whitelist: New test file, * tests/data/test-symtab/basic/one_function_one_variable_function.whitelist: Likewise. * tests/data/test-symtab/basic/one_function_one_variable_irrelevant.whitelist: Likewise. * tests/data/test-symtab/basic/one_function_one_variable_variable.whitelist: Likewise. * tests/test-symtab.cc (read_corpus): Add support for whitelists. (assert_symbol_count): Likewise. (Symtab::SymtabWithWhitelist): New testcase. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- tests/data/Makefile.am | 4 + .../one_function_one_variable_all.whitelist | 3 + ...e_function_one_variable_function.whitelist | 2 + ...function_one_variable_irrelevant.whitelist | 2 + ...e_function_one_variable_variable.whitelist | 2 + tests/test-symtab.cc | 103 ++++++++++++++++-- 6 files changed, 109 insertions(+), 7 deletions(-) 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 diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index a23dbc6343fa..42a94f62f67d 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -1861,6 +1861,10 @@ test-symtab/basic/no_debug_info.c \ test-symtab/basic/no_debug_info.so \ test-symtab/basic/one_function_one_variable.c \ test-symtab/basic/one_function_one_variable.so \ +test-symtab/basic/one_function_one_variable_variable.whitelist \ +test-symtab/basic/one_function_one_variable_function.whitelist \ +test-symtab/basic/one_function_one_variable_irrelevant.whitelist \ +test-symtab/basic/one_function_one_variable_all.whitelist \ test-symtab/basic/one_function_one_variable_undefined.c \ test-symtab/basic/one_function_one_variable_undefined.so \ test-symtab/basic/single_function.c \ diff --git a/tests/data/test-symtab/basic/one_function_one_variable_all.whitelist b/tests/data/test-symtab/basic/one_function_one_variable_all.whitelist new file mode 100644 index 000000000000..02ea310960ff --- /dev/null +++ b/tests/data/test-symtab/basic/one_function_one_variable_all.whitelist @@ -0,0 +1,3 @@ +[abi_whitelist] + exported_function + exported_variable diff --git a/tests/data/test-symtab/basic/one_function_one_variable_function.whitelist b/tests/data/test-symtab/basic/one_function_one_variable_function.whitelist new file mode 100644 index 000000000000..893accc14118 --- /dev/null +++ b/tests/data/test-symtab/basic/one_function_one_variable_function.whitelist @@ -0,0 +1,2 @@ +[abi_whitelist] + exported_function diff --git a/tests/data/test-symtab/basic/one_function_one_variable_irrelevant.whitelist b/tests/data/test-symtab/basic/one_function_one_variable_irrelevant.whitelist new file mode 100644 index 000000000000..180ef9064e8f --- /dev/null +++ b/tests/data/test-symtab/basic/one_function_one_variable_irrelevant.whitelist @@ -0,0 +1,2 @@ +[abi_whitelist] + irrelevant diff --git a/tests/data/test-symtab/basic/one_function_one_variable_variable.whitelist b/tests/data/test-symtab/basic/one_function_one_variable_variable.whitelist new file mode 100644 index 000000000000..49d838f2c559 --- /dev/null +++ b/tests/data/test-symtab/basic/one_function_one_variable_variable.whitelist @@ -0,0 +1,2 @@ +[abi_whitelist] + exported_variable diff --git a/tests/test-symtab.cc b/tests/test-symtab.cc index 2df766de1c5c..ac853e895fef 100644 --- a/tests/test-symtab.cc +++ b/tests/test-symtab.cc @@ -11,11 +11,14 @@ #include #include +#include #include #include "abg-corpus.h" #include "abg-dwarf-reader.h" +#include "abg-fwd.h" #include "abg-ir.h" +#include "abg-tools-utils.h" #include "lib/catch.hpp" #include "test-utils.h" @@ -26,12 +29,16 @@ using dwarf_reader::read_context_sptr; using dwarf_reader::read_corpus_from_elf; using ir::environment; using ir::environment_sptr; +using suppr::suppressions_type; static const std::string test_data_dir = std::string(abigail::tests::get_src_dir()) + "/tests/data/test-symtab/"; 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()) { const std::string& absolute_path = test_data_dir + path; @@ -41,6 +48,15 @@ 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); + if (!whitelist_paths.empty()) + { + const suppressions_type& wl_suppr = + tools_utils::gen_suppr_spec_from_kernel_abi_whitelists( + whitelist_paths); + 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); @@ -76,14 +92,17 @@ 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, - 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()) { corpus_sptr corpus_ptr; - const dwarf_reader::status status = read_corpus(path, corpus_ptr); + const dwarf_reader::status status = + read_corpus(path, corpus_ptr, whitelist_paths); REQUIRE(corpus_ptr); REQUIRE((status & dwarf_reader::STATUS_OK)); @@ -188,6 +207,76 @@ TEST_CASE("Symtab::SimpleSymtabs", "[symtab, basic]") } } +TEST_CASE("Symtab::SymtabWithWhitelist", "[symtab, whitelist]") +{ + GIVEN("a binary with one function and one variable exported") + { + const std::string binary = "basic/one_function_one_variable.so"; + + GIVEN("we read the binary without any whitelists") + { + const corpus_sptr& corpus = assert_symbol_count(binary, 1, 1); + CHECK(corpus->lookup_function_symbol("exported_function")); + CHECK(!corpus->lookup_variable_symbol("exported_function")); + CHECK(corpus->lookup_variable_symbol("exported_variable")); + CHECK(!corpus->lookup_function_symbol("exported_variable")); + } + + GIVEN("we read the binary with all symbols on the whitelists") + { + std::vector whitelists; + whitelists.push_back(test_data_dir + + "basic/one_function_one_variable_all.whitelist"); + const corpus_sptr& corpus = + assert_symbol_count(binary, 1, 1, 0, 0, whitelists); + CHECK(corpus->lookup_function_symbol("exported_function")); + CHECK(!corpus->lookup_variable_symbol("exported_function")); + CHECK(corpus->lookup_variable_symbol("exported_variable")); + CHECK(!corpus->lookup_function_symbol("exported_variable")); + } + + GIVEN("we read the binary with only irrelevant symbols whitelisted") + { + std::vector whitelists; + whitelists.push_back( + test_data_dir + + "basic/one_function_one_variable_irrelevant.whitelist"); + + corpus_sptr corpus_ptr; + const dwarf_reader::status status = + read_corpus(binary, corpus_ptr, whitelists); + REQUIRE(!corpus_ptr); + REQUIRE((status & dwarf_reader::STATUS_NO_SYMBOLS_FOUND)); + } + + GIVEN("we read the binary with only the function whitelisted") + { + std::vector whitelists; + whitelists.push_back( + test_data_dir + "basic/one_function_one_variable_function.whitelist"); + const corpus_sptr& corpus = + assert_symbol_count(binary, 1, 0, 0, 0, whitelists); + CHECK(corpus->lookup_function_symbol("exported_function")); + CHECK(!corpus->lookup_variable_symbol("exported_function")); + CHECK(!corpus->lookup_variable_symbol("exported_variable")); + CHECK(!corpus->lookup_function_symbol("exported_variable")); + } + + GIVEN("we read the binary with only the variable whitelisted") + { + std::vector whitelists; + whitelists.push_back( + test_data_dir + "basic/one_function_one_variable_variable.whitelist"); + const corpus_sptr& corpus = + assert_symbol_count(binary, 0, 1, 0, 0, whitelists); + CHECK(!corpus->lookup_function_symbol("exported_function")); + CHECK(!corpus->lookup_variable_symbol("exported_function")); + CHECK(corpus->lookup_variable_symbol("exported_variable")); + CHECK(!corpus->lookup_function_symbol("exported_variable")); + } + } +} + static const char* kernel_versions[] = { "4.14", "4.19", "5.4", "5.6" }; static const size_t nr_kernel_versions = sizeof(kernel_versions) / sizeof(kernel_versions[0]); From patchwork Wed Jan 27 12:58:50 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: 41854 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 A076A3973039; Wed, 27 Jan 2021 13:01:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A076A3973039 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752497; bh=tzO2Q+GTj72UWdDTXmaUti8NOt5W2S6ETd7NJV0492c=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=mqevW7u5N9Nn5dKj+/+KsY6p0Ek/S7qO/Cm8XUMYO8Qw39AO8HVf+1HZA1r1aRey+ e/cIQxxrgNy/pApVXS/w4bR5EnHlxhitfqUKf+IVQWTsvkKoZTzWpPewEug7CquMFs cpDANpKJT17Rj8cQD37QmOsdzhgaOhycpQLfrauQ= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qk1-x74a.google.com (mail-qk1-x74a.google.com [IPv6:2607:f8b0:4864:20::74a]) by sourceware.org (Postfix) with ESMTPS id 87576397303B for ; Wed, 27 Jan 2021 12:59:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 87576397303B Received: by mail-qk1-x74a.google.com with SMTP id u66so1373809qkd.13 for ; Wed, 27 Jan 2021 04:59:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=tzO2Q+GTj72UWdDTXmaUti8NOt5W2S6ETd7NJV0492c=; b=MzxcDmNvih7rgYEEqUUiVeJZEkrdKEHcpMcS8HivHA6TYjdefZOHhl9xVtVFWPQXI2 uXslhv0xNkqfRwGe+2oF6zYNgcxWFyCt5F5tp3kXZxkjpFwTx7vf3RSVnUs5TQVEi0iT okti0tXv1fNUpZ3jQgg04JIYeS9g9T5GAMza5gqOpHq3nEq72tVg134BEjfl7VN8eqml ot8nOWL0ZfQmOeS90lr0pK2wirRJsCKYIc4aTK2dMxmBGMunpKB9NMKWqucM2SuysacW VEjYAE86d402SAPeqwRtrbsVHJkZpc+a1z6hxUKNfw1E08OQeti7KJSKlyJKVE+uukqI 4j2Q== X-Gm-Message-State: AOAM532anEAwCv2pYzIfHBS3PBHp13NI5uMpwwhWUC/QKASOT/tdiM+g 1Zby08LQhHss/+Z8DJsU5hGTC/qbPXJ6U4uEQATAy5CSppuQ3nn4VYBqukOs6OvaqKzTlXOejzB E2Zp0hG/pWzGCcAD2yuFwKJVizrnS/14mnJTf/l5mbMGg8c4YDYfdm65zj7EEa1x6hzR4rKg= X-Google-Smtp-Source: ABdhPJxQcTNy9g8ThZ0UYpwOcnOTbzL7sJ2YO1W5ZgoytwC6JOGKsH7ITjM0V3aA8mVPvNvoEPvaFimCgITfdw== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:f64c:: with SMTP id s12mr10324265qvm.2.1611752385322; Wed, 27 Jan 2021 04:59:45 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:50 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-18-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 17/20] symtab/dwarf-reader: allow hinting of main symbols for aliases To: libabigail@sourceware.org X-Spam-Status: No, score=-21.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TIME_LIMIT_EXCEEDED, USER_IN_DEF_DKIM_WL autolearn=unavailable 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" In case of aliased symbols, the "main symbol" cannot be deduced from the symtab as this solely contains a name->addr mapping and aliases are represented by multiple names resolving to the same address. Therefore the main symbol can only be picked rather randomly and unpredictable. Unlike DWARF, which contains a single symbol entry for only the main symbol. Hence we can (late) detect the main symbol. Exploiting that property allows to correct the addr->symbol lookup in the symtab to return the correct main symbol and it also allows to correct the aliased symbols to maintain the correct main symbol. This patch adds the `update_main_symbol` functionality to `elf_symbol` to update the main symbol by name (ELF symbols need unique names) and adds `update_main_symbol` to `symtab` that makes use of said new method. When we discover a main symbol during DWARF reading, we instruct the symtab to update the mapping. This creates consistent representations across different builds of the same binary with the same ABI by pinning down the main symbol to the defined one. Knowing the main symbol also helps to keep the correct dwarf information in the representation in the presence of symbol suppressions. A later patch will address that. Some test cases in tests/data need adjustment and they have all been verified to be valid changes. - main symbol changed for various elf symbols - test-annotate/test15-pr18892.so.abi - test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi - test-annotate/test3.so.abi - test-read-dwarf/test15-pr18892.so.abi - test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi - test-read-dwarf/test3.so.abi - test-read-dwarf/test3.so.hash.abi - due to main symbol changes, the symbol diff needs to be corrected - test-diff-dwarf/test12-report.txt - test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt - test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt - the test scenario needed adjustments as the main symbol changed - test-diff-suppr/test23-alias-filter-4.suppr - test-diff-suppr/test23-alias-filter-report-0.txt - test-diff-suppr/test23-alias-filter-report-2.txt As usual, the complete changelog follows. * include/abg-ir.h (elf_symbol::update_main_symbol): New method. * include/abg-symtab-reader.h (symtab::update_main_symbol): New method. * src/abg-dwarf-reader.cc (build_var_decl): Hint symtab about main symbol discovered in DWARF. (build_function_decl): Likewise. * src/abg-ir.cc (elf_symbol::get_main_symbol): Lock the weak_ptr on access in both overloads. (update_main_symbol): New method to allow updating the main symbol. * src/abg-symtab-reader.cc (symtab::update_main_symbol): New method. * data/Makefile.am: Add new test data files. * tests/data/test-annotate/test15-pr18892.so.abi: Updated test file. * tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-annotate/test2.so.abi: Likewise. * tests/data/test-annotate/test3.so.abi: Likewise. * tests/data/test-diff-dwarf/test12-report.txt: Likewise. * tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt: Likewise. * tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-4.suppr: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-0.txt: Likewise. * tests/data/test-diff-suppr/test23-alias-filter-report-2.txt: Likewise. * tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi: Likewise. * tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise. * tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise. * tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise. * tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise. * tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise. * tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise. * tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi: Likewise. * tests/data/test-read-dwarf/test2.so.abi: Likewise. * tests/data/test-read-dwarf/test2.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.abi: Likewise. * tests/data/test-read-dwarf/test3.so.hash.abi: Likewise. * tests/data/test-symtab/basic/aliases.c: New test source file. * tests/data/test-symtab/basic/aliases.so: Likewise. * tests/test-symtab.cc (Symtab::AliasedFunctionSymbols): New test case. (Symtab::AliasedVariableSymbols): Likewise. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-ir.h | 3 + src/abg-dwarf-reader.cc | 16 +- src/abg-ir.cc | 47 +- src/abg-symtab-reader.cc | 31 + src/abg-symtab-reader.h | 3 + tests/data/Makefile.am | 2 + .../test5-fn-changed-report-0.txt | 4 - .../test5-fn-changed-report-1.txt | 4 - .../data/test-annotate/test15-pr18892.so.abi | 918 +++++++-------- ...19-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 +- .../test31-pr18535-libstdc++-report-0.txt | 6 +- .../test31-pr18535-libstdc++-report-1.txt | 6 +- ...bb-4.3-3.20141204.fc23.x86_64-report-0.txt | 6 +- ...bb-4.3-3.20141204.fc23.x86_64-report-1.txt | 6 +- .../test23-alias-filter-4.suppr | 2 +- .../test23-alias-filter-report-0.txt | 4 +- .../test23-alias-filter-report-2.txt | 4 +- .../PR22015-libboost_iostreams.so.abi | 48 +- .../test-read-dwarf/PR22122-libftdc.so.abi | 6 +- .../test-read-dwarf/test10-pr18818-gcc.so.abi | 192 +-- .../test-read-dwarf/test11-pr18828.so.abi | 516 ++++---- .../test-read-dwarf/test12-pr18844.so.abi | 66 +- .../test-read-dwarf/test15-pr18892.so.abi | 918 +++++++-------- .../test-read-dwarf/test16-pr18904.so.abi | 990 ++++++++-------- ...19-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 ++++++++--------- tests/data/test-read-dwarf/test3.so.abi | 6 +- tests/data/test-read-dwarf/test3.so.hash.abi | 6 +- tests/data/test-symtab/basic/aliases.c | 13 + tests/data/test-symtab/basic/aliases.so | Bin 0 -> 17176 bytes tests/test-symtab.cc | 47 + 38 files changed, 2619 insertions(+), 2472 deletions(-) create mode 100644 tests/data/test-symtab/basic/aliases.c create mode 100755 tests/data/test-symtab/basic/aliases.so diff --git a/include/abg-ir.h b/include/abg-ir.h index 23ba16bd327b..a14ee1c23784 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -954,6 +954,9 @@ public: bool is_main_symbol() const; + elf_symbol_sptr + update_main_symbol(const std::string&); + elf_symbol_sptr get_next_alias() const; diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 91451208ef11..7d7ffbdc8ebe 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -13419,7 +13419,13 @@ 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); + { + ctxt.symtab()->update_main_symbol(var_addr, + result->get_linkage_name().empty() + ? result->get_name() + : result->get_linkage_name()); + var_sym = ctxt.variable_symbol_is_exported(var_addr); + } if (var_sym) { @@ -13884,7 +13890,13 @@ build_function_decl(read_context& ctxt, elf_symbol_sptr fn_sym; Dwarf_Addr fn_addr; if (ctxt.get_function_address(die, fn_addr)) - fn_sym = ctxt.function_symbol_is_exported(fn_addr); + { + ctxt.symtab()->update_main_symbol(fn_addr, + result->get_linkage_name().empty() + ? result->get_name() + : result->get_linkage_name()); + fn_sym = ctxt.function_symbol_is_exported(fn_addr); + } if (fn_sym && !ctxt.symbol_already_belongs_to_a_function(fn_sym)) { diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 1ba95dd6c14f..0b31f2014189 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -1754,14 +1754,14 @@ elf_symbol::set_is_suppressed(bool is_suppressed) ///@return the main symbol. const elf_symbol_sptr elf_symbol::get_main_symbol() const -{return elf_symbol_sptr(priv_->main_symbol_);} +{return priv_->main_symbol_.lock();} /// Get the main symbol of an alias chain. /// ///@return the main symbol. elf_symbol_sptr elf_symbol::get_main_symbol() -{return elf_symbol_sptr(priv_->main_symbol_);} +{return priv_->main_symbol_.lock();} /// Tests whether this symbol is the main symbol. /// @@ -1838,6 +1838,49 @@ elf_symbol::add_alias(const elf_symbol_sptr& alias) alias->priv_->main_symbol_ = get_main_symbol(); } +/// Update the main symbol for a group of aliased symbols +/// +/// If after the construction of the symbols (in order of discovery), the +/// actual main symbol can be identified (e.g. as the symbol that actually is +/// defined in the code), this method offers a way of updating the main symbol +/// through one of the aliased symbols. +/// +/// For that, locate the new main symbol by name and update all references to +/// the main symbol among the group of aliased symbols. +/// +/// @param name the name of the main symbol +/// +/// @return the new main elf_symbol +elf_symbol_sptr +elf_symbol::update_main_symbol(const std::string& name) +{ + ABG_ASSERT(is_main_symbol()); + if (!has_aliases() || get_name() == name) + return get_main_symbol(); + + // find the new main symbol + elf_symbol_sptr new_main; + // we've already checked this; check the rest of the aliases + for (elf_symbol_sptr a = get_next_alias(); a.get() != this; + a = a->get_next_alias()) + if (a->get_name() == name) + { + new_main = a; + break; + } + + if (!new_main) + return get_main_symbol(); + + // now update all main symbol references + priv_->main_symbol_ = new_main; + for (elf_symbol_sptr a = get_next_alias(); a.get() != this; + a = a->get_next_alias()) + a->priv_->main_symbol_ = new_main; + + return new_main; +} + /// Return true if the symbol is a common one. /// /// @return true iff the symbol is common. diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc index 7318fdfce52e..a769934e5c05 100644 --- a/src/abg-symtab-reader.cc +++ b/src/abg-symtab-reader.cc @@ -376,6 +376,37 @@ symtab::load_(string_elf_symbols_map_sptr function_symbol_map, return true; } +/// Notify the symtab about the name of the main symbol at a given address. +/// +/// From just alone the symtab we can't guess the main symbol of a bunch of +/// aliased symbols that all point to the same address. During processing of +/// additional information (such as DWARF), this information becomes apparent +/// and we can adjust the addr->symbol lookup map as well as the alias +/// reference of the symbol objects. +/// +/// @param addr the addr that we are updating the main symbol for +/// @param name the name of the main symbol +void +symtab::update_main_symbol(GElf_Addr addr, const std::string& name) +{ + // get one symbol (i.e. the current main symbol) + elf_symbol_sptr symbol = lookup_symbol(addr); + + // The caller might not know whether the addr is associated to an ELF symbol + // that we care about. E.g. the addr could be associated to an ELF symbol, + // but not one in .dynsym when looking at a DSO. Hence, early exit if the + // lookup failed. + if (!symbol) + return; + + // determine the new main symbol by attempting an update + elf_symbol_sptr new_main = symbol->update_main_symbol(name); + + // also update the default symbol we return when looked up by address + if (new_main) + addr_symbol_map_[addr] = new_main; +} + void symtab::update_function_entry_address_symbol_map( Elf* elf_handle, diff --git a/src/abg-symtab-reader.h b/src/abg-symtab-reader.h index 2906bab818b0..a621938c44d7 100644 --- a/src/abg-symtab-reader.h +++ b/src/abg-symtab-reader.h @@ -225,6 +225,9 @@ public: load(string_elf_symbols_map_sptr function_symbol_map, string_elf_symbols_map_sptr variables_symbol_map); + void + update_main_symbol(GElf_Addr addr, const std::string& name); + private: /// Default constructor. Private to enforce creation by factory methods. symtab(); diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 42a94f62f67d..d1358c9e9942 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -1853,6 +1853,8 @@ test-kmi-whitelist/whitelist-with-duplicate-entry \ test-kmi-whitelist/whitelist-with-two-sections \ \ test-symtab/basic/Makefile \ +test-symtab/basic/aliases.c \ +test-symtab/basic/aliases.so \ test-symtab/basic/empty.c \ test-symtab/basic/empty.so \ test-symtab/basic/link_against_me.c \ diff --git a/tests/data/test-abicompat/test5-fn-changed-report-0.txt b/tests/data/test-abicompat/test5-fn-changed-report-0.txt index ccde357d75ce..04676908c7c2 100644 --- a/tests/data/test-abicompat/test5-fn-changed-report-0.txt +++ b/tests/data/test-abicompat/test5-fn-changed-report-0.txt @@ -15,7 +15,3 @@ 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) - method S0::S0(): - implicit parameter 0 of type 'S0*' has sub-type changes: - pointed to type 'struct S0' changed, as reported earlier - diff --git a/tests/data/test-abicompat/test5-fn-changed-report-1.txt b/tests/data/test-abicompat/test5-fn-changed-report-1.txt index dbdcbe5e7607..b39f650de332 100644 --- a/tests/data/test-abicompat/test5-fn-changed-report-1.txt +++ b/tests/data/test-abicompat/test5-fn-changed-report-1.txt @@ -15,7 +15,3 @@ 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 - method S0::S0(): - implicit parameter 0 of type 'S0*' has sub-type changes: - pointed to type 'struct S0' changed at test5-fn-changed-libapp-v0.h:1:1, as reported earlier - diff --git a/tests/data/test-annotate/test15-pr18892.so.abi b/tests/data/test-annotate/test15-pr18892.so.abi index cacace2a09cf..a79557aa2391 100644 --- a/tests/data/test-annotate/test15-pr18892.so.abi +++ b/tests/data/test-annotate/test15-pr18892.so.abi @@ -193,7 +193,7 @@ - + @@ -207,45 +207,45 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -253,7 +253,7 @@ - + @@ -261,69 +261,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -341,7 +341,7 @@ - + @@ -353,19 +353,19 @@ - + - + - + - + - + @@ -373,67 +373,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -441,25 +441,25 @@ - + - + - + - + - + - + - + - + @@ -467,39 +467,39 @@ - + - + - + - + - + - + - + - + - + - + @@ -509,43 +509,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -555,7 +555,7 @@ - + @@ -569,21 +569,21 @@ - + - + - + - + - + @@ -591,13 +591,13 @@ - + - + - + @@ -607,9 +607,9 @@ - + - + @@ -621,19 +621,19 @@ - + - + - + - + - + @@ -641,49 +641,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -695,19 +695,19 @@ - + - + - + - + @@ -719,23 +719,23 @@ - + - + - + - + - + @@ -745,7 +745,7 @@ - + @@ -761,93 +761,93 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2223,11 +2223,11 @@ - + - + @@ -2407,11 +2407,11 @@ - + - + @@ -2429,13 +2429,13 @@ - + - + - + @@ -2443,7 +2443,7 @@ - + @@ -2451,7 +2451,7 @@ - + @@ -2459,69 +2459,69 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2539,7 +2539,7 @@ - + @@ -2551,19 +2551,19 @@ - + - + - + - + - + @@ -2571,67 +2571,67 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2639,25 +2639,25 @@ - + - + - + - + - + - + - + - + @@ -2665,39 +2665,39 @@ - + - + - + - + - + - + - + - + - + - + @@ -2707,43 +2707,43 @@ - + - + - + - + - + - + - + - + - + - + - + - + @@ -2753,7 +2753,7 @@ - + @@ -2767,21 +2767,21 @@ - + - + - + - + - + @@ -2789,13 +2789,13 @@ - + - + - + @@ -2805,9 +2805,9 @@ - + - + @@ -2819,19 +2819,19 @@ - + - + - + - + - + @@ -2839,49 +2839,49 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -2893,19 +2893,19 @@ - + - + - + - + @@ -2917,23 +2917,23 @@ - + - + - + - + - + @@ -2943,7 +2943,7 @@ - + @@ -2959,73 +2959,73 @@ - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + @@ -13772,7 +13772,7 @@ - + @@ -13781,7 +13781,7 @@ - + @@ -13790,7 +13790,7 @@ - + @@ -20235,7 +20235,7 @@ - + @@ -20263,7 +20263,7 @@ - + @@ -20283,7 +20283,7 @@ - + @@ -20310,7 +20310,7 @@ - + @@ -20319,7 +20319,7 @@ - + @@ -20333,14 +20333,14 @@ - + - + @@ -20351,7 +20351,7 @@ - + @@ -20362,7 +20362,7 @@ - + @@ -20395,7 +20395,7 @@ - + @@ -20415,7 +20415,7 @@ - + @@ -20424,21 +20424,21 @@ - + - + - + @@ -20458,7 +20458,7 @@ - + @@ -20478,7 +20478,7 @@ - + @@ -20487,7 +20487,7 @@ - + @@ -20505,7 +20505,7 @@ - + @@ -20514,7 +20514,7 @@ - + @@ -20543,7 +20543,7 @@ - + @@ -20552,7 +20552,7 @@ - + @@ -20561,7 +20561,7 @@ - + @@ -20572,7 +20572,7 @@ - + @@ -20581,7 +20581,7 @@ - + @@ -20604,7 +20604,7 @@ - + @@ -20613,7 +20613,7 @@ - + @@ -20622,7 +20622,7 @@ - + @@ -20649,7 +20649,7 @@ - + @@ -20685,7 +20685,7 @@ - + @@ -20712,7 +20712,7 @@ - + @@ -20744,14 +20744,14 @@ - + - + @@ -20787,14 +20787,14 @@ - + - + @@ -20819,7 +20819,7 @@ - + @@ -20848,7 +20848,7 @@ - + @@ -20861,7 +20861,7 @@ - + @@ -20907,7 +20907,7 @@ - + @@ -20918,7 +20918,7 @@ - + @@ -20936,7 +20936,7 @@ - + @@ -20947,7 +20947,7 @@ - + @@ -20958,7 +20958,7 @@ - + @@ -20989,7 +20989,7 @@ - + @@ -21013,7 +21013,7 @@ - + @@ -21028,7 +21028,7 @@ - + @@ -21041,7 +21041,7 @@ - + @@ -21052,7 +21052,7 @@ - + @@ -21063,7 +21063,7 @@ - + @@ -21074,14 +21074,14 @@ - + - + @@ -21130,7 +21130,7 @@ - + @@ -21148,14 +21148,14 @@ - + - + @@ -21177,7 +21177,7 @@ - + @@ -21186,7 +21186,7 @@ - + @@ -21262,7 +21262,7 @@ - + @@ -21279,7 +21279,7 @@ - + @@ -21342,7 +21342,7 @@ - + @@ -21371,7 +21371,7 @@ - + @@ -21404,7 +21404,7 @@ - + @@ -21417,7 +21417,7 @@ - + @@ -21439,7 +21439,7 @@ - + @@ -21470,7 +21470,7 @@ - + @@ -21479,7 +21479,7 @@ - + @@ -21488,7 +21488,7 @@ - + @@ -21506,7 +21506,7 @@ - + @@ -21517,7 +21517,7 @@ - + @@ -21528,7 +21528,7 @@ - + @@ -21538,7 +21538,7 @@ - + @@ -21549,7 +21549,7 @@ - + @@ -21559,7 +21559,7 @@ - + @@ -21568,7 +21568,7 @@ - + @@ -21576,7 +21576,7 @@ - + @@ -21608,7 +21608,7 @@ - + @@ -21618,7 +21618,7 @@ - + @@ -21627,7 +21627,7 @@ - + @@ -21646,7 +21646,7 @@ - + @@ -21662,7 +21662,7 @@ - + @@ -21671,7 +21671,7 @@ - + @@ -21687,14 +21687,14 @@ - + - + @@ -21710,14 +21710,14 @@ - + - + @@ -21732,7 +21732,7 @@ - + @@ -21745,7 +21745,7 @@ - + @@ -21769,7 +21769,7 @@ - + @@ -21782,7 +21782,7 @@ - + @@ -21795,7 +21795,7 @@ - + @@ -21806,7 +21806,7 @@ - + @@ -21819,7 +21819,7 @@ - + @@ -21832,7 +21832,7 @@ - + @@ -21869,7 +21869,7 @@ - + @@ -21889,7 +21889,7 @@ - + @@ -21907,7 +21907,7 @@ - + @@ -21947,7 +21947,7 @@ - + @@ -21974,7 +21974,7 @@ - + @@ -21983,7 +21983,7 @@ - + @@ -22015,7 +22015,7 @@ - + @@ -22035,7 +22035,7 @@ - + @@ -22048,7 +22048,7 @@ - + @@ -22068,7 +22068,7 @@ - + @@ -22082,7 +22082,7 @@ - + @@ -22096,7 +22096,7 @@ - + @@ -22149,14 +22149,14 @@ - + - + @@ -22180,7 +22180,7 @@ - + @@ -22225,14 +22225,14 @@ - + - + @@ -22255,7 +22255,7 @@ - + @@ -22266,7 +22266,7 @@ - + @@ -22301,7 +22301,7 @@ - + @@ -22315,7 +22315,7 @@ - + @@ -22326,7 +22326,7 @@ - + @@ -22346,7 +22346,7 @@ - + @@ -22355,7 +22355,7 @@ - + @@ -22391,7 +22391,7 @@ - + @@ -22442,7 +22442,7 @@ - + @@ -22451,7 +22451,7 @@ - + @@ -22471,7 +22471,7 @@ - + @@ -22491,7 +22491,7 @@ - + @@ -22502,7 +22502,7 @@ - + @@ -22538,7 +22538,7 @@ - + @@ -22561,14 +22561,14 @@ - + - + @@ -22579,7 +22579,7 @@ - + @@ -22602,7 +22602,7 @@ - + @@ -22647,7 +22647,7 @@ - + @@ -22661,7 +22661,7 @@ - + @@ -22670,7 +22670,7 @@ - + @@ -22714,7 +22714,7 @@ - + @@ -22728,7 +22728,7 @@ - + @@ -22746,7 +22746,7 @@ - + @@ -22760,7 +22760,7 @@ - + @@ -22879,7 +22879,7 @@ - + @@ -22912,7 +22912,7 @@ - + @@ -22932,7 +22932,7 @@ - + @@ -22959,7 +22959,7 @@ - + @@ -23003,7 +23003,7 @@ - + @@ -23096,14 +23096,14 @@ - + - + @@ -23117,7 +23117,7 @@ - + @@ -23126,7 +23126,7 @@ - + @@ -23144,14 +23144,14 @@ - + - + @@ -23169,7 +23169,7 @@ - + @@ -23178,7 +23178,7 @@ - + @@ -23221,7 +23221,7 @@ - + @@ -23237,7 +23237,7 @@ - + @@ -27191,7 +27191,7 @@ - + @@ -27209,7 +27209,7 @@ - + diff --git a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi index 1ba7ead9d421..ec6cbb3f6bc3 100644 --- a/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi +++ b/tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi @@ -1098,15 +1098,15 @@ - + - + - + - + @@ -1124,11 +1124,11 @@ - + - + @@ -1138,19 +1138,19 @@ - + - + - + @@ -1164,7 +1164,7 @@ - + @@ -1174,23 +1174,23 @@ - + - + - + - + - + - + @@ -1204,19 +1204,19 @@ - + - + - + - + @@ -24511,7 +24511,7 @@ - + @@ -24528,7 +24528,7 @@ - + @@ -24539,14 +24539,14 @@ - + - + @@ -24571,7 +24571,7 @@ - + @@ -24594,7 +24594,7 @@ - + @@ -24624,14 +24624,14 @@ - + - + @@ -24647,14 +24647,14 @@ - + - + diff --git a/tests/data/test-annotate/test2.so.abi b/tests/data/test-annotate/test2.so.abi index cc40ccd0e3c5..072834a187b5 100644 --- a/tests/data/test-annotate/test2.so.abi +++ b/tests/data/test-annotate/test2.so.abi @@ -7,13 +7,13 @@ - + - + - + - + @@ -55,7 +55,7 @@ - + @@ -96,7 +96,7 @@ - + diff --git a/tests/data/test-annotate/test3.so.abi b/tests/data/test-annotate/test3.so.abi index cbcb456d97c8..ca3790742779 100644 --- a/tests/data/test-annotate/test3.so.abi +++ b/tests/data/test-annotate/test3.so.abi @@ -4,7 +4,7 @@ - + @@ -12,7 +12,7 @@ - + @@ -20,7 +20,7 @@ - + diff --git a/tests/data/test-diff-dwarf/test12-report.txt b/tests/data/test-diff-dwarf/test12-report.txt index e69de29bb2d1..62dd8337d694 100644 --- a/tests/data/test-diff-dwarf/test12-report.txt +++ b/tests/data/test-diff-dwarf/test12-report.txt @@ -0,0 +1,7 @@ +Functions changes summary: 0 Removed, 0 Changed, 1 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + +1 Added function: + + [A] 'function int _foo3(int, int)' + diff --git a/tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt b/tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt index 4f4a765f9381..a79c11bed2dc 100644 --- a/tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt +++ b/tests/data/test-diff-dwarf/test36-ppc64-aliases-report-0.txt @@ -3,14 +3,14 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 4 functions with some indirect sub-type change: - [C] 'method S::S()' has some indirect sub-type changes: + [C] 'method S::S(int)' has some indirect sub-type changes: implicit parameter 0 of type 'S*' has sub-type 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) - [C] 'method S::S(int)' has some indirect sub-type changes: + [C] 'method S::S()' has some indirect sub-type changes: implicit parameter 0 of type 'S*' has sub-type changes: pointed to type 'struct S' changed, as reported earlier diff --git a/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt b/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt index 61491027df5c..094a30dd3fee 100644 --- a/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt +++ b/tests/data/test-diff-dwarf/test42-PR21296-clanggcc-report0.txt @@ -1,10 +1,8 @@ -Functions changes summary: 3 Removed, 8 Changed, 0 Added functions +Functions changes summary: 1 Removed, 8 Changed, 0 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable -3 Removed functions: +1 Removed function: - [D] 'method STR::STR(const char*)' - [D] 'method STR::~STR()' [D] 'method void std::_Tuple_impl<1ul>::_Tuple_impl()' 8 functions with some indirect sub-type change: diff --git a/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt b/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt index 10677fccd685..544488c6becf 100644 --- a/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt +++ b/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt @@ -1,4 +1,4 @@ -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 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 @@ -97,8 +97,8 @@ Variable symbols changes summary: 0 Removed, 6 Added variable symbols not refere no member function changes (10 filtered); [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 - and it aliases symbol: _ZNSt14codecvt_bynameIwc11__mbstate_tEC2EPKcj@@GLIBCXX_3.4 + Please note that the symbol of this function is _ZNSt14codecvt_bynameIwc11__mbstate_tEC2EPKcj@@GLIBCXX_3.4 + and it aliases symbol: _ZNSt14codecvt_bynameIwc11__mbstate_tEC1EPKcj@@GLIBCXX_3.4 implicit parameter 0 of type 'std::codecvt_byname*' has sub-type changes: in pointed to type 'class std::codecvt_byname': type size hasn't changed diff --git a/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt b/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt index 84667becbc25..c84cd1cd0c78 100644 --- a/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt +++ b/tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt @@ -1,4 +1,4 @@ -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 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 @@ -97,8 +97,8 @@ Variable symbols changes summary: 0 Removed, 6 Added variable symbols not refere no member function changes (10 filtered); [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 - and it aliases symbol: _ZNSt14codecvt_bynameIwc11__mbstate_tEC2EPKcj@@GLIBCXX_3.4 + Please note that the symbol of this function is _ZNSt14codecvt_bynameIwc11__mbstate_tEC2EPKcj@@GLIBCXX_3.4 + and it aliases symbol: _ZNSt14codecvt_bynameIwc11__mbstate_tEC1EPKcj@@GLIBCXX_3.4 implicit parameter 0 of type 'std::codecvt_byname*' has sub-type changes: in pointed to type 'class std::codecvt_byname' at codecvt.h:458:1: type size hasn't changed diff --git a/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt b/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt index 3616cb3435bd..741487af86f8 100644 --- a/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt +++ b/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-0.txt @@ -317,20 +317,18 @@ ================ end of changes of 'libtbbmalloc.so.2'=============== ================ changes of 'libtbbmalloc_proxy.so.2'=============== - Functions changes summary: 1 Removed, 0 Changed, 5 Added functions + Functions changes summary: 1 Removed, 0 Changed, 3 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 Removed function: [D] 'function bool __TBB_internal_find_original_malloc(int, const char**, void**)' {__TBB_internal_find_original_malloc} - 5 Added functions: + 3 Added functions: [A] 'function void __libc_free(void*)' {__libc_free} [A] 'function void* __libc_realloc(void*, size_t)' {__libc_realloc} - [A] 'function void* calloc(size_t, size_t)' {__libc_calloc, aliases calloc} [A] 'function size_t malloc_usable_size(void*)' {malloc_usable_size} - [A] 'function void* valloc(size_t)' {__libc_valloc, aliases valloc} ================ end of changes of 'libtbbmalloc_proxy.so.2'=============== diff --git a/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt b/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt index dcd30874496b..9438b4ed8b00 100644 --- a/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt +++ b/tests/data/test-diff-pkg/tbb-4.1-9.20130314.fc22.x86_64--tbb-4.3-3.20141204.fc23.x86_64-report-1.txt @@ -165,20 +165,18 @@ ================ end of changes of 'libtbbmalloc.so.2'=============== ================ changes of 'libtbbmalloc_proxy.so.2'=============== - Functions changes summary: 1 Removed, 0 Changed, 5 Added functions + Functions changes summary: 1 Removed, 0 Changed, 3 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 Removed function: [D] 'function bool __TBB_internal_find_original_malloc(int, const char**, void**)' {__TBB_internal_find_original_malloc} - 5 Added functions: + 3 Added functions: [A] 'function void __libc_free(void*)' {__libc_free} [A] 'function void* __libc_realloc(void*, size_t)' {__libc_realloc} - [A] 'function void* calloc(size_t, size_t)' {__libc_calloc, aliases calloc} [A] 'function size_t malloc_usable_size(void*)' {malloc_usable_size} - [A] 'function void* valloc(size_t)' {__libc_valloc, aliases valloc} ================ end of changes of 'libtbbmalloc_proxy.so.2'=============== diff --git a/tests/data/test-diff-suppr/test23-alias-filter-4.suppr b/tests/data/test-diff-suppr/test23-alias-filter-4.suppr index b7429d14505f..16edb095bbbf 100644 --- a/tests/data/test-diff-suppr/test23-alias-filter-4.suppr +++ b/tests/data/test-diff-suppr/test23-alias-filter-4.suppr @@ -1,3 +1,3 @@ [suppress_function] - symbol_name_regexp = function1 + symbol_name_regexp = __private_function allow_other_aliases = no diff --git a/tests/data/test-diff-suppr/test23-alias-filter-report-0.txt b/tests/data/test-diff-suppr/test23-alias-filter-report-0.txt index 0788d48931f7..8b06f3151b63 100644 --- a/tests/data/test-diff-suppr/test23-alias-filter-report-0.txt +++ b/tests/data/test-diff-suppr/test23-alias-filter-report-0.txt @@ -4,8 +4,8 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 function with some indirect sub-type change: [C] 'function void __private_function(S*)' has some indirect sub-type changes: - Please note that the symbol of this function is function1@VERSION_1.0 - and it aliases symbols: __private_function@PRIVATE_1.0, function2@VERSION_1.0 + Please note that the symbol of this function is __private_function@PRIVATE_1.0 + and it aliases symbols: function2@VERSION_1.0, function1@VERSION_1.0 parameter 1 of type 'S*' has sub-type changes: in pointed to type 'typedef S': underlying type 'struct S' changed: diff --git a/tests/data/test-diff-suppr/test23-alias-filter-report-2.txt b/tests/data/test-diff-suppr/test23-alias-filter-report-2.txt index 0788d48931f7..8b06f3151b63 100644 --- a/tests/data/test-diff-suppr/test23-alias-filter-report-2.txt +++ b/tests/data/test-diff-suppr/test23-alias-filter-report-2.txt @@ -4,8 +4,8 @@ Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 function with some indirect sub-type change: [C] 'function void __private_function(S*)' has some indirect sub-type changes: - Please note that the symbol of this function is function1@VERSION_1.0 - and it aliases symbols: __private_function@PRIVATE_1.0, function2@VERSION_1.0 + Please note that the symbol of this function is __private_function@PRIVATE_1.0 + and it aliases symbols: function2@VERSION_1.0, function1@VERSION_1.0 parameter 1 of type 'S*' has sub-type changes: in pointed to type 'typedef S': underlying type 'struct S' changed: diff --git a/tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi b/tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi index 1fc1578e66e6..a8bbcf088f87 100644 --- a/tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi +++ b/tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi @@ -36,13 +36,13 @@ - - + + - - + + @@ -50,31 +50,31 @@ - + - + - - + + - - + + - + - + @@ -90,8 +90,8 @@ - - + + @@ -100,8 +100,8 @@ - - + + @@ -506,13 +506,13 @@ - + - + @@ -656,7 +656,7 @@ - + @@ -723,7 +723,7 @@ - + @@ -747,7 +747,7 @@ - + @@ -816,7 +816,7 @@ - + @@ -1418,7 +1418,7 @@ - + @@ -1582,7 +1582,7 @@ - + diff --git a/tests/data/test-read-dwarf/PR22122-libftdc.so.abi b/tests/data/test-read-dwarf/PR22122-libftdc.so.abi index a90c17dfacd6..e7a50ee9ac50 100644 --- a/tests/data/test-read-dwarf/PR22122-libftdc.so.abi +++ b/tests/data/test-read-dwarf/PR22122-libftdc.so.abi @@ -151,8 +151,8 @@ - - + + @@ -4809,7 +4809,7 @@ - + diff --git a/tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi b/tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi index c6fa10347cda..faa3faa186b5 100644 --- a/tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi +++ b/tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi @@ -36,8 +36,8 @@ - - + + @@ -45,24 +45,24 @@ - + - + - - + + - - - - - - + + + + + + @@ -88,16 +88,16 @@ - - + + - + - - + + - + @@ -109,10 +109,10 @@ - - - - + + + + @@ -167,30 +167,30 @@ - + - + - + - + - - + + - - + + - - + + @@ -213,27 +213,27 @@ - - + + - - + + - - + + - - + + - - + + @@ -254,24 +254,24 @@ - - - - + + + + - + - + - - + + - - + + @@ -282,8 +282,8 @@ - - + + @@ -362,9 +362,9 @@ - + - + @@ -1025,7 +1025,7 @@ - + @@ -1536,7 +1536,7 @@ - + @@ -1627,7 +1627,7 @@ - + @@ -1660,7 +1660,7 @@ - + @@ -1705,13 +1705,13 @@ - + - + @@ -1750,7 +1750,7 @@ - + @@ -1758,7 +1758,7 @@ - + @@ -3242,7 +3242,7 @@ - + @@ -3372,7 +3372,7 @@ - + @@ -3392,7 +3392,7 @@ - + @@ -3535,7 +3535,7 @@ - + @@ -3701,13 +3701,13 @@ - + - + @@ -3728,7 +3728,7 @@ - + @@ -3756,7 +3756,7 @@ - + @@ -3965,7 +3965,7 @@ - + @@ -4041,7 +4041,7 @@ - + @@ -4168,20 +4168,20 @@ - + - + - + @@ -4276,20 +4276,20 @@ - + - + - + @@ -4461,7 +4461,7 @@ - + @@ -4629,20 +4629,20 @@ - + - + - + @@ -4722,7 +4722,7 @@ - + @@ -4763,7 +4763,7 @@ - + @@ -4829,13 +4829,13 @@ - + - + @@ -5204,7 +5204,7 @@ - + @@ -5213,7 +5213,7 @@ - + @@ -5264,35 +5264,35 @@ - + - + - + - + - + @@ -5791,7 +5791,7 @@ - + diff --git a/tests/data/test-read-dwarf/test11-pr18828.so.abi b/tests/data/test-read-dwarf/test11-pr18828.so.abi index 1aa056ef2b5f..6734a8e437c7 100644 --- a/tests/data/test-read-dwarf/test11-pr18828.so.abi +++ b/tests/data/test-read-dwarf/test11-pr18828.so.abi @@ -40,24 +40,24 @@ - - - - + + + + - + - - + + - + - - + + @@ -71,22 +71,22 @@ - - - - + + + + - - - - + + + + - - - - + + + + @@ -97,16 +97,16 @@ - - - - + + + + - - + + @@ -115,8 +115,8 @@ - - + + @@ -130,11 +130,11 @@ - - + + - - + + @@ -145,20 +145,20 @@ - - + + - - + + - - + + - - + + @@ -171,8 +171,8 @@ - - + + @@ -183,11 +183,11 @@ - + - - - + + + @@ -205,8 +205,8 @@ - - + + @@ -232,44 +232,44 @@ - - - - - - - - + + + + + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - + + - - + + @@ -326,25 +326,25 @@ - + - - - + + + - - - - - - - - - - + + + + + + + + + + @@ -352,30 +352,30 @@ - - + + - - - - - - + + + + + + - - - - + + + + @@ -383,12 +383,12 @@ - - - - - - + + + + + + @@ -398,31 +398,31 @@ - - - - + + + + - - - - - - + + + + + + - - - - + + + + - - + + @@ -431,34 +431,34 @@ - - - - - - + + + + + + - - + + - - + + - - + + - - + + @@ -469,12 +469,12 @@ - - + + - - + + @@ -494,20 +494,20 @@ - - - - - - + + + + + + - - + + - - + + @@ -518,33 +518,33 @@ - - - - - - + + + + + + - - - - - - - - + + + + + + + + - - - - + + + + @@ -568,12 +568,12 @@ - + - + - - + + @@ -3510,7 +3510,7 @@ - + @@ -3544,7 +3544,7 @@ - + @@ -3591,14 +3591,14 @@ - + - + @@ -3829,7 +3829,7 @@ - + @@ -3876,14 +3876,14 @@ - + - + @@ -3937,14 +3937,14 @@ - + - + @@ -4064,13 +4064,13 @@ - + - + @@ -4131,7 +4131,7 @@ - + @@ -4241,13 +4241,13 @@ - + - + @@ -4332,13 +4332,13 @@ - + - + @@ -4378,7 +4378,7 @@ - + @@ -4431,7 +4431,7 @@ - + @@ -4445,7 +4445,7 @@ - + @@ -4500,7 +4500,7 @@ - + @@ -4515,7 +4515,7 @@ - + @@ -4536,7 +4536,7 @@ - + @@ -4722,7 +4722,7 @@ - + @@ -4776,7 +4776,7 @@ - + @@ -4901,14 +4901,14 @@ - + - + @@ -5003,14 +5003,14 @@ - + - + @@ -5250,7 +5250,7 @@ - + @@ -5475,7 +5475,7 @@ - + @@ -5587,7 +5587,7 @@ - + @@ -5647,7 +5647,7 @@ - + @@ -5728,7 +5728,7 @@ - + @@ -7256,7 +7256,7 @@ - + @@ -8548,7 +8548,7 @@ - + @@ -8627,7 +8627,7 @@ - + @@ -8848,7 +8848,7 @@ - + @@ -9064,7 +9064,7 @@ - + @@ -9278,13 +9278,13 @@ - + - + @@ -9864,7 +9864,7 @@ - + @@ -10983,7 +10983,7 @@ - + @@ -11153,11 +11153,11 @@ - + - + @@ -11178,7 +11178,7 @@ - + @@ -11190,7 +11190,7 @@ - + @@ -11265,7 +11265,7 @@ - + @@ -11315,7 +11315,7 @@ - + @@ -11424,7 +11424,7 @@ - + @@ -11460,7 +11460,7 @@ - + @@ -11515,7 +11515,7 @@ - + @@ -11727,7 +11727,7 @@ - + @@ -11749,7 +11749,7 @@ - + @@ -11829,7 +11829,7 @@ - + @@ -11851,7 +11851,7 @@ - + @@ -11894,21 +11894,21 @@ - + - + - + @@ -11922,7 +11922,7 @@ - + @@ -12063,14 +12063,14 @@ - + - + @@ -13032,13 +13032,13 @@ - + - + @@ -13144,7 +13144,7 @@ - + @@ -13163,7 +13163,7 @@ - + @@ -13417,7 +13417,7 @@ - + @@ -13471,7 +13471,7 @@ - + @@ -13550,7 +13550,7 @@ - + @@ -13630,7 +13630,7 @@ - + @@ -13645,7 +13645,7 @@ - + @@ -14005,7 +14005,7 @@ - + @@ -14058,7 +14058,7 @@ - + @@ -14375,14 +14375,14 @@ - + - + @@ -14702,7 +14702,7 @@ - + @@ -14736,7 +14736,7 @@ - + @@ -14758,7 +14758,7 @@ - + @@ -14800,7 +14800,7 @@ - + @@ -14815,7 +14815,7 @@ - + @@ -14945,7 +14945,7 @@ - + @@ -14970,7 +14970,7 @@ - + @@ -15037,7 +15037,7 @@ - + @@ -15062,7 +15062,7 @@ - + @@ -16032,7 +16032,7 @@ - + @@ -16161,13 +16161,13 @@ - + - + diff --git a/tests/data/test-read-dwarf/test12-pr18844.so.abi b/tests/data/test-read-dwarf/test12-pr18844.so.abi index 81dac4eed196..4422b76a7394 100644 --- a/tests/data/test-read-dwarf/test12-pr18844.so.abi +++ b/tests/data/test-read-dwarf/test12-pr18844.so.abi @@ -231,47 +231,47 @@ - - + + - - + + - - + + - - - + + + - + - - + + - - + + - - - - + + + + - - + + @@ -19191,7 +19191,7 @@ - + @@ -19217,7 +19217,7 @@ - + @@ -19231,7 +19231,7 @@ - + @@ -19281,7 +19281,7 @@ - + @@ -19291,7 +19291,7 @@ - + @@ -19378,7 +19378,7 @@ - + @@ -19511,7 +19511,7 @@ - + @@ -23762,14 +23762,14 @@ - + - + @@ -24442,7 +24442,7 @@ - + @@ -25563,7 +25563,7 @@ - + @@ -28277,14 +28277,14 @@ - + - + diff --git a/tests/data/test-read-dwarf/test15-pr18892.so.abi b/tests/data/test-read-dwarf/test15-pr18892.so.abi index 34ff0fb859b8..d4bd4ad68236 100644 --- a/tests/data/test-read-dwarf/test15-pr18892.so.abi +++ b/tests/data/test-read-dwarf/test15-pr18892.so.abi @@ -101,72 +101,72 @@ - + - + - - - - - - + + + + + + - - + + - + - - + + - + - + - - - - + + + + - - - - - + + + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + @@ -175,209 +175,209 @@ - + - + - - - + + + - + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - + - - + + - - - - - - + + + + + + - - + + - - - + + + - - - + + + - + - + - + - - + + - - - - - + + + + + - - - + + + - + - + - + - - + + - + - + - + - - + + - - + + - - - - + + + + - + - - - - - + + + + + - - - - + + + + - - - + + + - + - + - + - + - + - - + + - - + + - + - - + + - + @@ -385,50 +385,50 @@ - + - + - + - + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - + - + - - - - - - + + + + + + - - + + @@ -1116,9 +1116,9 @@ - + - + @@ -1208,9 +1208,9 @@ - + - + @@ -1219,53 +1219,53 @@ - + - - + + - + - + - - - - + + + + - - - - - + + + + + - - + + - - - + + + - - - + + + - - - + + + - - - + + + @@ -1274,209 +1274,209 @@ - + - + - - - + + + - + - - + + - + - - + + - - + + - - + + - - + + - + - - + + - - + + - + - - + + - - - - - - + + + + + + - - + + - - - + + + - - - + + + - + - + - + - - + + - - - - - + + + + + - - - + + + - + - + - + - - + + - + - + - + - - + + - - + + - - - - + + + + - + - - - - - + + + + + - - - - + + + + - - - + + + - + - + - + - + - + - - + + - - + + - + - - + + - + @@ -1484,40 +1484,40 @@ - + - + - + - + - - - + + + - - - + + + - - - + + + - - + + - - - + + + - + - + @@ -8444,17 +8444,17 @@ - + - + - + @@ -11967,7 +11967,7 @@ - + @@ -11982,7 +11982,7 @@ - + @@ -11993,7 +11993,7 @@ - + @@ -12008,12 +12008,12 @@ - + - + @@ -12021,23 +12021,23 @@ - + - + - + - + @@ -12055,7 +12055,7 @@ - + @@ -12066,20 +12066,20 @@ - + - + - + - + @@ -12090,7 +12090,7 @@ - + @@ -12101,12 +12101,12 @@ - + - + @@ -12116,12 +12116,12 @@ - + - + @@ -12137,28 +12137,28 @@ - + - + - + - + - + @@ -12171,17 +12171,17 @@ - + - + - + @@ -12196,7 +12196,7 @@ - + @@ -12216,7 +12216,7 @@ - + @@ -12231,7 +12231,7 @@ - + @@ -12249,11 +12249,11 @@ - + - + @@ -12273,11 +12273,11 @@ - + - + @@ -12291,7 +12291,7 @@ - + @@ -12307,14 +12307,14 @@ - + - + @@ -12339,13 +12339,13 @@ - + - + @@ -12355,19 +12355,19 @@ - + - + - + @@ -12384,7 +12384,7 @@ - + @@ -12397,7 +12397,7 @@ - + @@ -12405,36 +12405,36 @@ - + - + - + - + - + - + @@ -12461,7 +12461,7 @@ - + @@ -12471,11 +12471,11 @@ - + - + @@ -12487,12 +12487,12 @@ - + - + @@ -12533,7 +12533,7 @@ - + @@ -12542,7 +12542,7 @@ - + @@ -12576,7 +12576,7 @@ - + @@ -12592,7 +12592,7 @@ - + @@ -12610,14 +12610,14 @@ - + - + @@ -12629,7 +12629,7 @@ - + @@ -12646,17 +12646,17 @@ - + - + - + @@ -12666,47 +12666,47 @@ - + - + - + - + - + - + - + - + @@ -12724,18 +12724,18 @@ - + - + - + @@ -12746,7 +12746,7 @@ - + @@ -12755,12 +12755,12 @@ - + - + @@ -12769,11 +12769,11 @@ - + - + @@ -12782,11 +12782,11 @@ - + - + @@ -12794,14 +12794,14 @@ - + - + @@ -12814,41 +12814,41 @@ - + - + - + - + - + - + @@ -12868,7 +12868,7 @@ - + @@ -12879,7 +12879,7 @@ - + @@ -12889,7 +12889,7 @@ - + @@ -12911,7 +12911,7 @@ - + @@ -12926,12 +12926,12 @@ - + - + @@ -12949,7 +12949,7 @@ - + @@ -12960,14 +12960,14 @@ - + - + @@ -12978,7 +12978,7 @@ - + @@ -12986,7 +12986,7 @@ - + @@ -12994,7 +12994,7 @@ - + @@ -13023,11 +13023,11 @@ - + - + @@ -13040,7 +13040,7 @@ - + @@ -13065,11 +13065,11 @@ - + - + @@ -13082,13 +13082,13 @@ - + - + @@ -13107,7 +13107,7 @@ - + @@ -13115,13 +13115,13 @@ - + - + @@ -13132,12 +13132,12 @@ - + - + @@ -13157,7 +13157,7 @@ - + @@ -13185,12 +13185,12 @@ - + - + @@ -13201,7 +13201,7 @@ - + @@ -13212,13 +13212,13 @@ - + - + @@ -13238,7 +13238,7 @@ - + @@ -13251,17 +13251,17 @@ - + - + - + @@ -13274,7 +13274,7 @@ - + @@ -13299,7 +13299,7 @@ - + @@ -13307,12 +13307,12 @@ - + - + @@ -13337,7 +13337,7 @@ - + @@ -13345,7 +13345,7 @@ - + @@ -13355,7 +13355,7 @@ - + @@ -13363,7 +13363,7 @@ - + @@ -13429,7 +13429,7 @@ - + @@ -13447,7 +13447,7 @@ - + @@ -13458,7 +13458,7 @@ - + @@ -13473,7 +13473,7 @@ - + @@ -13497,7 +13497,7 @@ - + @@ -13549,11 +13549,11 @@ - + - + @@ -13561,12 +13561,12 @@ - + - + @@ -13576,11 +13576,11 @@ - + - + @@ -13590,12 +13590,12 @@ - + - + @@ -13619,7 +13619,7 @@ - + @@ -13628,7 +13628,7 @@ - + @@ -15769,7 +15769,7 @@ - + @@ -15779,7 +15779,7 @@ - + diff --git a/tests/data/test-read-dwarf/test16-pr18904.so.abi b/tests/data/test-read-dwarf/test16-pr18904.so.abi index 01605868fc1b..310a8a6bd2a7 100644 --- a/tests/data/test-read-dwarf/test16-pr18904.so.abi +++ b/tests/data/test-read-dwarf/test16-pr18904.so.abi @@ -41,16 +41,16 @@ - - - - + + + + - - - - + + + + @@ -58,8 +58,8 @@ - - + + @@ -67,16 +67,16 @@ - - + + - - + + @@ -95,11 +95,11 @@ - - + + - - + + @@ -123,10 +123,10 @@ - - - - + + + + @@ -156,10 +156,10 @@ - - - - + + + + @@ -180,18 +180,18 @@ - - - - + + + + - - + + @@ -199,14 +199,14 @@ - + - + - - + + @@ -215,20 +215,20 @@ - - + + - - + + - - + + @@ -242,30 +242,30 @@ - + - + - - + + - - + + - + - + - - + + @@ -273,35 +273,35 @@ - - - - + + + + - - - - - - + + + + + + - - - - + + + + - - - - + + + + @@ -316,8 +316,8 @@ - - + + @@ -329,30 +329,30 @@ - - + + - - - - + + + + - + - + - - + + @@ -386,20 +386,20 @@ - - - - + + + + - - + + - - + + @@ -584,57 +584,57 @@ - - - - + + + + - - + + - - - - + + + + - - + + - - - - + + + + - - + + - - + + - - - - - - + + + + + + - - + + @@ -647,7 +647,7 @@ - + @@ -655,17 +655,17 @@ - + - + - + @@ -687,10 +687,10 @@ - - - - + + + + @@ -706,17 +706,17 @@ - - - - + + + + - - + + - - + + @@ -725,73 +725,73 @@ - - + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + - - + + - + - + - + - + @@ -819,28 +819,28 @@ - - + + - - + + - - + + - - + + - - + + @@ -859,20 +859,20 @@ - + - + - + - + - - + + @@ -881,8 +881,8 @@ - - + + @@ -892,40 +892,40 @@ - - + + - + - + - + - + - + - + - - + + - - + + @@ -934,18 +934,18 @@ - - - - + + + + - - + + @@ -956,63 +956,63 @@ - + - + - + - + - + - + - + - + - + - - - + + + - - - - - - - - - + + + + + + + + + - - + + - - + + - - - + + + @@ -1025,13 +1025,13 @@ - - - - + + + + - - + + @@ -1040,10 +1040,10 @@ - - - - + + + + @@ -1056,8 +1056,8 @@ - - + + @@ -1069,8 +1069,8 @@ - - + + @@ -1100,10 +1100,10 @@ - - - - + + + + @@ -1119,8 +1119,8 @@ - - + + @@ -1134,8 +1134,8 @@ - - + + @@ -1145,45 +1145,45 @@ - - + + - - + + - - + + - + - + - + - + - - + + - - + + @@ -1194,8 +1194,8 @@ - - + + @@ -1207,8 +1207,8 @@ - - + + @@ -1218,23 +1218,23 @@ - - + + - - + + - - + + - - + + @@ -1255,8 +1255,8 @@ - - + + @@ -1281,13 +1281,13 @@ - - - - + + + + - - + + @@ -1296,8 +1296,8 @@ - - + + @@ -1341,16 +1341,16 @@ - - + + - - + + @@ -1371,8 +1371,8 @@ - - + + @@ -1382,16 +1382,16 @@ - + - + - - - - + + + + @@ -1400,8 +1400,8 @@ - - + + @@ -1423,11 +1423,11 @@ - + - - - + + + @@ -1479,9 +1479,9 @@ - + - + @@ -1525,12 +1525,12 @@ - + - - + + - + @@ -2419,13 +2419,13 @@ - + - + @@ -2590,7 +2590,7 @@ - + @@ -2636,14 +2636,14 @@ - + - + @@ -2669,14 +2669,14 @@ - + - + @@ -2784,7 +2784,7 @@ - + @@ -3166,7 +3166,7 @@ - + @@ -3210,7 +3210,7 @@ - + @@ -3330,7 +3330,7 @@ - + @@ -3598,7 +3598,7 @@ - + @@ -4678,7 +4678,7 @@ - + @@ -4715,13 +4715,13 @@ - + - + @@ -4757,7 +4757,7 @@ - + @@ -4799,13 +4799,13 @@ - + - + @@ -4841,7 +4841,7 @@ - + @@ -4904,32 +4904,32 @@ - + - + - + - + - + @@ -5080,7 +5080,7 @@ - + @@ -5113,7 +5113,7 @@ - + @@ -5194,7 +5194,7 @@ - + @@ -5312,7 +5312,7 @@ - + @@ -5331,7 +5331,7 @@ - + @@ -5345,7 +5345,7 @@ - + @@ -5483,7 +5483,7 @@ - + @@ -5511,7 +5511,7 @@ - + @@ -5524,7 +5524,7 @@ - + @@ -5534,7 +5534,7 @@ - + @@ -5636,7 +5636,7 @@ - + @@ -5669,7 +5669,7 @@ - + @@ -5743,7 +5743,7 @@ - + @@ -5770,7 +5770,7 @@ - + @@ -6132,7 +6132,7 @@ - + @@ -6173,7 +6173,7 @@ - + @@ -6234,7 +6234,7 @@ - + @@ -6388,7 +6388,7 @@ - + @@ -6574,7 +6574,7 @@ - + @@ -6600,7 +6600,7 @@ - + @@ -6696,7 +6696,7 @@ - + @@ -6742,7 +6742,7 @@ - + @@ -6779,7 +6779,7 @@ - + @@ -6793,7 +6793,7 @@ - + @@ -6856,7 +6856,7 @@ - + @@ -6887,7 +6887,7 @@ - + @@ -6933,7 +6933,7 @@ - + @@ -6948,7 +6948,7 @@ - + @@ -6996,7 +6996,7 @@ - + @@ -7346,7 +7346,7 @@ - + @@ -7400,7 +7400,7 @@ - + @@ -7553,7 +7553,7 @@ - + @@ -7629,7 +7629,7 @@ - + @@ -7840,7 +7840,7 @@ - + @@ -7907,7 +7907,7 @@ - + @@ -7938,7 +7938,7 @@ - + @@ -7970,7 +7970,7 @@ - + @@ -7978,7 +7978,7 @@ - + @@ -7994,7 +7994,7 @@ - + @@ -8100,7 +8100,7 @@ - + @@ -8127,7 +8127,7 @@ - + @@ -8200,7 +8200,7 @@ - + @@ -8239,7 +8239,7 @@ - + @@ -8331,7 +8331,7 @@ - + @@ -8358,7 +8358,7 @@ - + @@ -8468,7 +8468,7 @@ - + @@ -8555,7 +8555,7 @@ - + @@ -8580,13 +8580,13 @@ - + - + @@ -8620,7 +8620,7 @@ - + @@ -8696,7 +8696,7 @@ - + @@ -8798,7 +8798,7 @@ - + @@ -8814,7 +8814,7 @@ - + @@ -8822,7 +8822,7 @@ - + @@ -8987,7 +8987,7 @@ - + @@ -9078,7 +9078,7 @@ - + @@ -9147,7 +9147,7 @@ - + @@ -9397,7 +9397,7 @@ - + @@ -9460,7 +9460,7 @@ - + @@ -9482,7 +9482,7 @@ - + @@ -9497,7 +9497,7 @@ - + @@ -9543,7 +9543,7 @@ - + @@ -9567,7 +9567,7 @@ - + @@ -9634,7 +9634,7 @@ - + @@ -9648,7 +9648,7 @@ - + @@ -9741,7 +9741,7 @@ - + @@ -9820,7 +9820,7 @@ - + @@ -10022,13 +10022,13 @@ - + - + @@ -10073,7 +10073,7 @@ - + @@ -10117,7 +10117,7 @@ - + @@ -10197,7 +10197,7 @@ - + @@ -10315,7 +10315,7 @@ - + @@ -10333,7 +10333,7 @@ - + @@ -10378,7 +10378,7 @@ - + @@ -10415,7 +10415,7 @@ - + @@ -10453,7 +10453,7 @@ - + @@ -10471,7 +10471,7 @@ - + @@ -10558,7 +10558,7 @@ - + @@ -10590,7 +10590,7 @@ - + @@ -10683,7 +10683,7 @@ - + @@ -10699,7 +10699,7 @@ - + @@ -10873,13 +10873,13 @@ - + - + @@ -11344,14 +11344,14 @@ - + - + @@ -11363,14 +11363,14 @@ - + - + @@ -11606,7 +11606,7 @@ - + @@ -11618,7 +11618,7 @@ - + @@ -11630,7 +11630,7 @@ - + @@ -11642,7 +11642,7 @@ - + @@ -11654,7 +11654,7 @@ - + @@ -11717,7 +11717,7 @@ - + @@ -11839,7 +11839,7 @@ - + @@ -11851,7 +11851,7 @@ - + @@ -12002,7 +12002,7 @@ - + @@ -12234,7 +12234,7 @@ - + @@ -12251,7 +12251,7 @@ - + @@ -12264,7 +12264,7 @@ - + @@ -12277,7 +12277,7 @@ - + @@ -12751,7 +12751,7 @@ - + @@ -12949,7 +12949,7 @@ - + @@ -12957,7 +12957,7 @@ - + @@ -13028,7 +13028,7 @@ - + @@ -13036,7 +13036,7 @@ - + @@ -13222,13 +13222,13 @@ - + - + @@ -13304,7 +13304,7 @@ - + @@ -13347,7 +13347,7 @@ - + @@ -13407,7 +13407,7 @@ - + @@ -13495,7 +13495,7 @@ - + @@ -13929,7 +13929,7 @@ - + @@ -13955,7 +13955,7 @@ - + @@ -14016,7 +14016,7 @@ - + @@ -14071,7 +14071,7 @@ - + @@ -14121,7 +14121,7 @@ - + @@ -14577,7 +14577,7 @@ - + @@ -14807,7 +14807,7 @@ - + @@ -14844,7 +14844,7 @@ - + @@ -14859,7 +14859,7 @@ - + @@ -14941,7 +14941,7 @@ - + @@ -15151,7 +15151,7 @@ - + @@ -15216,7 +15216,7 @@ - + @@ -15261,14 +15261,14 @@ - + - + @@ -15733,13 +15733,13 @@ - + - + @@ -16084,14 +16084,14 @@ - + - + @@ -16101,7 +16101,7 @@ - + @@ -16132,7 +16132,7 @@ - + @@ -16153,14 +16153,14 @@ - + - + @@ -16183,7 +16183,7 @@ - + @@ -16325,7 +16325,7 @@ - + @@ -16436,7 +16436,7 @@ - + @@ -16470,7 +16470,7 @@ - + @@ -16561,7 +16561,7 @@ - + @@ -16634,7 +16634,7 @@ - + @@ -16648,7 +16648,7 @@ - + @@ -16707,7 +16707,7 @@ - + @@ -16791,11 +16791,11 @@ - + - + @@ -16944,7 +16944,7 @@ - + @@ -17204,7 +17204,7 @@ - + @@ -17357,7 +17357,7 @@ - + @@ -17617,13 +17617,13 @@ - + - + @@ -17665,7 +17665,7 @@ - + @@ -17778,13 +17778,13 @@ - + - + @@ -17831,7 +17831,7 @@ - + @@ -17862,13 +17862,13 @@ - + - + @@ -18629,7 +18629,7 @@ - + @@ -18641,7 +18641,7 @@ - + @@ -18653,7 +18653,7 @@ - + @@ -18665,7 +18665,7 @@ - + @@ -18677,7 +18677,7 @@ - + @@ -18727,7 +18727,7 @@ - + @@ -18772,7 +18772,7 @@ - + @@ -18880,7 +18880,7 @@ - + @@ -18914,7 +18914,7 @@ - + @@ -18970,7 +18970,7 @@ - + diff --git a/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi b/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi index d2e97237d139..8d9f97b626b9 100644 --- a/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi +++ b/tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi @@ -553,11 +553,11 @@ - - - + + + - + @@ -566,53 +566,53 @@ - + - + - + - + - + - + - - + + - - + + - - + + - + - - + + - + @@ -15241,7 +15241,7 @@ - + @@ -15251,17 +15251,17 @@ - + - + - + @@ -15275,7 +15275,7 @@ - + @@ -15288,7 +15288,7 @@ - + @@ -15305,11 +15305,11 @@ - + - + @@ -15318,11 +15318,11 @@ - + - + diff --git a/tests/data/test-read-dwarf/test2.so.abi b/tests/data/test-read-dwarf/test2.so.abi index 98dd9a607266..e3cee34c5826 100644 --- a/tests/data/test-read-dwarf/test2.so.abi +++ b/tests/data/test-read-dwarf/test2.so.abi @@ -6,10 +6,10 @@ - - - - + + + + @@ -35,7 +35,7 @@ - + @@ -63,7 +63,7 @@ - + diff --git a/tests/data/test-read-dwarf/test2.so.hash.abi b/tests/data/test-read-dwarf/test2.so.hash.abi index bb814f733f1d..5e1ae6d13ba7 100644 --- a/tests/data/test-read-dwarf/test2.so.hash.abi +++ b/tests/data/test-read-dwarf/test2.so.hash.abi @@ -6,10 +6,10 @@ - - - - + + + + @@ -35,7 +35,7 @@ - + @@ -63,7 +63,7 @@ - + diff --git a/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi b/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi index cd8fd33f43cf..8283fa8bdb28 100644 --- a/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi +++ b/tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi @@ -7,32 +7,32 @@ - - + + - - + + - - + + - - + + - - + + - - + + - - + + @@ -736,14 +736,14 @@ - + - + - + - + @@ -837,32 +837,32 @@ - - + + - + - + - - + + - - - + + + - + - + - - + + - + @@ -949,8 +949,8 @@ - - + + @@ -985,8 +985,8 @@ - - + + @@ -1075,33 +1075,33 @@ - - - + + + - + - - + + - - - + + + - + - - + + - - + + @@ -1130,45 +1130,45 @@ - + - - + + - + - - + + - + - + - + - - + + - + - - - - - - + + + + + + - - + + @@ -1179,25 +1179,25 @@ - - + + - - + + - - - - - - + + + + + + - - + + @@ -1205,16 +1205,16 @@ - - - - + + + + - - + + - - + + @@ -1229,16 +1229,16 @@ - - + + - - + + @@ -1257,11 +1257,11 @@ - - + + - - + + @@ -1273,25 +1273,25 @@ - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - + + @@ -1304,8 +1304,8 @@ - - + + @@ -1360,8 +1360,8 @@ - - + + @@ -1420,8 +1420,8 @@ - - + + @@ -1456,8 +1456,8 @@ - - + + @@ -1493,8 +1493,8 @@ - - + + @@ -1557,36 +1557,36 @@ - - + + - - + + - - + + - - + + - - + + - - + + @@ -1597,12 +1597,12 @@ - + - - + + - + @@ -1646,8 +1646,8 @@ - - + + @@ -1683,9 +1683,9 @@ - + - + @@ -1703,9 +1703,9 @@ - + - + @@ -1721,59 +1721,59 @@ - + - + - - + + - - + + - - + + - - - - + + + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + @@ -1781,61 +1781,61 @@ - - + + - - + + - - - - + + + + - - - - + + + + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + - - + + @@ -1869,8 +1869,8 @@ - - + + @@ -1909,24 +1909,24 @@ - - + + - + - + - - + + - - - - + + + + - - + + @@ -1947,37 +1947,37 @@ - + - + - - + + - - + + - - - - + + + + - - - - + + + + - - + + @@ -1995,24 +1995,24 @@ - - + + - - + + - + - + - - - - + + + + @@ -2021,16 +2021,16 @@ - - + + - - + + - - + + @@ -2044,23 +2044,23 @@ - - - - + + + + - - + + - - + + - - + + @@ -2068,33 +2068,33 @@ - - - - + + + + - - + + - - + + - - - - - - + + + + + + - - + + @@ -2108,19 +2108,19 @@ - - + + - + - + - - + + @@ -2148,12 +2148,12 @@ - + - + - - + + @@ -2173,20 +2173,20 @@ - - + + - - - - + + + + - - + + @@ -3697,7 +3697,7 @@ - + @@ -3885,7 +3885,7 @@ - + @@ -4019,7 +4019,7 @@ - + @@ -4229,7 +4229,7 @@ - + @@ -4969,13 +4969,13 @@ - + - + @@ -5152,7 +5152,7 @@ - + @@ -5190,7 +5190,7 @@ - + @@ -5232,7 +5232,7 @@ - + @@ -5354,7 +5354,7 @@ - + @@ -5579,7 +5579,7 @@ - + @@ -5883,7 +5883,7 @@ - + @@ -6599,7 +6599,7 @@ - + @@ -6705,7 +6705,7 @@ - + @@ -7271,7 +7271,7 @@ - + @@ -8061,14 +8061,14 @@ - + - + @@ -8494,7 +8494,7 @@ - + @@ -8512,7 +8512,7 @@ - + @@ -8557,7 +8557,7 @@ - + @@ -8565,7 +8565,7 @@ - + @@ -8690,7 +8690,7 @@ - + @@ -9095,7 +9095,7 @@ - + @@ -9205,7 +9205,7 @@ - + @@ -9621,7 +9621,7 @@ - + @@ -10054,7 +10054,7 @@ - + @@ -10089,7 +10089,7 @@ - + @@ -10098,7 +10098,7 @@ - + @@ -10259,7 +10259,7 @@ - + @@ -10429,7 +10429,7 @@ - + @@ -10506,7 +10506,7 @@ - + @@ -11462,7 +11462,7 @@ - + @@ -12472,7 +12472,7 @@ - + @@ -13903,7 +13903,7 @@ - + @@ -14693,14 +14693,14 @@ - + - + @@ -15126,7 +15126,7 @@ - + @@ -15144,7 +15144,7 @@ - + @@ -15189,7 +15189,7 @@ - + @@ -15197,7 +15197,7 @@ - + @@ -15322,7 +15322,7 @@ - + @@ -15725,7 +15725,7 @@ - + @@ -15835,7 +15835,7 @@ - + @@ -16251,7 +16251,7 @@ - + @@ -16684,7 +16684,7 @@ - + @@ -16719,7 +16719,7 @@ - + @@ -16728,7 +16728,7 @@ - + @@ -16889,7 +16889,7 @@ - + @@ -16945,7 +16945,7 @@ - + @@ -17001,7 +17001,7 @@ - + @@ -17060,7 +17060,7 @@ - + @@ -17081,7 +17081,7 @@ - + @@ -17142,13 +17142,13 @@ - + - + @@ -17398,7 +17398,7 @@ - + @@ -18182,7 +18182,7 @@ - + @@ -18454,7 +18454,7 @@ - + @@ -18509,7 +18509,7 @@ - + @@ -18915,7 +18915,7 @@ - + @@ -19171,7 +19171,7 @@ - + @@ -20215,7 +20215,7 @@ - + @@ -21404,7 +21404,7 @@ - + @@ -21664,7 +21664,7 @@ - + @@ -21849,7 +21849,7 @@ - + @@ -21872,7 +21872,7 @@ - + @@ -22020,14 +22020,14 @@ - + - + @@ -22063,7 +22063,7 @@ - + @@ -22350,7 +22350,7 @@ - + @@ -22434,14 +22434,14 @@ - + - + @@ -22825,14 +22825,14 @@ - + - + @@ -22865,7 +22865,7 @@ - + @@ -22889,7 +22889,7 @@ - + @@ -22914,7 +22914,7 @@ - + @@ -22953,7 +22953,7 @@ - + @@ -23698,7 +23698,7 @@ - + @@ -23899,7 +23899,7 @@ - + @@ -24208,7 +24208,7 @@ - + @@ -24817,7 +24817,7 @@ - + @@ -25194,7 +25194,7 @@ - + @@ -26002,7 +26002,7 @@ - + @@ -26010,7 +26010,7 @@ - + @@ -26164,14 +26164,14 @@ - + - + @@ -26179,7 +26179,7 @@ - + @@ -26265,7 +26265,7 @@ - + @@ -26386,7 +26386,7 @@ - + @@ -26465,7 +26465,7 @@ - + @@ -26520,7 +26520,7 @@ - + @@ -26731,14 +26731,14 @@ - + - + @@ -26932,7 +26932,7 @@ - + @@ -26987,7 +26987,7 @@ - + @@ -27109,7 +27109,7 @@ - + @@ -27373,7 +27373,7 @@ - + @@ -27388,7 +27388,7 @@ - + @@ -27465,7 +27465,7 @@ - + @@ -27597,7 +27597,7 @@ - + @@ -27791,7 +27791,7 @@ - + @@ -27806,7 +27806,7 @@ - + @@ -28000,14 +28000,14 @@ - + - + @@ -28015,7 +28015,7 @@ - + @@ -28092,7 +28092,7 @@ - + @@ -28203,14 +28203,14 @@ - + - + @@ -28357,14 +28357,14 @@ - + - + @@ -28372,7 +28372,7 @@ - + @@ -28424,7 +28424,7 @@ - + @@ -28975,7 +28975,7 @@ - + @@ -29366,7 +29366,7 @@ - + @@ -29394,7 +29394,7 @@ - + @@ -29468,7 +29468,7 @@ - + @@ -29496,7 +29496,7 @@ - + @@ -29762,7 +29762,7 @@ - + @@ -29880,7 +29880,7 @@ - + @@ -30053,7 +30053,7 @@ - + @@ -30074,7 +30074,7 @@ - + @@ -30247,7 +30247,7 @@ - + @@ -30744,7 +30744,7 @@ - + @@ -30788,7 +30788,7 @@ - + @@ -32844,7 +32844,7 @@ - + @@ -33902,7 +33902,7 @@ - + @@ -33930,7 +33930,7 @@ - + @@ -36168,7 +36168,7 @@ - + @@ -37544,7 +37544,7 @@ - + @@ -37721,7 +37721,7 @@ - + @@ -37805,14 +37805,14 @@ - + - + @@ -38196,14 +38196,14 @@ - + - + @@ -38236,7 +38236,7 @@ - + @@ -38260,7 +38260,7 @@ - + @@ -38285,7 +38285,7 @@ - + @@ -38678,7 +38678,7 @@ - + @@ -39171,7 +39171,7 @@ - + @@ -39567,14 +39567,14 @@ - + - + @@ -39610,7 +39610,7 @@ - + @@ -39864,7 +39864,7 @@ - + @@ -40019,7 +40019,7 @@ - + @@ -41369,7 +41369,7 @@ - + @@ -41392,7 +41392,7 @@ - + @@ -43569,7 +43569,7 @@ - + @@ -43591,7 +43591,7 @@ - + @@ -43609,7 +43609,7 @@ - + @@ -43649,7 +43649,7 @@ - + @@ -43689,7 +43689,7 @@ - + @@ -43711,7 +43711,7 @@ - + @@ -43754,7 +43754,7 @@ - + @@ -43797,7 +43797,7 @@ - + @@ -43815,7 +43815,7 @@ - + @@ -43855,7 +43855,7 @@ - + @@ -43877,7 +43877,7 @@ - + @@ -44203,7 +44203,7 @@ - + @@ -44258,7 +44258,7 @@ - + @@ -44390,7 +44390,7 @@ - + @@ -44471,14 +44471,14 @@ - + - + @@ -44623,14 +44623,14 @@ - + - + @@ -44638,7 +44638,7 @@ - + @@ -44690,7 +44690,7 @@ - + @@ -44780,7 +44780,7 @@ - + @@ -44896,7 +44896,7 @@ - + @@ -44972,7 +44972,7 @@ - + @@ -45164,14 +45164,14 @@ - + - + @@ -45179,7 +45179,7 @@ - + @@ -45256,7 +45256,7 @@ - + @@ -45382,7 +45382,7 @@ - + @@ -45410,7 +45410,7 @@ - + @@ -45612,7 +45612,7 @@ - + @@ -45627,7 +45627,7 @@ - + @@ -45704,7 +45704,7 @@ - + @@ -45830,7 +45830,7 @@ - + @@ -45858,7 +45858,7 @@ - + @@ -45887,7 +45887,7 @@ - + @@ -46068,7 +46068,7 @@ - + @@ -46153,7 +46153,7 @@ - + @@ -46168,7 +46168,7 @@ - + @@ -46472,7 +46472,7 @@ - + @@ -46480,7 +46480,7 @@ - + @@ -46737,7 +46737,7 @@ - + @@ -46758,7 +46758,7 @@ - + @@ -46943,7 +46943,7 @@ - + @@ -46984,7 +46984,7 @@ - + @@ -47505,14 +47505,14 @@ - + - + @@ -47520,7 +47520,7 @@ - + @@ -47606,7 +47606,7 @@ - + @@ -47777,7 +47777,7 @@ - + @@ -48154,14 +48154,14 @@ - + - + @@ -48292,7 +48292,7 @@ - + @@ -49033,7 +49033,7 @@ - + @@ -49234,7 +49234,7 @@ - + @@ -49541,7 +49541,7 @@ - + @@ -51450,7 +51450,7 @@ - + @@ -51476,7 +51476,7 @@ - + @@ -51520,7 +51520,7 @@ - + @@ -51541,7 +51541,7 @@ - + @@ -51617,7 +51617,7 @@ - + @@ -51672,7 +51672,7 @@ - + @@ -51731,7 +51731,7 @@ - + @@ -51748,7 +51748,7 @@ - + @@ -51769,7 +51769,7 @@ - + @@ -52056,7 +52056,7 @@ - + @@ -52087,7 +52087,7 @@ - + @@ -52095,7 +52095,7 @@ - + @@ -52103,7 +52103,7 @@ - + @@ -52111,7 +52111,7 @@ - + @@ -52120,7 +52120,7 @@ - + @@ -52129,7 +52129,7 @@ - + @@ -52152,7 +52152,7 @@ - + @@ -52898,14 +52898,14 @@ - + - + @@ -53572,7 +53572,7 @@ - + @@ -53612,7 +53612,7 @@ - + @@ -53652,7 +53652,7 @@ - + @@ -53695,7 +53695,7 @@ - + @@ -53760,7 +53760,7 @@ - + @@ -53778,7 +53778,7 @@ - + @@ -53818,7 +53818,7 @@ - + @@ -54178,7 +54178,7 @@ - + @@ -54739,7 +54739,7 @@ - + diff --git a/tests/data/test-read-dwarf/test3.so.abi b/tests/data/test-read-dwarf/test3.so.abi index 7357a7401c6e..96d8cc310237 100644 --- a/tests/data/test-read-dwarf/test3.so.abi +++ b/tests/data/test-read-dwarf/test3.so.abi @@ -3,16 +3,16 @@ - + - + - + diff --git a/tests/data/test-read-dwarf/test3.so.hash.abi b/tests/data/test-read-dwarf/test3.so.hash.abi index e01f395983fa..22540639c41d 100644 --- a/tests/data/test-read-dwarf/test3.so.hash.abi +++ b/tests/data/test-read-dwarf/test3.so.hash.abi @@ -3,16 +3,16 @@ - + - + - + diff --git a/tests/data/test-symtab/basic/aliases.c b/tests/data/test-symtab/basic/aliases.c new file mode 100644 index 000000000000..319f463249dc --- /dev/null +++ b/tests/data/test-symtab/basic/aliases.c @@ -0,0 +1,13 @@ +void exported_function(){} + +void exported_function_alias() __attribute__((alias("exported_function"))); +void exported_function_another_alias() __attribute__((alias("exported_function"))); +void exported_function_weak_alias() __attribute__((weak, alias("exported_function"))); +void exported_function_another_weak_alias() __attribute__((weak, alias("exported_function"))); + +int exported_variable = 42; + +extern int exported_variable_alias __attribute__((alias("exported_variable"))); +extern int exported_variable_another_alias __attribute__((alias("exported_variable"))); +extern int exported_variable_weak_alias __attribute__((weak, alias("exported_variable"))); +extern int exported_variable_another_weak_alias __attribute__((weak, alias("exported_variable"))); diff --git a/tests/data/test-symtab/basic/aliases.so b/tests/data/test-symtab/basic/aliases.so new file mode 100755 index 0000000000000000000000000000000000000000..95a5c058e95d5f7027b767e1200bf2cef5d5bead GIT binary patch literal 17176 zcmeHOYiJzT6~42hwN_qf^>EV2v0IJJ1{}A$QW8I8yRt@4uZ-llsss&*JDS}c?JnJ& z6+5$$loTp32@Y;R{n1xQAQV&F&{7xLA1$TCI1O$7^hJvaZE;FM9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NFTtBrU!^IJzm7%ZJfZ`AK)Om-tSFG4;8tvhb1 z$aX>Ah#Mh&`m1E4Ok{UA0=y=&54FJIf%hq*v&uILMMiI-It~vstZVPr>WIzZ`WC`$ zDbM|iaeT#t@8dYV4{a}u9R)^k#R1#Hf_X23&wVKYj_q!F{I6U3&G+{!fcy2o)wsT9 z`RQaYO2BxEpPwtBBe3Rq@_h^MV+Z6$C)VQbGar5lY9Y)d@{H@cW!^l`|7htqKNs%< zEF$u)*^fQ9wVBEbqfo&i!9m0KHVxZT+uh#)At=w`ku3t;lkZf zm8F0~-(*kwIii=jrnmpp{yfOhC%mcbLhmb1y*mzX{9Xbpx4p#eh?2V&?%Ah2_Oy>A zO7S9lsuNW`_OyQ?`a?40)Z3q&$Da13MCm)2+<3>2`xhKP#h*!BlhZh_67kwU2?Do0 z?Q@BKmJB(iaTEL$Ft|sf`%8aspgd`>KGlihcW$@Kp7zZbcpf?Ffr?eAPV@ypaqdw2 zw7;f2bjmlUag!b0hsVGc$4~aO55EDY;;~59wSFOcqF)D*+n&i>cgUtR&pGNme`Nn{ z5V-AWU*FH|t?zy^21<4WeUD?*|F~>R;@qCbP5RiDyZituh;emCMD}|f#Ae8z=rw?e zcdN?Wq1Ufh7x$@N4E?Nd!!Np>`sn`N2Sbza19)ZZQJXkdZ(Hwz#EYTw61SJJ;woO< z+aN>CJI)um{UMJ5Ro&Eic3tgUf6%VbI*RX^1pMg!)4amlookup_function_symbol("exported_function")->get_main_symbol(); + REQUIRE(main_symbol); + + // But since we know that 'exported_function' is the main symbol and this + // can be discovered from DWARF + CHECK(corpus->lookup_function_symbol("exported_function")->is_main_symbol()); + + CHECK(corpus->lookup_function_symbol("exported_function") + ->get_number_of_aliases() == 4); + + CHECK(main_symbol->has_aliases()); + CHECK(main_symbol->get_number_of_aliases() == 4); + CHECK(main_symbol->get_main_symbol() == main_symbol); +} + +TEST_CASE("Symtab::AliasedVariableSymbols", "[symtab, variables, aliases]") +{ + const std::string binary = "basic/aliases.so"; + const corpus_sptr& corpus = assert_symbol_count(binary, 5, 5); + // The main symbol is not necessarily the one that is aliased to in the + // code So, this can't be decided by just looking at ELF. Hence acquire the + // main symbol. + const elf_symbol_sptr& main_symbol = + corpus->lookup_variable_symbol("exported_variable")->get_main_symbol(); + REQUIRE(main_symbol); + + // But since we know that 'exported_function' is the main symbol and this + // can be discovered from DWARF + CHECK(corpus->lookup_variable_symbol("exported_variable")->is_main_symbol()); + + CHECK(corpus->lookup_variable_symbol("exported_variable") + ->get_number_of_aliases() == 4); + + CHECK(main_symbol->has_aliases()); + CHECK(main_symbol->get_number_of_aliases() == 4); + CHECK(main_symbol->get_main_symbol() == main_symbol); +} + static const char* kernel_versions[] = { "4.14", "4.19", "5.4", "5.6" }; static const size_t nr_kernel_versions = sizeof(kernel_versions) / sizeof(kernel_versions[0]); From patchwork Wed Jan 27 12:58:51 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: 41852 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 47D09397282F; Wed, 27 Jan 2021 12:59:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 47D09397282F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752395; bh=yslD7cs6nxPwp91DV1NQNTy50lCPs3G2eO50UZ9NJDY=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=t8uj8CbUSLGkiENcOoZGARoZO/lMfFDNzZCSwTZeXgyAH8lo/LdCfpXMFm+5p/6br DztyJCZdxCQ1Uxlw4R9u1tSKiIZLnoodI0zXI/fo1YsbmVT2KA/TM8AWPmyMCZHUK6 jIWGfpolJipXLnUeqyMd/oLYbtMdVlHj19K1r4Ak= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-qv1-xf4a.google.com (mail-qv1-xf4a.google.com [IPv6:2607:f8b0:4864:20::f4a]) by sourceware.org (Postfix) with ESMTPS id 386513972827 for ; Wed, 27 Jan 2021 12:59:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 386513972827 Received: by mail-qv1-xf4a.google.com with SMTP id l3so1229995qvz.12 for ; Wed, 27 Jan 2021 04:59:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc:content-transfer-encoding; bh=yslD7cs6nxPwp91DV1NQNTy50lCPs3G2eO50UZ9NJDY=; b=f8Vhae/2sLWS14tT9mxWW4gNqKYgew3VAcCYh17EPrx2z7jBZiKhQYclNvdhseIhka zgItcLUHkDCt0E7jKPJYd4PYXbgBYJzdEEth0s45l7DZbRPrgXzR5vIRGLXZWApWjc1P HS/1NNjyf1UJVHQ9LKveLcqtq/X2kynrygMV9zMNQh6i9dFu6kwC3+lc9gUWjnpn9AJO pamVegU+f0ZqQuK0oG3e9RAfrCUumI/NI62DTgdPmyDtriOzO1mjmTqzjCZcxGol+iVW bf892Llm+CH+JmVE8I91AguF3bAErF1OjyaeI8Ari/uq4HYSOMEf5hz1KUmgtYiDfCf2 WPEA== X-Gm-Message-State: AOAM530q8mB6bGzQTafjMJYxS56yBBDwcLgCqS2QAZOTorcLT1ngrqUT DUojOTBTUmGFzChLI23GrKjeCJmTugUNZP2FnzRIRizIS6FVh0Vh4aZraBzxVYoR7KtvfcOgsNq yYV9g4jgm++xppN/x4O/1OS6RUNIWxVqI0sT4j2saZjXBYIMoP/XhYYfT20DwyJzOx0356+E= X-Google-Smtp-Source: ABdhPJw0FNviFvQFbqsooKA77/MoEBixaFwhs+BO2cKqmk12+7sLyaW27MU6NJdl+e4LVQ5DHnTpN1tgH+igMA== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a0c:fe47:: with SMTP id u7mr10447611qvs.4.1611752387723; Wed, 27 Jan 2021 04:59:47 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:51 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-19-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 18/20] dwarf-reader/writer: consider aliases when dealing with suppressions To: libabigail@sourceware.org X-Spam-Status: No, score=-22.4 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libabigail@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list of the Libabigail project List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-Patchwork-Original-From: Matthias Maennich via Libabigail From: =?utf-8?q?Matthias_M=C3=A4nnich?= Reply-To: Matthias Maennich Cc: maennich@google.com, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" 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. 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. 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. When reading from XML with a symbol whitelist that leads to suppression of aliased symbols, abidiff would hit an assertion and crash when looking up the aliased symbol due to it being suppressed. In the new symtab reader we can still suppress a symbol without removing it from the lookup. Make use of that property to fix this bug. A test has been added for this as well. * src/abg-dwarf-reader.cc(function_is_suppressed): Do not suppress a function for which there is an alias that is not suppressed. (variable_is_suppressed): Likewise for variables. * src/abg-reader.cc (build_elf_symbol): Improve handling of suppressed aliased symbols when reading from XML. * src/abg-symtab-reader.cc (load): Likewise. * src/abg-writer.cc(write_elf_symbol_reference): Fall back to any aliased symbol if the main symbol is suppressed. * tests/data/Makefile.am: Add new test files. * tests/data/test-abidiff-exit/test-missing-alias-report.txt: New test file. * tests/data/test-abidiff-exit/test-missing-alias.abi: Likewise. * tests/data/test-abidiff-exit/test-missing-alias.suppr: Likewise. * tests/test-abidiff-exit.cc: Add support for whitelists and add new testcase. * tests/data/test-read-dwarf/test-suppressed-alias.c: New test file. * tests/data/test-read-dwarf/test-suppressed-alias.o: Likewise. * tests/data/test-read-dwarf/test-suppressed-alias.o.abi: Likewise. * tests/data/test-read-dwarf/test-suppressed-alias.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-1.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-1.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-2.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-3.suppr: Likewise. * tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise. * tests/data/test-read-dwarf/test3-alias-4.suppr: Likewise. * tests/test-read-dwarf.cc: Add new test cases. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-dwarf-reader.cc | 30 +- src/abg-reader.cc | 7 +- src/abg-symtab-reader.cc | 14 +- src/abg-writer.cc | 5 +- tests/data/Makefile.am | 15 + .../test-missing-alias-report.txt | 0 .../test-abidiff-exit/test-missing-alias.abi | 12 + .../test-missing-alias.suppr | 4 + .../data/test-diff-suppr/test31-report-0.txt | 3 + .../data/test-diff-suppr/test32-report-1.txt | 2 +- .../test-read-dwarf/libtest24-drop-fns.so.abi | 314 +++++++++--------- .../test-read-dwarf/test-suppressed-alias.c | 16 + .../test-read-dwarf/test-suppressed-alias.o | Bin 0 -> 2848 bytes .../test-suppressed-alias.o.abi | 16 + .../test-suppressed-alias.suppr | 7 + .../test-read-dwarf/test3-alias-1.so.hash.abi | 14 + .../data/test-read-dwarf/test3-alias-1.suppr | 3 + .../test-read-dwarf/test3-alias-2.so.hash.abi | 18 + .../data/test-read-dwarf/test3-alias-2.suppr | 3 + .../test-read-dwarf/test3-alias-3.so.hash.abi | 14 + .../data/test-read-dwarf/test3-alias-3.suppr | 3 + .../test-read-dwarf/test3-alias-4.so.hash.abi | 8 + .../data/test-read-dwarf/test3-alias-4.suppr | 3 + tests/test-abidiff-exit.cc | 11 + tests/test-read-dwarf.cc | 40 +++ 25 files changed, 399 insertions(+), 163 deletions(-) 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 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 diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 7d7ffbdc8ebe..37d63b262646 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -13490,8 +13490,21 @@ function_is_suppressed(const read_context& ctxt, if (!ctxt.get_function_address(function_die, fn_addr)) return true; - if (!ctxt.function_symbol_is_exported(fn_addr)) + elf_symbol_sptr symbol = ctxt.function_symbol_is_exported(fn_addr); + if (!symbol) return true; + if (!symbol->is_suppressed()) + return false; + + // Since there is only one symbol in DWARF associated with an elf_symbol, + // we can assume this is the main symbol then. Otherwise the main hinting + // did not work as expected. + ABG_ASSERT(symbol->is_main_symbol()); + if (symbol->has_aliases()) + for (elf_symbol_sptr a = symbol->get_next_alias(); + !a->is_main_symbol(); a = a->get_next_alias()) + if (!a->is_suppressed()) + return false; } return suppr::function_is_suppressed(ctxt, qualified_name, @@ -13599,8 +13612,21 @@ variable_is_suppressed(const read_context& ctxt, if (!ctxt.get_variable_address(variable_die, var_addr)) return true; - if (!ctxt.variable_symbol_is_exported(var_addr)) + elf_symbol_sptr symbol = ctxt.variable_symbol_is_exported(var_addr); + if (!symbol) return true; + if (!symbol->is_suppressed()) + return false; + + // Since there is only one symbol in DWARF associated with an elf_symbol, + // we can assume this is the main symbol then. Otherwise the main hinting + // did not work as expected. + ABG_ASSERT(symbol->is_main_symbol()); + if (symbol->has_aliases()) + for (elf_symbol_sptr a = symbol->get_next_alias(); + !a->is_main_symbol(); a = a->get_next_alias()) + if (!a->is_suppressed()) + return false; } return suppr::variable_is_suppressed(ctxt, qualified_name, diff --git a/src/abg-reader.cc b/src/abg-reader.cc index 296e1e2115d1..e0269436ee89 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -2780,7 +2780,8 @@ build_elf_symbol(read_context& ctxt, const xmlNodePtr node, elf_symbol::version version(version_string, is_default_version); - if (drop_if_suppressed && suppr::is_elf_symbol_suppressed(ctxt, name, type)) + const bool is_suppressed = suppr::is_elf_symbol_suppressed(ctxt, name, type); + if (drop_if_suppressed && is_suppressed) return elf_symbol_sptr(); const environment* env = ctxt.get_environment(); @@ -2789,6 +2790,8 @@ build_elf_symbol(read_context& ctxt, const xmlNodePtr node, is_defined, is_common, version, visibility, /*is_linux_string_cst=*/false); + + e->set_is_suppressed(is_suppressed); return e; } @@ -2875,7 +2878,7 @@ build_elf_symbol_db(read_context& ctxt, elf_symbol_sptr sym; for (xmlNodePtr n = node->children; n; n = n->next) { - if ((sym = build_elf_symbol(ctxt, n, /*drop_if_suppress=*/true))) + if ((sym = build_elf_symbol(ctxt, n, /*drop_if_suppress=*/false))) { id_sym_map[sym->get_id_string()] = sym; xml_node_ptr_elf_symbol_map[n] = sym; diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc index a769934e5c05..512fbc20adc0 100644 --- a/src/abg-symtab-reader.cc +++ b/src/abg-symtab-reader.cc @@ -357,16 +357,22 @@ symtab::load_(string_elf_symbols_map_sptr function_symbol_map, if (function_symbol_map) for (const auto& symbol_map_entry : *function_symbol_map) { - symbols_.insert(symbols_.end(), symbol_map_entry.second.begin(), - symbol_map_entry.second.end()); + for (const auto& symbol : symbol_map_entry.second) + { + if (!symbol->is_suppressed()) + symbols_.push_back(symbol); + } ABG_ASSERT(name_symbol_map_.insert(symbol_map_entry).second); } if (variables_symbol_map) for (const auto& symbol_map_entry : *variables_symbol_map) { - symbols_.insert(symbols_.end(), symbol_map_entry.second.begin(), - symbol_map_entry.second.end()); + for (const auto& symbol : symbol_map_entry.second) + { + if (!symbol->is_suppressed()) + symbols_.push_back(symbol); + } ABG_ASSERT(name_symbol_map_.insert(symbol_map_entry).second); } diff --git a/src/abg-writer.cc b/src/abg-writer.cc index d4d5e5531894..c2fdd8f0a043 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -1728,7 +1728,10 @@ write_elf_symbol_aliases(const elf_symbol& sym, ostream& out) static bool write_elf_symbol_reference(const elf_symbol& sym, ostream& o) { - o << " elf-symbol-id='" << sym.get_id_string() << "'"; + auto actual_sym = &sym; + while (actual_sym->is_suppressed() && actual_sym->has_aliases()) + actual_sym = actual_sym->get_next_alias().get(); + o << " elf-symbol-id='" << actual_sym->get_id_string() << "'"; return true; } diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index d1358c9e9942..83e48cb8ebac 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -197,6 +197,9 @@ test-abidiff-exit/test-non-leaf-array-v0.o \ test-abidiff-exit/test-non-leaf-array-v1.c \ test-abidiff-exit/test-non-leaf-array-v1.o \ test-abidiff-exit/test-non-leaf-array-report.txt \ +test-abidiff-exit/test-missing-alias-report.txt \ +test-abidiff-exit/test-missing-alias.abi \ +test-abidiff-exit/test-missing-alias.suppr \ \ test-diff-dwarf/test0-v0.cc \ test-diff-dwarf/test0-v0.o \ @@ -450,6 +453,14 @@ test-read-dwarf/test3.c \ test-read-dwarf/test3.so \ test-read-dwarf/test3.so.abi \ test-read-dwarf/test3.so.hash.abi \ +test-read-dwarf/test3-alias-1.so.hash.abi \ +test-read-dwarf/test3-alias-1.suppr \ +test-read-dwarf/test3-alias-2.so.hash.abi \ +test-read-dwarf/test3-alias-2.suppr \ +test-read-dwarf/test3-alias-3.so.hash.abi \ +test-read-dwarf/test3-alias-3.suppr \ +test-read-dwarf/test3-alias-4.so.hash.abi \ +test-read-dwarf/test3-alias-4.suppr \ test-read-dwarf/test4.c \ test-read-dwarf/test4.so \ test-read-dwarf/test4.so.abi \ @@ -535,6 +546,10 @@ test-read-dwarf/test-PR26568-1.o.abi \ test-read-dwarf/test-PR26568-2.o.abi \ test-read-dwarf/test-libandroid.so \ test-read-dwarf/test-libandroid.so.abi \ +test-read-dwarf/test-suppressed-alias.c \ +test-read-dwarf/test-suppressed-alias.o \ +test-read-dwarf/test-suppressed-alias.o.abi \ +test-read-dwarf/test-suppressed-alias.suppr \ \ test-annotate/test0.abi \ test-annotate/test1.abi \ diff --git a/tests/data/test-abidiff-exit/test-missing-alias-report.txt b/tests/data/test-abidiff-exit/test-missing-alias-report.txt new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/tests/data/test-abidiff-exit/test-missing-alias.abi b/tests/data/test-abidiff-exit/test-missing-alias.abi new file mode 100644 index 000000000000..07a13f5e6d15 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-missing-alias.abi @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/tests/data/test-abidiff-exit/test-missing-alias.suppr b/tests/data/test-abidiff-exit/test-missing-alias.suppr new file mode 100644 index 000000000000..bcebae43a350 --- /dev/null +++ b/tests/data/test-abidiff-exit/test-missing-alias.suppr @@ -0,0 +1,4 @@ +[suppress_function] + symbol_name_not_regexp = ^__foo$ + drop = true + diff --git a/tests/data/test-diff-suppr/test31-report-0.txt b/tests/data/test-diff-suppr/test31-report-0.txt index e69de29bb2d1..9666a8fddad7 100644 --- a/tests/data/test-diff-suppr/test31-report-0.txt +++ b/tests/data/test-diff-suppr/test31-report-0.txt @@ -0,0 +1,3 @@ +Functions changes summary: 0 Removed, 0 Changed (1 filtered out), 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + diff --git a/tests/data/test-diff-suppr/test32-report-1.txt b/tests/data/test-diff-suppr/test32-report-1.txt index 2f785d0203dd..cffdf3a5aa4f 100644 --- a/tests/data/test-diff-suppr/test32-report-1.txt +++ b/tests/data/test-diff-suppr/test32-report-1.txt @@ -1,4 +1,4 @@ -Functions changes summary: 0 Removed, 1 Changed, 0 Added function +Functions changes summary: 0 Removed, 1 Changed (1 filtered out), 0 Added functions Variables changes summary: 0 Removed, 0 Changed, 0 Added variable 1 function with some indirect sub-type change: diff --git a/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi b/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi index 98b691bb4eec..fac267b365e1 100644 --- a/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi +++ b/tests/data/test-read-dwarf/libtest24-drop-fns.so.abi @@ -204,75 +204,78 @@ - + + - - - - - - - + + + + + - - + + + - + + + + - - + + - + - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - + @@ -280,10 +283,10 @@ - - + + - + @@ -294,29 +297,34 @@ - + - + - + - + - + - + - - - - - + + + + + + + + + + @@ -327,10 +335,10 @@ - + - + @@ -338,7 +346,7 @@ - + @@ -349,13 +357,13 @@ - + - + @@ -369,14 +377,14 @@ - + - + - + @@ -384,10 +392,10 @@ - + - + @@ -400,15 +408,15 @@ - + - + - - + + @@ -419,142 +427,142 @@ - - + + - - + + - + - - + + - - - + + + - - + + - - + + - + - - - + + + - - + + - - + + - - - + + + - - + + - + - - + + - + - - + + - + - - + + - - + + - + - + - + - - + + - - + + - - + + - - - - + + + + - - + + - - + + - - + + @@ -563,58 +571,58 @@ - - + + - - + + - + - - + + - + - + - + - + - + - + - + - + - + - + - + @@ -628,12 +636,12 @@ - + - + - + @@ -642,7 +650,7 @@ - + @@ -656,7 +664,7 @@ - + @@ -670,7 +678,7 @@ - + @@ -684,23 +692,23 @@ - - + + - - + + - - + + - - + + @@ -710,7 +718,7 @@ - + @@ -731,12 +739,12 @@ - - + + - - + + diff --git a/tests/data/test-read-dwarf/test-suppressed-alias.c b/tests/data/test-read-dwarf/test-suppressed-alias.c new file mode 100644 index 000000000000..a7812736c44b --- /dev/null +++ b/tests/data/test-read-dwarf/test-suppressed-alias.c @@ -0,0 +1,16 @@ + +// function aliases + +void main_func(void); +void alias_func(void) __attribute__((weak, alias("main_func"))); + +void main_func(void) +{ + +} + +// variables aliases + +int main_var; +extern int alias_var __attribute__((weak, alias("main_var"))); + diff --git a/tests/data/test-read-dwarf/test-suppressed-alias.o b/tests/data/test-read-dwarf/test-suppressed-alias.o new file mode 100644 index 0000000000000000000000000000000000000000..10d4a94a18c9c249c5ed3b60ada8c4f8cc5393ae GIT binary patch literal 2848 zcmbtVPjA#l6o0c$NWvyd{A7GM3v~Y{LpH!|fa2|NZLzUob>$O5?NIeO}9@Wu_$8NEVIh4zf9i70%Rj z80SS4acrKH)1(tK2e~o-@fHftvU zoKsM*U#UB@Sly%+gZpr`$qr|l6s3LQ$7@YYc@7_4B%ou7IDZM!;ssnCcpq0G{%tJa zs#}Vk5Rj`Z_j}rGTEJWp7Prk?H3tocGK{;sqqqlJdLmQykWnbJE&;8lSxd(KGzt4H znPiV!k5n3~$O}ec)c5iviL#d3&k>YSD+&V{gaa8yu>Hktx3h7<-B|ZO^4DE&n2%z$ zHBhli!yayB+S}XOzqsjbo_D>0>+Qnt3(h6V*(xzaFA z!9V|1DY1Q3Fn)=HCQs-c)KrmUCfC+Ea4>iiDyMjZ35+%l%)NmXc>NH3;SjuW2>!;Y z((}1o>H|;cGDi5I0;d^WD)pf_vjC?NKUsnEFpkHx7|Y3t9giw^>?p=#8AagA38yaI zBM@n+V8Hl_*}rY!r_7#CClP)5@>gEdDCjuldGbp*<)u7CmkXxj95XVp&yCFWyleJ% zEZl72ff4L__}wXvzQv5);vx2Q;}F?#T#Xj*T7F;fvu8s*n#l9C;Cn3Pco%@*m$?K# z$TIL#6-mFZg3+KG#=8mXv@C-lRZk|=GL`WFPkY%V3S-4Cm;(G>G8`(rsr@*~m5-N< zm*uke$T+FJ?rtiF$`t-T*(&-|Pq?2Pu5ARKcgD%KOeb+en0@lM%SI*H_CJF + + + + + + + + + + + + + + + diff --git a/tests/data/test-read-dwarf/test-suppressed-alias.suppr b/tests/data/test-read-dwarf/test-suppressed-alias.suppr new file mode 100644 index 000000000000..3f0790a23f8c --- /dev/null +++ b/tests/data/test-read-dwarf/test-suppressed-alias.suppr @@ -0,0 +1,7 @@ +[suppress_function] + symbol_name = main_func + drop = true + +[suppress_variable] + symbol_name = main_var + drop = true diff --git a/tests/data/test-read-dwarf/test3-alias-1.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-1.so.hash.abi new file mode 100644 index 000000000000..1ed4b0612886 --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-1.so.hash.abi @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/data/test-read-dwarf/test3-alias-1.suppr b/tests/data/test-read-dwarf/test3-alias-1.suppr new file mode 100644 index 000000000000..b347500d4c4e --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-1.suppr @@ -0,0 +1,3 @@ +[suppress_function] + symbol_name_not_regexp = ^__foo$ + drop = true diff --git a/tests/data/test-read-dwarf/test3-alias-2.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-2.so.hash.abi new file mode 100644 index 000000000000..50a53f97bf84 --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-2.so.hash.abi @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-read-dwarf/test3-alias-2.suppr b/tests/data/test-read-dwarf/test3-alias-2.suppr new file mode 100644 index 000000000000..b6d203d53c2b --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-2.suppr @@ -0,0 +1,3 @@ +[suppress_function] + symbol_name_regexp = ^__foo$ + drop = true diff --git a/tests/data/test-read-dwarf/test3-alias-3.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-3.so.hash.abi new file mode 100644 index 000000000000..6de4d59b13d5 --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-3.so.hash.abi @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/tests/data/test-read-dwarf/test3-alias-3.suppr b/tests/data/test-read-dwarf/test3-alias-3.suppr new file mode 100644 index 000000000000..66cd33a8d353 --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-3.suppr @@ -0,0 +1,3 @@ +[suppress_function] + symbol_name_not_regexp = ^foo$ + drop = true diff --git a/tests/data/test-read-dwarf/test3-alias-4.so.hash.abi b/tests/data/test-read-dwarf/test3-alias-4.so.hash.abi new file mode 100644 index 000000000000..b26d12f80e61 --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-4.so.hash.abi @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/data/test-read-dwarf/test3-alias-4.suppr b/tests/data/test-read-dwarf/test3-alias-4.suppr new file mode 100644 index 000000000000..25a2c437f51e --- /dev/null +++ b/tests/data/test-read-dwarf/test3-alias-4.suppr @@ -0,0 +1,3 @@ +[suppress_function] + symbol_name_not_regexp = ^_init$ + drop = true diff --git a/tests/test-abidiff-exit.cc b/tests/test-abidiff-exit.cc index 4283e1455d67..38f1301eb924 100644 --- a/tests/test-abidiff-exit.cc +++ b/tests/test-abidiff-exit.cc @@ -392,6 +392,17 @@ InOutSpec in_out_specs[] = "data/test-abidiff-exit/test-non-leaf-array-report.txt", "output/test-abidiff-exit/test-non-leaf-array-report.txt" }, + { + "data/test-abidiff-exit/test-missing-alias.abi", + "data/test-abidiff-exit/test-missing-alias.abi", + "data/test-abidiff-exit/test-missing-alias.suppr", + "", + "", + "", + abigail::tools_utils::ABIDIFF_OK, + "data/test-abidiff-exit/test-missing-alias-report.txt", + "output/test-abidiff-exit/test-missing-alias-report.txt" + }, {0, 0, 0 ,0, 0, 0, abigail::tools_utils::ABIDIFF_OK, 0, 0} }; diff --git a/tests/test-read-dwarf.cc b/tests/test-read-dwarf.cc index 1212e11c0663..e327909fb803 100644 --- a/tests/test-read-dwarf.cc +++ b/tests/test-read-dwarf.cc @@ -110,6 +110,46 @@ InOutSpec in_out_specs[] = "data/test-read-dwarf/test3.so.hash.abi", "output/test-read-dwarf/test3.so.hash.abi" }, + // suppress all except the main symbol of a group of aliases + { + "data/test-read-dwarf/test3.so", + "data/test-read-dwarf/test3-alias-1.suppr", + HASH_TYPE_ID_STYLE, + "data/test-read-dwarf/test3-alias-1.so.hash.abi", + "output/test-read-dwarf/test3-alias-1.so.hash.abi" + }, + // suppress the main symbol of a group of aliases + { + "data/test-read-dwarf/test3.so", + "data/test-read-dwarf/test3-alias-2.suppr", + HASH_TYPE_ID_STYLE, + "data/test-read-dwarf/test3-alias-2.so.hash.abi", + "output/test-read-dwarf/test3-alias-2.so.hash.abi" + }, + // suppress all except one non main symbol of a group of aliases + { + "data/test-read-dwarf/test3.so", + "data/test-read-dwarf/test3-alias-3.suppr", + HASH_TYPE_ID_STYLE, + "data/test-read-dwarf/test3-alias-3.so.hash.abi", + "output/test-read-dwarf/test3-alias-3.so.hash.abi" + }, + // suppress all symbols of a group of aliases + { + "data/test-read-dwarf/test3.so", + "data/test-read-dwarf/test3-alias-4.suppr", + HASH_TYPE_ID_STYLE, + "data/test-read-dwarf/test3-alias-4.so.hash.abi", + "output/test-read-dwarf/test3-alias-4.so.hash.abi" + }, + // suppress the main symbols with alias (function+variable) in .o file + { + "data/test-read-dwarf/test-suppressed-alias.o", + "data/test-read-dwarf/test-suppressed-alias.suppr", + HASH_TYPE_ID_STYLE, + "data/test-read-dwarf/test-suppressed-alias.o.abi", + "output/test-read-dwarf/test-suppressed-alias.o.abi", + }, { "data/test-read-dwarf/test4.so", "", From patchwork Wed Jan 27 12:58:52 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: 41851 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 F0F15397282F; Wed, 27 Jan 2021 12:59:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F0F15397282F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752394; bh=ZpL0TV5oyjDeuNzlo/TQIiJn1rpZjXshIf1WgPfr6rI=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=K9RB19ZSLvB5I+4q2NKJIZ6lldTWuwFOW/PXLsBvcjrltdUZygKPXJyi8Ivx1T8as Haf2OjVgKaJ2tPQuzvmVF/pj+6O0rvMfEpLAfqDTgbLZaOFEMEk742UCkBCWcB9zq6 4o5wqIxSJegQkVCkToi5uXI9DmFdPB3SwOMbPBo0= 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 9BD2E397282F for ; Wed, 27 Jan 2021 12:59:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 9BD2E397282F Received: by mail-qt1-x849.google.com with SMTP id k11so1009256qtm.16 for ; Wed, 27 Jan 2021 04:59:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=ZpL0TV5oyjDeuNzlo/TQIiJn1rpZjXshIf1WgPfr6rI=; b=NNWbycb3yVkI3O30qBU5+1B+obv8VflzRRgZXkdOfXjP83HBaLq0DFejZTuPNqpXbk v13+2j2Qx1UttBIq6683Mty5gWSsCFixu3BhaV6pkMu6ojZIBMgBOb95GXeS4vXpolFP moNheackjM10wFQ2oNx9tiUADzXHmvO1R6liL5ObDaTBaaInYz2FexY4UZT3MId8ve/Z Zxxx/YAluD0UNByUcyLYqmVJR/2021cuQXh65wsZAJFSvzpoGC8nDtkMufTiKI28YDcB 3Wk/J2JtSw/Jsg/5kSEkXORBwZMTDtk0rzTTa8kKBDcm6PhWYS/T6lNnxviOm8tMeOtZ 2mnQ== X-Gm-Message-State: AOAM531NVH1NNrGIBuTU8R908eJ/S3rTBTTLkfUj/coqXeDS3/HRs7eA gZxNnsf1/KoDCgUTy5oXD6/2wCFtFFFpAyeUQqeP1yT7mvowK4fCqYDohv51JXgRCjPJC8xNa1j QOEe7UpkAG1yW1uxPQM5YD+R80F2WpIC0MKn5oXtKquDnrz0VOLfbUABk8fShVA6G6LImnPM= X-Google-Smtp-Source: ABdhPJxhjsKzzMyBWJk0Li5m7MJYfskbB1gUKToVgnAatCFeTYEj28muEKmAZ309CfHg8Bn3HlsxDaqmV1ZJDg== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a05:6214:2ee:: with SMTP id h14mr10172559qvu.34.1611752390118; Wed, 27 Jan 2021 04:59:50 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:52 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-20-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 19/20] abg-writer.cc: fix write_elf_symbol_reference loop To: libabigail@sourceware.org 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, 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" From: Giuliano Procida The function write_elf_symbol_reference iterates through aliases, looking for an unsuppressed alias to use. The existing code went wrong in the case when aliases are present. In the case of all symbols suppressed, it would also have selected the last alias, rather than the first, if the data structure invariants had matched the code's expectations. The main symbol is always distinguished. When aliases are absent, the sole symbol's next pointer is null, but when aliases are present, they form a circular list. This makes traversal of aliases a bit tricky. The code now picks the first symbol from the following: - the given symbol, if unsuppressed - the main symbol, if unsuppressed - the unsuppressed aliases in the remainder of the alias chain - the main symbol (suppressed) The given symbol, which need not be the same as the main symbol, will be tested twice, if suppressed, but addressing this would make the code even more elaborate and fragile. The last case may be unreachable if symbol suppression triggers when all aliases are suppressed. I left this change stand-alone for easier review and to credit Giuliano for his work on it, though it fixes a previous commit. * src/abg-writer.cc (write_elf_symbol_reference): Check main symbol and aliases with more care. Fixes: commmit ("dwarf-reader/writer: consider aliases when dealing with suppressions") Signed-off-by: Giuliano Procida Signed-off-by: Matthias Maennich --- src/abg-writer.cc | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/abg-writer.cc b/src/abg-writer.cc index c2fdd8f0a043..4985174d3abd 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -1728,10 +1728,28 @@ write_elf_symbol_aliases(const elf_symbol& sym, ostream& out) static bool write_elf_symbol_reference(const elf_symbol& sym, ostream& o) { - auto actual_sym = &sym; - while (actual_sym->is_suppressed() && actual_sym->has_aliases()) - actual_sym = actual_sym->get_next_alias().get(); - o << " elf-symbol-id='" << actual_sym->get_id_string() << "'"; + const elf_symbol* main = sym.get_main_symbol().get(); + const elf_symbol* alias = &sym; + bool found = !alias->is_suppressed(); + // If the symbol itself is suppressed, check the alias chain. + if (!found) + { + alias = main; + found = !alias->is_suppressed(); + } + // If the main symbol is suppressed, search the remainder of the chain. + while (!found) + { + alias = alias->get_next_alias().get(); + // Two separate termination conditions at present. + if (!alias || alias == main) + break; + found = !alias->is_suppressed(); + } + // If all aliases are suppressed, just stick with the main symbol. + if (!found) + alias = main; + o << " elf-symbol-id='" << alias->get_id_string() << "'"; return true; } From patchwork Wed Jan 27 12:58:53 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: 41853 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 E3A153857C73; Wed, 27 Jan 2021 13:00:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E3A153857C73 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611752431; bh=75wHZrMLBplb5BGKaQ0iIzxfY+ulXg80tEyWnfd9jCY=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ZhtzlMyAGUvl3xXngw0cHJdIlXByKwT0ktoXf5CSZqnsMRT7bUrAa8lBa0LOOizAa 4AoQnMOT9389bJ8LVPIaa4G6bEMGWYBd2xzkFfkR3ftgapo3ejX2U6mFCJzki/NKCh J5DPowMODa/wyd9qAoFs/GmFJpxSawrR7ZT0Z2wQ= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-wr1-x449.google.com (mail-wr1-x449.google.com [IPv6:2a00:1450:4864:20::449]) by sourceware.org (Postfix) with ESMTPS id 7F6FE3971C3C for ; Wed, 27 Jan 2021 12:59:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7F6FE3971C3C Received: by mail-wr1-x449.google.com with SMTP id o17so913390wrv.4 for ; Wed, 27 Jan 2021 04:59:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=75wHZrMLBplb5BGKaQ0iIzxfY+ulXg80tEyWnfd9jCY=; b=hQ8idoNSp33apPctYQRLabCuauC7Veg1GC3ur2K5VLOBT+C9qKyWVRpPRZoeWGsf32 kTOGTQOZ/IJnSD9EdBgMdID4WGGT6g1zU1W7GYSzng2A8r05PZzKggILeiTI6qwBpKnV BfplsjLEdZaLDJYEUP3kKfAw+9/7Ti28nPEjRQFY9+uOM5VrN5ZfaTVZjYq3xAI+gE2f SdJc2JccbJTL6w3VhaoHPZEKkAP6vThNmfVtbs3CBAa7KRFVFu/zDuJF2gvCEsidD/QW gu+qTrUVtnTkQE6hWwQfLU8n7/7JI5trrXToiKYGGrDRLPyHwyvV4FbKF2Hgwukk1YQQ n7Zg== X-Gm-Message-State: AOAM531OFVSruJfcxHugKA/myeXYIBKgKUg+t6069HAxjTuKZ7H8cVYG H9ev65RGtLlI1xrJao95/mLfchgmLwloifMDKXoY3H62TghKy+Lmln7WDsU8xpLf84Hi6kiL3ED pDVv3H05OMNebjKojOr2ir3gcjDH8ljREUdD+eqsVOWokjFp1TLioJUzKFx2x3g2pW9mCEig= X-Google-Smtp-Source: ABdhPJyEuU0TfD+HUHOar/id+wIjmzJhnghYiVjFf/VIKSqRkZwmNyFRgD2ztt/BpurXZbHl9tWygArNVjmUNA== X-Received: from lux.lon.corp.google.com ([2a00:79e0:d:210:7220:84ff:fe09:a3aa]) (user=maennich job=sendgmr) by 2002:a7b:c08f:: with SMTP id r15mr4203993wmh.22.1611752392522; Wed, 27 Jan 2021 04:59:52 -0800 (PST) Date: Wed, 27 Jan 2021 12:58:53 +0000 In-Reply-To: <20210127125853.886677-1-maennich@google.com> Message-Id: <20210127125853.886677-21-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20210127125853.886677-1-maennich@google.com> X-Mailer: git-send-email 2.30.0.280.ga3ce27912f-goog Subject: [PATCH 20/20] symtab: Add support for MODVERSIONS (CRC checksums) To: libabigail@sourceware.org X-Spam-Status: No, score=-19.3 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_LINEPADDING, LIKELY_SPAM_BODY, NORMAL_HTTP_TO_IP, NUMERIC_HTTP_ADDR, RCVD_IN_DNSWL_NONE, SCC_10_SHORT_WORD_LINES, SCC_5_SHORT_WORD_LINES, 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, kernel-team@android.com Errors-To: libabigail-bounces@sourceware.org Sender: "Libabigail" The Linux Kernel has a mechanism (MODVERSIONS) to checksum symbols based on their type. In a way similar to what libabigail does, but different. The CRC values for symbols can be extracted from the symtab either by following the __kcrctab_ entry or by using the __crc_ value directly. This patch adds support for extracting those CRC values and storing them as a property of elf_symbol. Subsequently, 'crc' gets emitted as an attribute of 'elf-symbol' in the XML representation. CRC comparisons are also added to the abidiff machinery such that if both representations of a comparison contain a CRC value, they will be compared and if any of the values is unset (i.e. == 0), equality is assumed. Differences will be reported in the format that the Kernel presents them e.g. via Module.symvers. It is likely, but not necessary, that a CRC difference comes along with an ABI difference reported by libabigail. Not everything that leads to a change of the CRC value an ABI breakage in the libabigail sense. In case a function or variable symbol changes in a harmless way, we would previously also consider a CRC change harmless (or more precise: not harmful). Explicitly testing for CRC changes when analyzing whether diff nodes need to be considered harmful, allows to still classify them harmful. Also add some test cases to ensure reading CRC values from kernel binaries works as expected. The empty-report files have been consolidated to one file: empty-report.txt. That also clarifies the expected outcome for the affected tests. * include/abg-ir.h (elf_symbol::elf_symbol): Add CRC parameter. (elf_symbol::create): Likewise. (elf_symbol::get_crc): New member method. (elf_symbol::set_crc): New member method. * src/abg-comp-filter.cc (crc_changed): New function. (categorize_harmful_diff_node): Also test for CRC changes. * src/abg-ir.cc (elf_symbol::priv::crc_): New data member. * src/abg-ir.cc (elf_symbol::priv::priv): Add CRC parameter. (elf_symbol::elf_symbol): Likewise. (elf_symbol::create): Likewise. (elf_symbol::textually_equals): Add CRC support. (elf_symbol::get_crc): New member method. (elf_symbol::set_crc): New member method. * src/abg-reader.cc (build_elf_symbol): Add CRC support. * src/abg-reporter-priv.cc (maybe_report_diff_for_symbol): Likewise. * src/abg-symtab-reader.cc (symtab::load): Likewise. * src/abg-writer.cc (write_elf_symbol): Likewise. * tests/data/Makefile.am: Add new test data files. * tests/data/test-abidiff-exit/test-crc-report.txt: New test file. * tests/data/test-abidiff-exit/test-crc-v0.abi: Likewise. * tests/data/test-abidiff-exit/test-crc-v1.abi: Likewise. * tests/data/test-abidiff/empty-report.txt: New file. * tests/data/test-abidiff/test-PR18166-libtirpc.so.report.txt: Deleted. * tests/data/test-abidiff/test-PR24552-report0.txt: Deleted. * tests/data/test-abidiff/test-crc-0.xml: New test file. * tests/data/test-abidiff/test-crc-1.xml: Likewise. * tests/data/test-abidiff/test-crc-2.xml: Likewise. * tests/data/test-abidiff/test-crc-report.txt: Likewise. * tests/data/test-abidiff/test-empty-corpus-report.txt: Deleted. * tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Add CRC values. * tests/data/test-read-write/test-crc.xml: New test data file. * tests/data/test-symtab/kernel-modversions/Makefile: New test source. * tests/data/test-symtab/kernel-modversions/one_of_each.c: Likewise. * tests/data/test-symtab/kernel-modversions/one_of_each.ko: Likewise. * tests/test-abidiff-exit.cc: Add new test case. * tests/test-abidiff.cc: Add new test case. * tests/test-read-write.cc: Likewise. * tests/test-symtab.cc (Symtab::KernelSymtabsWithCRC): New test case. Reviewed-by: Giuliano Procida Signed-off-by: Matthias Maennich --- include/abg-ir.h | 8 + src/abg-comp-filter.cc | 39 +- src/abg-ir.cc | 22 +- src/abg-reader.cc | 8 + src/abg-reporter-priv.cc | 18 +- src/abg-symtab-reader.cc | 19 + src/abg-writer.cc | 6 + tests/data/Makefile.am | 17 +- .../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 + ...ibtirpc.so.report.txt => empty-report.txt} | 0 .../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 + .../test-abidiff/test-empty-corpus-report.txt | 3 - .../data/test-read-dwarf/PR25007-sdhci.ko.abi | 72 +- tests/data/test-read-write/test-crc.xml | 10 + .../test-symtab/kernel-modversions/Makefile | 19 + .../kernel-modversions/one_of_each.c | 1 + .../kernel-modversions/one_of_each.ko | Bin 0 -> 131760 bytes tests/test-abidiff-exit.cc | 11 + tests/test-abidiff.cc | 34 +- tests/test-read-write.cc | 6 + tests/test-symtab.cc | 15 + 27 files changed, 5138 insertions(+), 59 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 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-write/test-crc.xml 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 diff --git a/include/abg-ir.h b/include/abg-ir.h index a14ee1c23784..555bb769ba50 100644 --- a/include/abg-ir.h +++ b/include/abg-ir.h @@ -840,6 +840,7 @@ private: visibility vi, bool is_linux_string_cst = false, bool is_in_ksymtab = false, + uint64_t crc = 0, bool is_suppressed = false); elf_symbol(const elf_symbol&); @@ -865,6 +866,7 @@ public: visibility vi, bool is_linux_string_cst = false, bool is_in_ksymtab = false, + uint64_t crc = 0, bool is_suppressed = false); const environment* @@ -939,6 +941,12 @@ public: void set_is_in_ksymtab(bool is_in_ksymtab); + uint64_t + get_crc() const; + + void + set_crc(uint64_t crc); + bool is_suppressed() const; diff --git a/src/abg-comp-filter.cc b/src/abg-comp-filter.cc index a0280d8eddf1..0734b56ec2ee 100644 --- a/src/abg-comp-filter.cc +++ b/src/abg-comp-filter.cc @@ -218,6 +218,42 @@ access_changed(const decl_base_sptr& f, const decl_base_sptr& s) return false; } +/// Test if there was a function or variable CRC change. +/// +/// @param f the first function or variable to consider. +/// +/// @param s the second function or variable to consider. +/// +/// @return true if the test is positive, false otherwise. +template +static bool +crc_changed(const function_or_var_decl_sptr& f, + const function_or_var_decl_sptr& s) +{ + const auto symbol_f = f->get_symbol(), symbol_s = s->get_symbol(); + if (!symbol_f || !symbol_s) + return false; + const auto crc_f = symbol_f->get_crc(), crc_s = symbol_s->get_crc(); + return (crc_f != 0 && crc_s != 0 && crc_f != crc_s); +} + +/// Test if the current diff tree node carries a CRC change in either a +/// function or a variable. +/// +/// @param diff the diff tree node to consider. +/// +/// @return true if the test is positive, false otherwise. +static bool +crc_changed(const diff* diff) +{ + if (const function_decl_diff* d = + dynamic_cast(diff)) + return crc_changed(d->first_function_decl(), d->second_function_decl()); + if (const var_diff* d = dynamic_cast(diff)) + return crc_changed(d->first_var(), d->second_var()); + return false; +} + /// Test if there was a function name change, but there there was no /// change in name of the underlying symbol. IOW, if the name of a /// function changed, but the symbol of the new function is equal to @@ -1717,7 +1753,8 @@ categorize_harmful_diff_node(diff *d, bool pre) || non_static_data_member_type_size_changed(f, s) || non_static_data_member_added_or_removed(d) || base_classes_added_or_removed(d) - || has_harmful_enum_change(d))) + || has_harmful_enum_change(d) + || crc_changed(d))) category |= SIZE_OR_OFFSET_CHANGE_CATEGORY; if (has_virtual_mem_fn_change(d)) diff --git a/src/abg-ir.cc b/src/abg-ir.cc index 0b31f2014189..64dfffbf4011 100644 --- a/src/abg-ir.cc +++ b/src/abg-ir.cc @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -1311,6 +1312,7 @@ struct elf_symbol::priv bool is_common_; bool is_linux_string_cst_; bool is_in_ksymtab_; + uint64_t crc_; bool is_suppressed_; elf_symbol_wptr main_symbol_; elf_symbol_wptr next_alias_; @@ -1328,6 +1330,7 @@ struct elf_symbol::priv is_common_(false), is_linux_string_cst_(false), is_in_ksymtab_(false), + crc_(0), is_suppressed_(false) {} @@ -1343,6 +1346,7 @@ struct elf_symbol::priv elf_symbol::visibility vi, bool is_linux_string_cst, bool is_in_ksymtab, + uint64_t crc, bool is_suppressed) : env_(e), index_(i), @@ -1356,6 +1360,7 @@ struct elf_symbol::priv is_common_(c), is_linux_string_cst_(is_linux_string_cst), is_in_ksymtab_(is_in_ksymtab), + crc_(crc), is_suppressed_(is_suppressed) { if (!is_common_) @@ -1414,6 +1419,7 @@ elf_symbol::elf_symbol(const environment* e, visibility vi, bool is_linux_string_cst, bool is_in_ksymtab, + uint64_t crc, bool is_suppressed) : priv_(new priv(e, i, @@ -1427,6 +1433,7 @@ elf_symbol::elf_symbol(const environment* e, vi, is_linux_string_cst, is_in_ksymtab, + crc, is_suppressed)) {} @@ -1486,11 +1493,12 @@ elf_symbol::create(const environment* e, visibility vi, bool is_linux_string_cst, bool is_in_ksymtab, + uint64_t crc, bool is_suppressed) { elf_symbol_sptr sym(new elf_symbol(e, i, s, n, t, b, d, c, ve, vi, is_linux_string_cst, - is_in_ksymtab, is_suppressed)); + is_in_ksymtab, crc, is_suppressed)); sym->priv_->main_symbol_ = sym; return sym; } @@ -1511,7 +1519,9 @@ textually_equals(const elf_symbol&l, && l.is_public() == r.is_public() && l.is_defined() == r.is_defined() && l.is_common_symbol() == r.is_common_symbol() - && l.get_version() == r.get_version()); + && l.get_version() == r.get_version() + && (l.get_crc() == 0 || r.get_crc() == 0 + || l.get_crc() == r.get_crc())); if (equals && l.is_variable()) // These are variable symbols. Let's compare their symbol size. @@ -1718,6 +1728,14 @@ void elf_symbol::set_is_in_ksymtab(bool is_in_ksymtab) {priv_->is_in_ksymtab_ = is_in_ksymtab;} +uint64_t +elf_symbol::get_crc() const +{return priv_->crc_;} + +void +elf_symbol::set_crc(uint64_t crc) +{priv_->crc_ = crc;} + bool elf_symbol::is_suppressed() const {return priv_->is_suppressed_;} diff --git a/src/abg-reader.cc b/src/abg-reader.cc index e0269436ee89..42985e5a7496 100644 --- a/src/abg-reader.cc +++ b/src/abg-reader.cc @@ -2769,6 +2769,10 @@ build_elf_symbol(read_context& ctxt, const xmlNodePtr node, is_default_version = true; } + uint64_t crc = 0; + if (xml_char_sptr s = XML_NODE_GET_ATTRIBUTE(node, "crc")) + crc = strtoull(CHAR_STR(s), NULL, 0); + elf_symbol::type type = elf_symbol::NOTYPE_TYPE; read_elf_symbol_type(node, type); @@ -2792,6 +2796,10 @@ build_elf_symbol(read_context& ctxt, const xmlNodePtr node, /*is_linux_string_cst=*/false); e->set_is_suppressed(is_suppressed); + + if (crc != 0) + e->set_crc(crc); + return e; } diff --git a/src/abg-reporter-priv.cc b/src/abg-reporter-priv.cc index 1a7f09df63eb..c0b26d086c36 100644 --- a/src/abg-reporter-priv.cc +++ b/src/abg-reporter-priv.cc @@ -42,8 +42,7 @@ emit_num_value(uint64_t value, const diff_context& ctxt, ostream& out) out << std::hex << std::showbase ; else out << std::dec; - out << value; - out << std::dec << std::noshowbase; + out << value << std::dec << std::noshowbase; } /// Convert a bits value into a byte value if the current diff context @@ -1179,6 +1178,21 @@ maybe_report_diff_for_symbol(const elf_symbol_sptr& symbol1, reported = true; } + if (symbol1->get_crc() != 0 && symbol2->get_crc() != 0 + && symbol1->get_crc() != symbol2->get_crc()) + { + if (reported) + out << ",\n" << indent << "its CRC (modversions) changed from "; + else + out << "\n" << indent << "CRC value (modversions) changed from "; + + out << std::showbase << std::hex + << symbol1->get_crc() << " to " << symbol2->get_crc() + << std::noshowbase << std::dec; + + reported = true; + } + if (reported) out << "\n"; diff --git a/src/abg-symtab-reader.cc b/src/abg-symtab-reader.cc index 512fbc20adc0..8ee90c590a94 100644 --- a/src/abg-symtab-reader.cc +++ b/src/abg-symtab-reader.cc @@ -12,6 +12,7 @@ #include #include +#include #include #include "abg-elf-helpers.h" @@ -202,6 +203,7 @@ symtab::load_(Elf* elf_handle, const bool is_kernel = elf_helpers::is_linux_kernel(elf_handle); std::unordered_set exported_kernel_symbols; + std::unordered_map crc_values; const bool is_ppc64 = elf_helpers::architecture_is_ppc64(elf_handle); @@ -249,6 +251,11 @@ symtab::load_(Elf* elf_handle, ABG_ASSERT(exported_kernel_symbols.insert(name.substr(10)).second); continue; } + if (is_kernel && name.rfind("__crc_", 0) == 0) + { + ABG_ASSERT(crc_values.emplace(name.substr(6), sym->st_value).second); + continue; + } // filter out uninteresting entries and only keep functions/variables for // now. The rest might be interesting in the future though. @@ -338,6 +345,18 @@ symtab::load_(Elf* elf_handle, has_ksymtab_entries_ = true; } + // Now add the CRC values + for (const auto& crc_entry : crc_values) + { + const auto r = name_symbol_map_.find(crc_entry.first); + if (r == name_symbol_map_.end()) + continue; + + for (const auto& symbol : r->second) { + symbol->set_crc(crc_entry.second); + } + } + // sort the symbols for deterministic output std::sort(symbols_.begin(), symbols_.end(), symbol_sort); diff --git a/src/abg-writer.cc b/src/abg-writer.cc index 4985174d3abd..8a1fc2495506 100644 --- a/src/abg-writer.cc +++ b/src/abg-writer.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -3068,6 +3069,11 @@ write_elf_symbol(const elf_symbol_sptr& sym, if (sym->is_common_symbol()) o << " is-common='yes'"; + if (sym->get_crc() != 0) + o << " crc='" + << std::hex << std::showbase << sym->get_crc() << "'" + << std::dec << std::noshowbase; + o << "/>\n"; return true; diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am index 83e48cb8ebac..eb1577c55527 100644 --- a/tests/data/Makefile.am +++ b/tests/data/Makefile.am @@ -35,6 +35,7 @@ test-read-write/test28-without-std-fns-ref.xml \ test-read-write/test28-drop-std-vars.abignore \ test-read-write/test28-without-std-vars-ref.xml \ test-read-write/test28-without-std-vars.xml \ +test-read-write/test-crc.xml \ \ test-write-read-archive/test0.xml \ test-write-read-archive/test1.xml \ @@ -57,6 +58,7 @@ test-core-diff/report11.txt \ test-core-diff/report12.txt \ test-core-diff/report13.txt \ \ +test-abidiff/empty-report.txt \ test-abidiff/test-enum0-v0.cc.bi \ test-abidiff/test-enum0-v1.cc.bi \ test-abidiff/test-enum0-report.txt \ @@ -77,17 +79,18 @@ test-abidiff/test-var0-v1.cc.bi \ test-abidiff/test-var0-report.txt \ test-abidiff/test-PR18166-libtirpc.so \ test-abidiff/test-PR18166-libtirpc.so.abi \ -test-abidiff/test-PR18166-libtirpc.so.report.txt \ test-abidiff/test-PR18791-report0.txt \ test-abidiff/test-PR18791-v0.so.abi \ test-abidiff/test-PR18791-v1.so.abi \ -test-abidiff/test-PR24552-report0.txt \ test-abidiff/test-PR24552-v0.abi \ test-abidiff/test-PR24552-v1.abi \ test-abidiff/test-empty-corpus-0.xml \ test-abidiff/test-empty-corpus-1.xml \ test-abidiff/test-empty-corpus-2.xml \ -test-abidiff/test-empty-corpus-report.txt \ +test-abidiff/test-crc-0.xml \ +test-abidiff/test-crc-1.xml \ +test-abidiff/test-crc-2.xml \ +test-abidiff/test-crc-report.txt \ \ test-abidiff-exit/test1-voffset-change-report0.txt \ test-abidiff-exit/test1-voffset-change-report1.txt \ @@ -197,6 +200,9 @@ test-abidiff-exit/test-non-leaf-array-v0.o \ test-abidiff-exit/test-non-leaf-array-v1.c \ test-abidiff-exit/test-non-leaf-array-v1.o \ test-abidiff-exit/test-non-leaf-array-report.txt \ +test-abidiff-exit/test-crc-report.txt \ +test-abidiff-exit/test-crc-v0.abi \ +test-abidiff-exit/test-crc-v1.abi \ test-abidiff-exit/test-missing-alias-report.txt \ test-abidiff-exit/test-missing-alias.abi \ test-abidiff-exit/test-missing-alias.suppr \ @@ -1951,4 +1957,7 @@ test-symtab/kernel-5.6/single_function_gpl.ko \ test-symtab/kernel-5.6/single_variable.c \ test-symtab/kernel-5.6/single_variable.ko \ test-symtab/kernel-5.6/single_variable_gpl.c \ -test-symtab/kernel-5.6/single_variable_gpl.ko +test-symtab/kernel-5.6/single_variable_gpl.ko \ +test-symtab/kernel-modversions/Makefile \ +test-symtab/kernel-modversions/one_of_each.c \ +test-symtab/kernel-modversions/one_of_each.ko diff --git a/tests/data/test-abidiff-exit/test-crc-report.txt b/tests/data/test-abidiff-exit/test-crc-report.txt new file mode 100644 index 000000000000..ddba41f40dad --- /dev/null +++ b/tests/data/test-abidiff-exit/test-crc-report.txt @@ -0,0 +1,15 @@ +Functions changes summary: 0 Removed, 1 Changed (1 filtered out), 0 Added functions +Variables changes summary: 0 Removed, 1 Changed, 0 Added variable + +1 function with some indirect sub-type change: + + [C] 'function void func1(E)' has some indirect sub-type changes: + + CRC value (modversions) changed from 0x10000001 to 0x10000002 + +1 Changed variable: + + [C] 'int var1' was changed: + + CRC value (modversions) changed from 0x30000001 to 0x30000002 + diff --git a/tests/data/test-abidiff-exit/test-crc-v0.abi b/tests/data/test-abidiff-exit/test-crc-v0.abi new file mode 100644 index 000000000000..320899fc97ff --- /dev/null +++ b/tests/data/test-abidiff-exit/test-crc-v0.abi @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-abidiff-exit/test-crc-v1.abi b/tests/data/test-abidiff-exit/test-crc-v1.abi new file mode 100644 index 000000000000..0baa66e4766b --- /dev/null +++ b/tests/data/test-abidiff-exit/test-crc-v1.abi @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-abidiff/test-PR18166-libtirpc.so.report.txt b/tests/data/test-abidiff/empty-report.txt similarity index 100% rename from tests/data/test-abidiff/test-PR18166-libtirpc.so.report.txt rename to tests/data/test-abidiff/empty-report.txt diff --git a/tests/data/test-abidiff/test-PR24552-report0.txt b/tests/data/test-abidiff/test-PR24552-report0.txt deleted file mode 100644 index a9d032e74e35..000000000000 --- a/tests/data/test-abidiff/test-PR24552-report0.txt +++ /dev/null @@ -1,3 +0,0 @@ -Functions changes summary: 0 Removed, 0 Changed, 0 Added function -Variables changes summary: 0 Removed, 0 Changed, 0 Added variable - diff --git a/tests/data/test-abidiff/test-crc-0.xml b/tests/data/test-abidiff/test-crc-0.xml new file mode 100644 index 000000000000..a5cdee7adcec --- /dev/null +++ b/tests/data/test-abidiff/test-crc-0.xml @@ -0,0 +1,1601 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-abidiff/test-crc-1.xml b/tests/data/test-abidiff/test-crc-1.xml new file mode 100644 index 000000000000..9e1289ce5584 --- /dev/null +++ b/tests/data/test-abidiff/test-crc-1.xml @@ -0,0 +1,1601 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-abidiff/test-crc-2.xml b/tests/data/test-abidiff/test-crc-2.xml new file mode 100644 index 000000000000..bf21ca6f93e4 --- /dev/null +++ b/tests/data/test-abidiff/test-crc-2.xml @@ -0,0 +1,1601 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-abidiff/test-crc-report.txt b/tests/data/test-abidiff/test-crc-report.txt new file mode 100644 index 000000000000..4572a207a5ae --- /dev/null +++ b/tests/data/test-abidiff/test-crc-report.txt @@ -0,0 +1,9 @@ +Functions changes summary: 0 Removed, 1 Changed, 0 Added function +Variables changes summary: 0 Removed, 0 Changed, 0 Added variable + +1 function with some indirect sub-type change: + + [C] 'function void exported_function()' has some indirect sub-type changes: + + CRC value (modversions) changed from 0xe52d5bcf to 0xe52d5bd0 + diff --git a/tests/data/test-abidiff/test-empty-corpus-report.txt b/tests/data/test-abidiff/test-empty-corpus-report.txt deleted file mode 100644 index a9d032e74e35..000000000000 --- a/tests/data/test-abidiff/test-empty-corpus-report.txt +++ /dev/null @@ -1,3 +0,0 @@ -Functions changes summary: 0 Removed, 0 Changed, 0 Added function -Variables changes summary: 0 Removed, 0 Changed, 0 Added variable - diff --git a/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi b/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi index 4c9a766f1c7c..a8f632bea3f7 100644 --- a/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi +++ b/tests/data/test-read-dwarf/PR25007-sdhci.ko.abi @@ -1,41 +1,41 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/test-read-write/test-crc.xml b/tests/data/test-read-write/test-crc.xml new file mode 100644 index 000000000000..d74bb5700383 --- /dev/null +++ b/tests/data/test-read-write/test-crc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/tests/data/test-symtab/kernel-modversions/Makefile b/tests/data/test-symtab/kernel-modversions/Makefile new file mode 100644 index 000000000000..1479ae4b03b0 --- /dev/null +++ b/tests/data/test-symtab/kernel-modversions/Makefile @@ -0,0 +1,19 @@ +obj-m += one_of_each.o + +# Overwrite to an actual kernel dir when using this: +# +# $ make KDIR=/path/to/actual/kernel/source/dir +# +KDIR := /tmp/some/kernel/source/dir + +PWD := $(shell pwd) +default: + make -C $(KDIR) tinyconfig + cd $(KDIR) && ./scripts/config -e 64BIT -e MODULES -e MODVERSIONS -e CONFIG_DEBUG_INFO + $(MAKE) -C $(KDIR) olddefconfig + $(MAKE) -C $(KDIR) + $(MAKE) -C $(KDIR) M=$(PWD) modules + rm -rf *.mod.c *.o .*.cmd .*.d *.mod modules.order Module.symvers .tmp_versions + +clean: + rm -f *.ko diff --git a/tests/data/test-symtab/kernel-modversions/one_of_each.c b/tests/data/test-symtab/kernel-modversions/one_of_each.c new file mode 120000 index 000000000000..27c87e5758cb --- /dev/null +++ b/tests/data/test-symtab/kernel-modversions/one_of_each.c @@ -0,0 +1 @@ +../kernel/one_of_each.c \ No newline at end of file diff --git a/tests/data/test-symtab/kernel-modversions/one_of_each.ko b/tests/data/test-symtab/kernel-modversions/one_of_each.ko new file mode 100644 index 0000000000000000000000000000000000000000..c6f1bed5a04fdd035459d11260a940ef1b45f35d GIT binary patch literal 131760 zcmeFa33Oc5l{R{Bm83eFt29(;vRsyATec<7gN(5)%a$z}TQVLr7@M+&(ttHZg9ivh z7y^MnfG`sX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HcmV?d00001 diff --git a/tests/test-abidiff-exit.cc b/tests/test-abidiff-exit.cc index 38f1301eb924..76fde58fdbae 100644 --- a/tests/test-abidiff-exit.cc +++ b/tests/test-abidiff-exit.cc @@ -392,6 +392,17 @@ InOutSpec in_out_specs[] = "data/test-abidiff-exit/test-non-leaf-array-report.txt", "output/test-abidiff-exit/test-non-leaf-array-report.txt" }, + { + "data/test-abidiff-exit/test-crc-v0.abi", + "data/test-abidiff-exit/test-crc-v1.abi", + "", + "", + "", + "", + abigail::tools_utils::ABIDIFF_ABI_CHANGE, + "data/test-abidiff-exit/test-crc-report.txt", + "output/test-abidiff-exit/test-crc-report.txt" + }, { "data/test-abidiff-exit/test-missing-alias.abi", "data/test-abidiff-exit/test-missing-alias.abi", diff --git a/tests/test-abidiff.cc b/tests/test-abidiff.cc index 82683f426d66..3452b7ee7284 100644 --- a/tests/test-abidiff.cc +++ b/tests/test-abidiff.cc @@ -77,7 +77,7 @@ static InOutSpec specs[] = { "data/test-abidiff/test-PR18166-libtirpc.so.abi", "data/test-abidiff/test-PR18166-libtirpc.so.abi", - "data/test-abidiff/test-PR18166-libtirpc.so.report.txt", + "data/test-abidiff/empty-report.txt", "output/test-abidiff/test-PR18166-libtirpc.so.report.txt" }, { @@ -89,26 +89,44 @@ static InOutSpec specs[] = { "data/test-abidiff/test-PR24552-v0.abi", "data/test-abidiff/test-PR24552-v1.abi", - "data/test-abidiff/test-PR24552-report0.txt", + "data/test-abidiff/empty-report.txt", "output/test-abidiff/test-PR24552-report0.txt" }, { "data/test-abidiff/test-empty-corpus-0.xml", "data/test-abidiff/test-empty-corpus-0.xml", - "data/test-abidiff/test-empty-corpus-report.txt", - "output/test-abidiff/test-empty-corpus-report.txt" + "data/test-abidiff/empty-report.txt", + "output/test-abidiff/test-empty-corpus-report-0.txt" }, { "data/test-abidiff/test-empty-corpus-1.xml", "data/test-abidiff/test-empty-corpus-1.xml", - "data/test-abidiff/test-empty-corpus-report.txt", - "output/test-abidiff/test-empty-corpus-report.txt" + "data/test-abidiff/empty-report.txt", + "output/test-abidiff/test-empty-corpus-report-1.txt" }, { "data/test-abidiff/test-empty-corpus-2.xml", "data/test-abidiff/test-empty-corpus-2.xml", - "data/test-abidiff/test-empty-corpus-report.txt", - "output/test-abidiff/test-empty-corpus-report.txt" + "data/test-abidiff/empty-report.txt", + "output/test-abidiff/test-empty-corpus-report-1.txt" + }, + { + "data/test-abidiff/test-crc-0.xml", + "data/test-abidiff/test-crc-1.xml", + "data/test-abidiff/empty-report.txt", + "output/test-abidiff/test-crc-report-0-1.txt" + }, + { + "data/test-abidiff/test-crc-1.xml", + "data/test-abidiff/test-crc-0.xml", + "data/test-abidiff/empty-report.txt", + "output/test-abidiff/test-crc-report-1-0.txt" + }, + { + "data/test-abidiff/test-crc-1.xml", + "data/test-abidiff/test-crc-2.xml", + "data/test-abidiff/test-crc-report.txt", + "output/test-abidiff/test-crc-report-1-2.txt" }, // This should be the last entry. {0, 0, 0, 0} diff --git a/tests/test-read-write.cc b/tests/test-read-write.cc index ffca005251c0..54bc2b5e9fb2 100644 --- a/tests/test-read-write.cc +++ b/tests/test-read-write.cc @@ -238,6 +238,12 @@ InOutSpec in_out_specs[] = "data/test-read-write/test28-without-std-vars-ref.xml", "output/test-read-write/test28-without-std-vars.xml" }, + { + "data/test-read-write/test-crc.xml", + "", + "data/test-read-write/test-crc.xml", + "output/test-read-write/test-crc.xml", + }, // This should be the last entry. {NULL, NULL, NULL, NULL} }; diff --git a/tests/test-symtab.cc b/tests/test-symtab.cc index e843738bedad..830f3ec80608 100644 --- a/tests/test-symtab.cc +++ b/tests/test-symtab.cc @@ -410,3 +410,18 @@ TEST_CASE("Symtab::SimpleKernelSymtabs", "[symtab, basic, kernel, ksymtab]") } } } + +TEST_CASE("Symtab::KernelSymtabsWithCRC", "[symtab, crc, kernel, ksymtab]") +{ + const std::string base_path = "kernel-modversions/"; + + GIVEN("a binary with one function and one variable (GPL) exported") + { + const std::string binary = base_path + "one_of_each.ko"; + const corpus_sptr& corpus = assert_symbol_count(binary, 2, 2); + CHECK(corpus->lookup_function_symbol("exported_function")->get_crc() != 0); + CHECK(corpus->lookup_function_symbol("exported_function_gpl")->get_crc() != 0); + CHECK(corpus->lookup_variable_symbol("exported_variable")->get_crc() != 0); + CHECK(corpus->lookup_variable_symbol("exported_variable_gpl")->get_crc() != 0); + } +}