From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31280 invoked by alias); 25 Mar 2010 22:44:38 -0000 Received: (qmail 31269 invoked by uid 22791); 25 Mar 2010 22:44:35 -0000 X-SWARE-Spam-Status: No, hits=-7.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 25 Mar 2010 22:44:27 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o2PMiPsp031939 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 25 Mar 2010 18:44:26 -0400 Received: from host0.dyn.jankratochvil.net (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o2PMiN2W001503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 25 Mar 2010 18:44:25 -0400 Received: from host0.dyn.jankratochvil.net (localhost [127.0.0.1]) by host0.dyn.jankratochvil.net (8.14.3/8.14.3) with ESMTP id o2PMiNlG001643 for ; Thu, 25 Mar 2010 23:44:23 +0100 Received: (from jkratoch@localhost) by host0.dyn.jankratochvil.net (8.14.3/8.14.3/Submit) id o2PMiMcR001642 for gdb-patches@sourceware.org; Thu, 25 Mar 2010 23:44:22 +0100 Date: Thu, 25 Mar 2010 22:44:00 -0000 From: Jan Kratochvil To: gdb-patches@sourceware.org Subject: [patch] PIE: Fix back re-run [Re: [patch] svr4_exec_displacement success indicator] Message-ID: <20100325224422.GA973@host0.dyn.jankratochvil.net> References: <20100307005326.GA29245@caradoc.them.org> <20100308213744.GA16628@host0.dyn.jankratochvil.net> <20100308215357.GA17132@host0.dyn.jankratochvil.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100308215357.GA17132@host0.dyn.jankratochvil.net> User-Agent: Mutt/1.5.20 (2009-08-17) X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-03/txt/msg00868.txt.bz2 Hi, currently: $ echo 'main(){}'|gcc -o 1 -fPIE -pie -x c -; ./gdb -nx -ex 'set disable-randomization off' -ex 'b main' -ex r -ex c -ex r ./1 Breakpoint 1 at 0x6b0 Starting program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/1 Breakpoint 1, 0x00007fbf73e8c6b0 in main () Continuing. Program exited with code 0140. Starting program: /home/jkratoch/redhat/gdb-clean/gdb/testsuite/1 Error in re-setting breakpoint 1: Cannot access memory at address 0x7fbf73e8c6ac It is since: [patch] svr4_exec_displacement success indicator [Re: PIE question] http://sourceware.org/ml/gdb-patches/2010-03/msg00336.html On Mon, 08 Mar 2010 22:53:58 +0100, Jan Kratochvil wrote: > Attached these changes: > > * svr4_exec_displacement calling convention should have success indicator. > > * Preserving now section_offsets if they are already set, inspired by > init_objfile_sect_indices. > > I believe either of parts would be sufficient for this problem. The first part has caused the regression for PIE on native x86* GNU/Linux host. As I believe for Daniel J.'s seen regression of `qOffsets' the second already checked-in part is sufficient - I would like to remove the first part. OK to check it in? No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu. (I do not think one needs to think about 7.1-branch as it is not a regression against any FSF GDB release.) Thanks, Jan gdb/ 2010-03-25 Jan Kratochvil Fix re-run of PIE executable. * solib-svr4.c (svr4_relocate_main_executable) : Remove the part of pre-set SYMFILE_OBJFILE->SECTION_OFFSETS. gdb/testsuite/ 2010-03-25 Jan Kratochvil Fix re-run of PIE executable. * gdb.base/break-interp.exp (test_ld): Turn off "disable-randomization". Remove $displacement_main to match the solib-svr4.c change. New "kill" and re-"run" of the inferior. --- a/gdb/solib-svr4.c +++ b/gdb/solib-svr4.c @@ -1791,17 +1791,10 @@ svr4_relocate_main_executable (void) { CORE_ADDR displacement; - if (symfile_objfile) - { - int i; - - /* Remote target may have already set specific offsets by `qOffsets' - which should be preferred. */ - - for (i = 0; i < symfile_objfile->num_sections; i++) - if (ANOFFSET (symfile_objfile->section_offsets, i) != 0) - return; - } + /* SYMFILE_OBJFILE->SECTION_OFFSETS may now contain displacement from the + previous run of the inferior. Re-set it according to the current value, + if we can find it out. But otherwise keep it as for remote target it may + have been pre-set by the `qOffsets' packet. */ if (! svr4_exec_displacement (&displacement)) return; --- a/gdb/testsuite/gdb.base/break-interp.exp +++ b/gdb/testsuite/gdb.base/break-interp.exp @@ -416,25 +416,28 @@ proc test_ld {file ifmain trynosym displacement} { # Print the "PIE (Position Independent Executable) displacement" message. gdb_test "set verbose on" + # A bit better test coverage. + gdb_test "set disable-randomization off" + reach "dl_main" "run segv" $displacement gdb_test "bt" "#0 +\[^\r\n\]*\\mdl_main\\M.*" "dl bt" if $ifmain { # Displacement message will be printed the second time on initializing - # the linker from svr4_special_symbol_handling. If any ANOFFSET has - # been already set as non-zero the detection will no longer be run. - if {$displacement == "NONZERO"} { - set displacement_main "NONE" - } else { - set displacement_main $displacement - } - reach "main" continue $displacement_main + # the linker from svr4_special_symbol_handling. + reach "main" continue $displacement reach "libfunc" continue "NONE" gdb_test "bt" "#0 +\[^\r\n\]*\\mlibfunc\\M\[^\r\n\]*\r\n#1 +\[^\r\n\]*\\mmain\\M.*" "main bt" + } + # Try re-run if the new PIE displacement takes effect. + gdb_test "kill" "" "kill" {Kill the program being debugged\? \(y or n\) } "y" + reach "dl_main" "run segv" $displacement + + if $ifmain { test_core $file $displacement test_attach $file $displacement