From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3CTUpYQgKCigKTVSGMHEKSSKPI.GSQPMFEFMKEMPWSYVGIaEVI.SVK@flex--gprocida.bounces.google.com> 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. From: Giuliano Procida To: libabigail@sourceware.org Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com, maennich@google.com, mark@klomp.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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-List-Received-Date: Fri, 27 Aug 2021 18:55:16 -0000 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=3D28220 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 =3D 0; =20 is_tls_address =3D false; - if (!die_location_expr(die, DW_AT_location, &expr, &expr_len)) + + if (!die) return false; =20 - int64_t addr =3D 0; - if (!eval_last_constant_dwarf_sub_expr(expr, expr_len, addr, is_tls_addr= ess)) + Dwarf_Attribute attr; + if (!dwarf_attr_integrate(const_cast(die), DW_AT_location, &= attr)) return false; =20 - address =3D 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 =3D=3D 0) + return false; =20 + 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 =3D expr->number; + return true; + } +} =20 /// 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.a= bi 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 @@ - - + + + + + + - - + + --=20 2.33.0.259.gc128427fd7-goog