This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
ping: [patch 6/6] PIE: Fix back re-run
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 9 Jun 2010 17:10:08 +0200
- Subject: ping: [patch 6/6] PIE: Fix back re-run
- References: <20100329161905.GE2940@host0.dyn.jankratochvil.net>
Hi,
originally posted as:
[patch 6/6] PIE: Fix back re-run
http://sourceware.org/ml/gdb-patches/2010-03/msg01005.html
Rediffed only.
------------------------------------------------------------------------------
originally posted as:
[patch] PIE: Fix back re-run [Re: [patch] svr4_exec_displacement success indicator]
http://sourceware.org/ml/gdb-patches/2010-03/msg00868.html
Rediffed only (+some word change in the accompanying mail text below).
FYI on i686 Linux kernel (+x86_64 kernel for i686 programs)
"set disable-randomization on" acts the same as - apparently being applied -
- "set disable-randomization off" (the state before introducing that
"disable-randomization" GDB patch). This is a Linux kernel bug; tracked at:
https://bugzilla.redhat.com/show_bug.cgi?id=220892
------------------------------------------------------------------------------
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 part "Preserving now section_offsets if they are already set" has caused
the regression for PIE on native x86* GNU/Linux host.
As I believe for Daniel J.'s seen regression of `qOffsets' the checked-in part
"svr4_exec_displacement calling convention should have success indicator" is
sufficient - I would like to remove the "Preserving now section_offsets if they
are already set" part.
No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu for the whole
patch series together.
Thanks,
Jan
gdb/
2010-03-29 Jan Kratochvil <jan.kratochvil@redhat.com>
Fix re-run of PIE executable.
* solib-svr4.c (svr4_relocate_main_executable) <symfile_objfile>: Remove
the part of pre-set SYMFILE_OBJFILE->SECTION_OFFSETS.
gdb/testsuite/
2010-03-29 Jan Kratochvil <jan.kratochvil@redhat.com>
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
@@ -1985,17 +1985,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
@@ -330,6 +330,9 @@ proc test_ld {file ifmain trynosym displacement} {
# Print the "PIE (Position Independent Executable) displacement" message.
gdb_test_no_output "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"
@@ -340,7 +343,13 @@ proc test_ld {file ifmain trynosym 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