From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 113499 invoked by alias); 25 Dec 2018 14:10:03 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 113375 invoked by uid 48); 25 Dec 2018 14:09:58 -0000 From: "mark at klomp dot org" To: elfutils-devel@sourceware.org Subject: [Bug libdw/23981] dwarf_siblingof() fails with attribute form DW_FORM_ref_addr Date: Tue, 25 Dec 2018 14:10:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: elfutils X-Bugzilla-Component: libdw X-Bugzilla-Version: unspecified X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: mark at klomp dot org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at sourceware dot org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc everconfirmed Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://sourceware.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2018-q4/txt/msg00228.txt.bz2 https://sourceware.org/bugzilla/show_bug.cgi?id=3D23981 Mark Wielaard changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |ASSIGNED Last reconfirmed| |2018-12-25 CC| |mark at klomp dot org Ever confirmed|0 |1 --- Comment #1 from Mark Wielaard --- (In reply to Andreas Kromke from comment #0) > The API function dwarf_siblingof() internally calls __libdw_formref() whi= ch > is deprecated and especially does not support DW_FORM_ref_addr, resulting= in > a return code of -1 (format error). >=20 > Instead dwarf_siblingof() should call dwarf_formref_die() or an internal > variant of that. Yes, __libdw_formref() only handles relative DIE offsets. In theory a produ= cer might also use one of the other DIE reference forms, although only DW_FORM_ref_addr might make sense for DW_AT_sibling (DW_FORM_ref_sig8, DW_FORM_ref_alt, DW_FORM_ref_sup4, DW_FORM_ref_sup8 and DW_FORM_GNU_ref_alt= all point outside the current CU, so aren't appropriate). DW_FORM_ref_addr might not be the most efficient way to encode DW_AT_sibling and is normally used for cross CU DIE references. But we should probably support it, if it is used as inter CU die reference. Does the following work for you: https://code.wildebeest.org/git/user/mjw/elfutils/commit/?h=3Dsibling-ref-a= ddr diff --git a/libdw/dwarf_siblingof.c b/libdw/dwarf_siblingof.c index 613d20908..b0d9dd75f 100644 --- a/libdw/dwarf_siblingof.c +++ b/libdw/dwarf_siblingof.c @@ -71,8 +71,28 @@ dwarf_siblingof (Dwarf_Die *die, Dwarf_Die *result) Dwarf_Off offset; sibattr.valp =3D addr; if (unlikely (__libdw_formref (&sibattr, &offset) !=3D 0)) - /* Something went wrong. */ - return -1; + { + /* __libdw_formref only handles relative forms, there is + also DW_FORM_ref_addr which might be used for inter + CU DIE references too (all other reference FORMs + point outside the current CU by definition). */ + if (sibattr.form =3D=3D DW_FORM_ref_addr) + { + uint8_t ref_size; + struct Dwarf_CU *cu =3D sibattr.cu; + if (cu->version =3D=3D 2) + ref_size =3D cu->address_size; + else + ref_size =3D cu->offset_size; + + if (__libdw_read_offset (cu->dbg, cu->dbg, IDX_debug_info, + sibattr.valp, ref_size, &offset, + IDX_debug_info, 0)) + return -1; + } + else + return -1; + } /* The sibling attribute should point after this DIE in the CU. But not after the end of the CU. */ Also do you have an example file to use as test case? What DWARF producer generated a DW_AT_sibling with DW_FORM_ref_addr? --=20 You are receiving this mail because: You are on the CC list for the bug.