From patchwork Thu Aug 8 12:49:08 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: 34006 Received: (qmail 76241 invoked by alias); 8 Aug 2019 12:49:14 -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 76227 invoked by uid 89); 8 Aug 2019 12:49:13 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.0 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; Thu, 08 Aug 2019 12:49:12 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 6BB4DAF54; Thu, 8 Aug 2019 12:49:10 +0000 (UTC) Date: Thu, 8 Aug 2019 14:49:08 +0200 From: Tom de Vries To: gdb-patches@sourceware.org Cc: Kevin Buettner Subject: [PATCH][gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie Message-ID: <20190808124907.GA19791@delia> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-IsSubscribed: yes Hi, With target board unix/-fPIE/-pie, we get: ... FAIL: gdb.dwarf2/varval.exp: print varval2 ... This is due comparing a get_frame_pc result (which includes the for PIE non-zero relocation offset) with pc_high and pc_low obtained using get_scope_pc_bounds (which do not include the relocation offset). Fix this by adjusting pc_high and pc_low with the relocation offset. Tested on x86_64-linux with target board unix/-fPIE/-pie. OK for trunk? Thanks, - Tom [gdb] Fix gdb.dwarf2/varval.exp with -fPIE/-pie gdb/ChangeLog: 2019-08-08 Tom de Vries PR gdb/24591 * dwarf2read.c (dwarf2_fetch_die_loc_sect_off): Adjust pc_high and pc_low with relocation offset. --- gdb/dwarf2read.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 1c26f8355f..fde08047ca 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -23206,6 +23206,9 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, != dwarf2_per_objfile->abstract_to_concrete.end ())) { CORE_ADDR pc = (*get_frame_pc) (baton); + CORE_ADDR baseaddr + = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile)); + struct gdbarch *gdbarch = get_objfile_arch (objfile); for (const auto &cand_off : dwarf2_per_objfile->abstract_to_concrete[die->sect_off]) @@ -23220,6 +23223,8 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, CORE_ADDR pc_low, pc_high; get_scope_pc_bounds (cand->parent, &pc_low, &pc_high, cu); + pc_low = gdbarch_adjust_dwarf2_addr (gdbarch, pc_low + baseaddr); + pc_high = gdbarch_adjust_dwarf2_addr (gdbarch, pc_high + baseaddr); if (pc_low == ((CORE_ADDR) -1) || !(pc_low <= pc && pc < pc_high)) continue;