From patchwork Fri Jul 3 16:46:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Matthias_M=C3=A4nnich?= X-Patchwork-Id: 39894 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 B9C6F3844079; Fri, 3 Jul 2020 16:48:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B9C6F3844079 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1593794881; bh=bjvevK4XRxlsEQarn4V+87rXypA7XXC5pAyzcLO0xvM=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=ys/dPiWeWXvuIOrPxwNwPJO56CTlnnaHPgwwthfVa7d41JNWqMC+RIrQCFcAMFSRU 7nvVA77B9g5++N+0LaE/FCUeutxxo5m1Ek3DlnPOnYqDeICsD5HLh4+8I2jGMzfhY/ yusg1V9N6Rrj5xP14phpZFZJuozGnnuDJlHtYK0E= X-Original-To: libabigail@sourceware.org Delivered-To: libabigail@sourceware.org Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by sourceware.org (Postfix) with ESMTPS id 964B63844038 for ; Fri, 3 Jul 2020 16:47:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 964B63844038 Received: by mail-yb1-xb4a.google.com with SMTP id j3so34223570yba.14 for ; Fri, 03 Jul 2020 09:47:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=bjvevK4XRxlsEQarn4V+87rXypA7XXC5pAyzcLO0xvM=; b=sP86Wugxn0VabhgHORv4juYUAj3xbzR5jsWqsGPYGscbs8Oq596ST1ODtyMclBQV+O ACpr9rEkqw+nqQ5NYkQsWOsPVP4T2rQCMtoZUR5K+8yfaeqdHE0IleY85+aFC2joWT4V xnQFPillStOP5viQQQNSn04VHnYLyxUZV1M4XD/RueSqhM4wPJP7z59CaEjKvbJ3Y2H1 ledRIGJcohkwTP4c7dtLW5GvDpwY0fy7eDik81uWmm0GRUk5E4Kq96fQ5+jMQO+JI97J 09jnaH1O4WWtDUjxFfVztnaOShw6v70vA/hT90WKvhAynooiIj2ef7WHzKBKCer42Mjx Q+UQ== X-Gm-Message-State: AOAM532a7MZohyeha/NbkezYlrj2l70vU70olk2kuSMeLXg9qCnrBwxS xBzlwtw6J6YEHunB/FE3Lj+ip6cBd4YHx2BL0UNbaKcVWo0DY8dNsNJEm98bdjY2jjgJLYWnQeu yvTgCu77CQX6Y4PhUErDGN2dObQilrbTxA0dUGr0FhvqcmJJLg2EdWMMzFiY+OlNkjDAu3S4= X-Google-Smtp-Source: ABdhPJwG8ncR1At1tgNiEip0zsJ3k4yszVS1VyFuD25xdv2gD/Ie0YpMe5jep9MH5guLsBPqIpjxGLR/+CIR/A== X-Received: by 2002:a25:37ca:: with SMTP id e193mr59162145yba.505.1593794879036; Fri, 03 Jul 2020 09:47:59 -0700 (PDT) Date: Fri, 3 Jul 2020 18:46:41 +0200 In-Reply-To: <20200703164651.1510825-1-maennich@google.com> Message-Id: <20200703164651.1510825-12-maennich@google.com> Mime-Version: 1.0 References: <20200619214305.562-1-maennich@google.com> <20200703164651.1510825-1-maennich@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH v2 11/21] dwarf-reader: read_context: use new symtab in *_symbols_is_exported 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" 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 d9c1c03d273f..6f792a957076 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -5515,11 +5515,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; @@ -5528,16 +5528,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(); } @@ -5555,11 +5547,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; @@ -5568,16 +5560,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(); }