Bug 9174 - gdb can't handle PIE
Summary: gdb can't handle PIE
Status: RESOLVED FIXED
Alias: None
Product: gdb
Classification: Unclassified
Component: symtab (show other bugs)
Version: 4.50
: P3 normal
Target Milestone: 7.1
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 9276 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-01-13 14:58 UTC by Andreas Schwab
Modified: 2010-01-18 22:10 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 Andreas Schwab 2006-01-13 14:58:02 UTC
[Converted from Gnats 2069]

$ gdb ntpdc
GNU gdb 6.4.50.20060113-cvs
Copyright (C) 2006 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 "ia64-suse-linux"...Using host libthread_db library "/lib/libthread_db.so.1".

(gdb) r
Starting program: /usr/sbin/ntpdc 
ntpdc> 
Program exited normally.
(gdb) b main
Breakpoint 1 at 0xd711: file ntpdc.c, line 264.
(gdb) r
Starting program: /usr/sbin/ntpdc 
ntpdc> 
Program exited normally.
(gdb)

Release:
6.4.50.20060113-cvs
Comment 1 Alex Bennee 2007-10-01 10:22:45 UTC
From: Alex Bennee <kernel-hacker@bennee.com>
To: gdb-gnats@sources.redhat.com
Cc:  
Subject: Re: symtab/2069: gdb can't handle PIE
Date: Mon, 01 Oct 2007 11:22:45 +0100

 This also occurs if you build your executable with the following:
 
 CFLAGS =  -fpic -shared 
 LDFLAGS =  -Wl,-e,_start
 
 $ gdb ourprog
 This GDB was configured as "x86_64-linux-gnu"...
 Using host libthread_db library "/lib/libthread_db.so.1".
 (gdb) start
 Breakpoint 1 at 0x32e753: file ourprog/main.cc, line 67.
 Starting program: ourprog
 Warning:
 Cannot insert breakpoint 1.
 Error accessing memory address 0x32e753: Input/output error.
 
 This is to be expected of course as our executable live way up high:
 
 $ cat /proc/123456/map
 <snip>
 2b8268e6a000-2b8268fb1000 r-xp 00000000 08:01
 1733565                    /lib/libc-2.5.so
 2b8268fb1000-2b82691b1000 ---p 00147000 08:01
 1733565                    /lib/libc-2.5.so
 2b82691b1000-2b82691b4000 r-xp 00147000 08:01
 1733565                    /lib/libc-2.5.so
 2b82691b4000-2b82691b6000 rwxp 0014a000 08:01
 1733565                    /lib/libc-2.5.so
 2b82691b6000-2b82691bd000 rwxp 2b82691b6000 00:00 0 
 2b82691bd000-2b82691be000 ---p 2b82691bd000 00:00 0 
 2b82691be000-2b82692fe000 rwxp 2b82691be000 00:00 0 
 2b82692fe000-2b82692ff000 r-xp 00000000 00:12
 29833155                   /tmp/dynaEcmyWf (deleted)
 2b82692ff000-2b82695c3000 rwxp 2b82692ff000 00:00 0 
 555555554000-555555a32000 r-xp 00000000 08:04 12649433
 ourprog
 555555b32000-555555b79000 rwxp 004de000 08:04 12649433
 ourprog
 555555b79000-555555c77000 rwxp 555555b79000 00:00 0
 [heap]
 7fff42c04000-7fff42c1a000 rwxp 7fff42c04000 00:00 0
 [stack]
 ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
 [vdso]
 
 Running the binary with "r" works fine although you can't set any
 breakpoints in the code.
 I suspect this is because the symbols in our shared object are relative.
 It looks like the add-symbol-file should be able to handle this but I'm
 not seeing it work.
 
 (gdb) add-symbol-file ourprog 0x555555554000
 add symbol table from file "ourprog" at
         .text_addr = 0x555555554000
 (y or n) y
 Reading symbols from ourprog...done
 (gdb) x/5i main
 0x32e740 <main>:        push   %rbp
 0x32e741 <main+1>:      mov    %rsp,%rbp
Comment 2 Pedro Alves 2009-01-16 22:42:56 UTC
*** Bug 9723 has been marked as a duplicate of this bug. ***
Comment 3 Thiago Jung Bauermann 2009-03-08 05:46:50 UTC
*** Bug 9276 has been marked as a duplicate of this bug. ***
Comment 4 Thiago Jung Bauermann 2009-03-08 06:18:04 UTC
Sorry about that, removing address (apparently madcoder@gmail.com is not the
person who filed bug #9276, weird).
Comment 5 Tom Tromey 2010-01-18 22:10:22 UTC
I believe all the PIE patches have gone in.