From patchwork Fri Aug 27 18:54:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Giuliano Procida X-Patchwork-Id: 44801 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 84E673858003 for ; Fri, 27 Aug 2021 18:55:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 84E673858003 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1630090519; bh=FS6zPM9/s+gN/dK4EQUxiXJjfPN/DnwLr+aOSRPO6SE=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Help: List-Subscribe:From:Reply-To:Cc:From; b=BbzVVkjFsrV1TQmsySyCize+/cyFHd+81D/V1Qch/3cen//o2Nl9F4sRJfhqLvDgY CWEUXUR3KPRc6vBZL4kd85ZthXdYP2ndPDcHZ5h2BDFJSJ2dwGZEeHRtQkfZiiQoc6 eLRZ1oNGPG6IeaA+AWhYSv+yVl/m4ECMcwYoDcOI= 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 26352385841C for ; Fri, 27 Aug 2021 18:55:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 26352385841C Received: by mail-qk1-x749.google.com with SMTP id t18-20020a05620a0b1200b003f8729fdd04so1041036qkg.5 for ; Fri, 27 Aug 2021 11:55:06 -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:message-id:mime-version:subject:from:to:cc :content-transfer-encoding; bh=FS6zPM9/s+gN/dK4EQUxiXJjfPN/DnwLr+aOSRPO6SE=; b=TW2BYyy62M+GCAhoY5VlmBE0/jm12SqzmXwevdoNvfC+ZgTaggDdoeqeXD8ms/ldGO ytVEoishVwME8rPHvM3SVQbSMpEkeZuwZoB/40NYmAf9rtTQnlQVkcRUXppxwZ3L0SSl 0D9qoQgByAJ6zSQ1Pf4/9lsJYVX0AYVDHLmjbt2CtkHTvTHJzCNKgt95rHjYws4oDTT0 wBrmAv0RbOpGVwqxVr2x/9rPT0VaWt5ll/+BsmYTE5pC5LifWE3VsSYfLKHpQj+1+Q5k gjvYu5ESbC+zF48FfsSiwjEYlU4Nrb66oRdQNhZjTACpaeGKp8gN3P0RcWTOCTIiNCwU wZkw== X-Gm-Message-State: AOAM530E1UsIDn/pgYwrne/+o+RKIm63EIm/zhzj1nfDrk3XWV65vAXy XyyxOYl9E7z55zUmFX2smI4Q6xFPxdHVnH/5uaak4tfYaZPehP2v6I/rWWs6Cz3c11sMHNsifEb iKV5nmBeDj1deTWh3O7nXD+SLoYVhrhSBpZf6i0QKGWehRRtn6k8oiBjRTTyqg08MH52iHM4= X-Google-Smtp-Source: ABdhPJw4xDhVFqjX0JFtLBfjufEyccOfiTb84RkDkwWxXgCePQSCorjcE/GRKxXho6VbXoYdQdOmpEkwrO3fdw== X-Received: from tef.lon.corp.google.com ([2a00:79e0:d:210:3c20:7cb5:7c1f:3951]) (user=gprocida job=sendgmr) by 2002:a05:6214:29cd:: with SMTP id gh13mr11168111qvb.25.1630090505749; Fri, 27 Aug 2021 11:55:05 -0700 (PDT) Date: Fri, 27 Aug 2021 19:54:45 +0100 Message-Id: <20210827185445.952297-1-gprocida@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.33.0.259.gc128427fd7-goog Subject: [PATCH] Interpret DWARF 5 addrx locations. To: libabigail@sourceware.org X-Spam-Status: No, score=-22.3 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 @@ - - + + + + + + - - + +