Bug 11776 - solib-svr4 with remote target assumes qOffsets packet is supported
Summary: solib-svr4 with remote target assumes qOffsets packet is supported
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: shlibs (show other bugs)
Version: 7.1
: P2 normal
Target Milestone: 7.1
Assignee: Jan Kratochvil
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-30 19:48 UTC by Michal Ostrowski
Modified: 2010-07-05 18:07 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michal Ostrowski 2010-06-30 19:48:10 UTC
svr4_relocate_main_executable() bails out without doing anything if it detects
prior existing relocation offsets have been applied.  A comment there states
that this is done so that preference is given to relocation offsets specified by
qOffsets packet processing, which occurs earlier.

Now suppose I start gdb and do:

1. Issue "target remote /dev/ttyS0"
2. GDB attaches, reads auxv and relocates via svr4_relocate_main_executable()
3. Issue "detach"
4. Issue "target remote /dev/ttyS1"
5. GDB attaches, reads auxv (relocation is different than above)
6. GDB bails out of svr4_relocate_main_executable() without relocating.
7. GDB uses the relocation data from the original connection, not the current one.

Note that if the remote stub supports "qOffsets" (not required), then the
processing of that response relocates the executable using that mechanism.
Comment 1 Jan Kratochvil 2010-06-30 20:36:56 UTC
I believe this problem should be fixed by:
ping: [patch 6/6] PIE: Fix back re-run
http://sourceware.org/ml/gdb-patches/2010-06/msg00236.html
[ You should apply all 6 patches of the series. ]

It should get finally checked-in these days after 3 months of reviewing process.
Comment 2 Michael Snyder 2010-06-30 21:46:47 UTC
Jan -- will this change be in time for the 7.2 release?
Comment 3 Jan Kratochvil 2010-07-01 04:21:14 UTC
Yes, it is listed as a 7.2 blocker:
http://sourceware.org/gdb/wiki/GDB_7.2_Release
Comment 4 Sourceware Commits 2010-07-05 18:04:45 UTC
Subject: Bug 11776

CVSROOT:	/cvs/src
Module name:	src
Changes by:	jkratoch@sourceware.org	2010-07-05 18:04:33

Modified files:
	gdb            : ChangeLog solib-svr4.c 
	gdb/testsuite  : ChangeLog 
	gdb/testsuite/gdb.base: break-interp.exp 

Log message:
	gdb/
	Fix re-run of PIE executable, PR shlibs/11776.
	* solib-svr4.c (svr4_relocate_main_executable) <symfile_objfile>: Remove
	the part of pre-set SYMFILE_OBJFILE->SECTION_OFFSETS.
	
	gdb/testsuite/
	Fix re-run of PIE executable, PR shlibs/11776.
	* 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.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/ChangeLog.diff?cvsroot=src&r1=1.11966&r2=1.11967
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/solib-svr4.c.diff?cvsroot=src&r1=1.136&r2=1.137
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/ChangeLog.diff?cvsroot=src&r1=1.2375&r2=1.2376
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gdb/testsuite/gdb.base/break-interp.exp.diff?cvsroot=src&r1=1.17&r2=1.18

Comment 5 Jan Kratochvil 2010-07-05 18:07:18 UTC
The bug should be fixed now.