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