Bug 150591

Summary: gdb fails completely for gcc4 compiled -pie executable shared objects
Product: [Fedora] Fedora Reporter: Jason Vas Dias <jvdias>
Component: gdbAssignee: Elena Zannoni <ezannoni>
Status: CLOSED RAWHIDE QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: rawhideCC: cagney, jjohnstn, jorton, notting, wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-08-23 15:44:53 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 133944    
Bug Blocks: 130423, 150222, 158504    

Description Jason Vas Dias 2005-03-08 20:06:41 UTC
Description of problem:

gdb completely fails to debug executable shared objects
compiled with gcc4 .

Version-Release number of selected component (if applicable):

$ rpm -q gdb gcc glibc binutils --queryformat
'%{NAME}-%{VERSION}-%{RELEASE}-%{ARCH}\n'
gdb-6.3.0.0-0.29-i386
gcc-4.0.0-0.31-i386
glibc-2.3.4-14-i686
binutils-2.15.94.0.2-4-i386

How reproducible:

100%


Steps to Reproduce:

$ echo 'int main(int argc, char **argv, char **envp){ return (0); }' > t.c
$ gcc -fPIE -o t.o -c t.c
$ gcc -pie -o t t.o
$ gdb t
GNU gdb Red Hat Linux (6.3.0.0-0.29rh)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and
you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for
details.
This GDB was configured as "i386-redhat-linux-gnu"...(no debugging
symbols found)
Using host libthread_db library "/lib/tls/libthread_db.so.1".

(gdb) break main
Breakpoint 1 at 0x5ba
(gdb) run
Starting program: /tmp/t
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x5ba: Input/output error.

(gdb)
 
Actual results:

Cannot set breakpoint at function address 

Expected results:

'break main' must correctly set a breakpoint at the main()
entrypoint when the program is run, regardless of whether
it is -fPIE/-pie or not.


Additional info:

Comment 1 Jason Vas Dias 2005-03-08 20:09:14 UTC
Exactly the same result occurs if object is compiled with
  $ gcc -fPIE -g -o t.o -c t.c

Comment 2 Warren Togami 2005-05-28 08:18:22 UTC
Any status update?  This bug is on the FC4Blocker list but this is probably too
late now.

Comment 3 Jason Vas Dias 2005-06-10 23:17:53 UTC
At least there seems to have been some progress on this issue.

With gcc-4.0.0-9 and gdb-6.3.0.0-1.24rh, having ANY -fpie / -fPIE compiled 
object in an executable resulted in bogus break addresses for any entry point,
even if the executable was not linked -pie, and you were trying to break into
a non -fpie compiled object.

When I upgraded to gcc-4.0.0-11, I can now break into a non -pie linked
executable which contains -fpie compiled objects, and even break into -fpie
compiled objects which are compiled with -g3 -gdwarf-2 .

Still, gdb gets bogus break addresses for any -pie linked executable into
either -fpie or non -fpie compiled objects.



Comment 4 Jason Vas Dias 2005-08-23 15:44:53 UTC
Hooray! 
This bug now seems to be fixed with :
  - gcc-4.0.1-9
  - binutils-2.16.91.0.2-4
  - glibc-2.3.90-9
  - gdb-6.3.0.0-1.61
  - kernel-2.6.12-1.1504_FC5
The 't.c' compile test above now works, and gdb is now able to break into any
-fPIE / no -fPIE compiled object in a -pie linked executable.
As to which of the above components actually fixed this bug, I don't know, but
it is now fixed in Rawhide.