From patchwork Fri Aug 27 18:57:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 44802 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 26CDE385801E for ; Fri, 27 Aug 2021 18:58:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 26CDE385801E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630090696; bh=FS6zPM9/s+gN/dK4EQUxiXJjfPN/DnwLr+aOSRPO6SE=; h=Date:In-Reply-To:References:Subject:To:List-Id:List-Unsubscribe: List-Archive:List-Help:List-Subscribe:From:Reply-To:Cc:From; b=OmamD24rbMMyklABfQBvYrC3obvIF1nrtsXyFpmnW3a1zX788CjXVE3GSHgyRmr7L A+XHtKh3rJmZxLH5K3232IKZi7tzcJX5hiYRFZDGWWxxQFPn230PpIReUzuZzLSREN Ui5kaCCDBsTBhHp/ynf7sc27knwP9A475VTJUsGo= 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 AC8E8385781C for ; Fri, 27 Aug 2021 18:58:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org AC8E8385781C Received: by mail-qt1-x849.google.com with SMTP id p21-20020ac846150000b02902982d999bfbso793889qtn.7 for ; Fri, 27 Aug 2021 11:58:02 -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:content-transfer-encoding; bh=FS6zPM9/s+gN/dK4EQUxiXJjfPN/DnwLr+aOSRPO6SE=; b=NPt/0RhcfbGSFdgte084t91H4fSbYIgZye4SUWUXnd3uWEvqtU/bxdLcs8ZJwMsc0y EvRGqA0lkHtdhAWsFDqlUYBAtDK0WGlaGw/uIe+/zNMGYlpkVfW/UCoemyWKyAFdP6Zi qrm63NEqfrQ1MgjtOZVsYCHQcIk1itfSqRtxwsW+E0CVVXOn3VrYIxq5HRW/s/lajOXS Cr+fZ1t+3E1WFe9nLZz+CHB3cfoGjW/rLYNvg8/odL7Akv3R/469xRNNYM9twNUI8193 KhvwJ51YHD2zPj7ewjwXXyXNQMZ4tvssNrCAXZV9oBS/K6B4iJQrJSItCiZhKpDonf/x geWg== X-Gm-Message-State: AOAM533D/560xVDw1XsQE+7a2bJs8HNBmUkPjeFvoSahe6tQ5fZOC6t0 C1ZmQizzJVIjAWIFb6bNYLb7QbEqNty3z9v4rl2p+oHxdnDPrmKoKiyIIF1Jlxx2dguuvRwJj3h YvHqx14FmT/9N+YIubVUmQuow6Di9UCRcsH70TDh9nRm5g5SZ0ad64cfOnLBFZdjQzz/VRws= X-Google-Smtp-Source: ABdhPJxVTpzZU/9ppFv4E6JYDr1tOVxVyy3HV5pvXW1AsIPcd2NfiwvVTfNiODnxWJ6griNFkk1vZyAGxuQ62g== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:3c20:7cb5:7c1f:3951]) (user=gprocida job=sendgmr) by 2002:a0c:f68e:: with SMTP id p14mr11433102qvn.13.1630090682210; Fri, 27 Aug 2021 11:58:02 -0700 (PDT) Date: Fri, 27 Aug 2021 19:57:55 +0100 In-Reply-To: <20210827185445.952297-1-gprocida@google.com> Message-Id: <20210827185755.953243-1-gprocida@google.com> Mime-Version: 1.0 References: <20210827185445.952297-1-gprocida@google.com> X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog Subject: [PATCH v2] Bug 28191 - Interpret DWARF 5 addrx locations To: libabigail@sourceware.org X-Spam-Status: No, score=-21.9 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Giuliano Procida via Libabigail From: Giuliano Procida Reply-To: Giuliano Procida Cc: maennich@google.com, kernel-team@android.com, mark@klomp.org Errors-To: libabigail-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libabigail" The DWARF 5 location operation DW_OP_addrx is emitted by Clang. It's not currently understood by libabigail, resulting in symbols not being linked to their type information in the ABI representation. This patch adds basic support, using the libdw dwarf_getlocation_attr function. Even with this patch, 32-bit DWARF will be misread until elfutils includes the https://sourceware.org/bugzilla/show_bug.cgi?id=28220 fix. * src/abg-dwarf-reader.cc (die_location_address): Use dwarf_attr_integrate, dwarf_getlocation and dwarf_getlocation_attr to decode addreses, instead of die_location_expr and eval_last_constant_dwarf_sub_expr. * tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi: Refresh test reference output; two more symbols have types. Signed-off-by: Giuliano Procida --- src/abg-dwarf-reader.cc | 26 ++++-- .../PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi | 86 +++++++++++-------- 2 files changed, 70 insertions(+), 42 deletions(-) diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc index 09eb1d70..e4470512 100644 --- a/src/abg-dwarf-reader.cc +++ b/src/abg-dwarf-reader.cc @@ -8764,17 +8764,31 @@ die_location_address(Dwarf_Die* die, uint64_t expr_len = 0; is_tls_address = false; - if (!die_location_expr(die, DW_AT_location, &expr, &expr_len)) + + if (!die) return false; - int64_t addr = 0; - if (!eval_last_constant_dwarf_sub_expr(expr, expr_len, addr, is_tls_address)) + Dwarf_Attribute attr; + if (!dwarf_attr_integrate(const_cast(die), DW_AT_location, &attr)) return false; - address = addr; - return true; -} + if (dwarf_getlocation(&attr, &expr, &expr_len)) + return false; + // Ignore location expressions where reading them succeeded but + // their length is 0. + if (expr_len == 0) + return false; + Dwarf_Attribute result; + if (!dwarf_getlocation_attr(&attr, expr, &result)) { + // A location that has been interpreted as an address. + return !dwarf_formaddr(&result, &address); + } else { + // Just get the address out of the number field. + address = expr->number; + return true; + } +} /// Return the index of a function in its virtual table. That is, /// return the value of the DW_AT_vtable_elem_location attribute. diff --git a/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi b/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi index cb8303d1..4bc4c375 100644 --- a/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi +++ b/tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi @@ -642,6 +642,14 @@ + + + + + + + + @@ -668,6 +676,7 @@ + @@ -676,6 +685,7 @@ + @@ -730,11 +740,11 @@ - - + + - + @@ -742,7 +752,7 @@ - + @@ -771,63 +781,63 @@ - + - - - + + + - + - + - + - + - + - + - + - + - + - + - + @@ -837,7 +847,7 @@ - + @@ -947,8 +957,8 @@ - - + + @@ -977,13 +987,13 @@ - + - + @@ -997,10 +1007,10 @@ - - + + - + @@ -1033,9 +1043,9 @@ - - - + + + @@ -1048,11 +1058,11 @@ - + - + @@ -1071,11 +1081,15 @@ - - + + + + + + - - + +