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(); }