From patchwork Tue May 7 08:42:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 32576 Received: (qmail 110072 invoked by alias); 7 May 2019 08:42:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 110064 invoked by uid 89); 7 May 2019 08:42:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 May 2019 08:42:47 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 5CD02ACFA; Tue, 7 May 2019 08:42:45 +0000 (UTC) Date: Tue, 7 May 2019 10:42:43 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Yao Qi , Tom Tromey Subject: [committed][gdb/testsuite] Fix handling of DW_FORM_ref_addr in dwarf assembler Message-ID: <20190507084241.GA25711@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi, When running gdb.dwarf2/multidictionary.exp with target board cc-with-dwz and current dwz, we run into a dwz abort: ... gdb compile failed, gdb/contrib/cc-with-tweaks.sh: line 188: 11484 Aborted \ (core dumped) $DWZ "$output_file" > /dev/null 2>&1 UNTESTED: gdb.dwarf2/multidictionary.exp: multidictionary.exp ... The dwz abort (PR dwz/24169) is caused by an invalid DW_FORM_ref_addr in the multidictionary binary. The multidictionary binary is build from multidictionary.S which is generated using the dwarf assembler, and multidictionary.S contains dwarf for 3 compilation units. In multidictionary0.o (generated from multidictionary.S), we find a concrete formal parameter DIE: ... <2>: Abbrev Number: 4 (DW_TAG_formal_parameter)
DW_AT_abstract_origin: <0xa6> ... referring to an abstract formal parameter DIE at 0xa6: ... <2>: Abbrev Number: 8 (DW_TAG_formal_parameter) DW_AT_name : msg DW_AT_type : <0x92> ... but in the multidictionary binary the concrete formal parameter DIE is still referring to 0xa6: ... <2><1a3>: Abbrev Number: 4 (DW_TAG_formal_parameter) <1a4> DW_AT_abstract_origin: <0xa6> ... while the abstract formal parameter DIE has moved to 0x16d: ... <2><16d>: Abbrev Number: 8 (DW_TAG_formal_parameter) <16e> DW_AT_name : msg <172> DW_AT_type : <0x159> ... The concrete formal parameter DIE is specified in multidictionary.S like this: ... .Llabel21: .uleb128 4 .4byte .Llabel17 - .Lcu1_begin ... The problem is that the .Lcu1_begin label is assumed to mark the start of the .debug_info section in the executable, but in fact it marks the start of the first compilation unit from multidictionary.S in the executable. Usually these two entities are the same, but they are not when linked in object files contain dwarf info and are placed in the .debug_info section before the compilation units generated from multidictionary.S. Fix this in the dwarf assembler by generating instead the label itself: ... .Llabel21: .uleb128 4 .4byte .Llabel17 ... resulting in a relocation in the object file: ... Offset Info Type Sym. Value Sym. Name + Addend 0000000000dd 00040000000a R_X86_64_32 0000000000000000 .debug_info + a6 ... and resulting in the correct offset in the executable: ... <2><1a3>: Abbrev Number: 4 (DW_TAG_formal_parameter) <1a4> DW_AT_abstract_origin: <0x16d> ... Tested on x86_64-linux with native and cc-with-dwz. Committed to trunk. Thanks, - Tom [gdb/testsuite] Fix handling of DW_FORM_ref_addr in dwarf assembler gdb/testsuite/ChangeLog: 2019-05-07 Tom de Vries PR testsuite/24159 * lib/dwarf.exp: Fix handling of DW_FORM_ref_addr. --- gdb/testsuite/lib/dwarf.exp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gdb/testsuite/lib/dwarf.exp b/gdb/testsuite/lib/dwarf.exp index 3cc592890c..75d19abf80 100644 --- a/gdb/testsuite/lib/dwarf.exp +++ b/gdb/testsuite/lib/dwarf.exp @@ -567,10 +567,8 @@ namespace eval Dwarf { } % { - # Label reference, an offset from .debug_info. Assuming - # .Lcu1_begin is on .debug_info. - set cu1_label [_compute_label "cu1_begin"] - set new_value "[string range $value 1 end] - $cu1_label" + # Label reference, an offset from .debug_info. + set new_value "[string range $value 1 end]" return DW_FORM_ref_addr }