Summary: | GDB cannot generate backtraces | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Tommy McDaniel <tommstein> |
Component: | [OLD] Development | Assignee: | Gentoo Toolchain Maintainers <toolchain> |
Status: | RESOLVED INVALID | ||
Severity: | blocker | CC: | hardened |
Priority: | High | ||
Version: | unspecified | ||
Hardware: | AMD64 | ||
OS: | Linux | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- |
Description
Tommy McDaniel
2005-09-01 22:58:27 UTC
You need to link with '-nopie'; GDB does not support PIEs (Position Independent Executables). Linking with '-nopie' means that the executable loads at the normal fixed address, and all symbols have real addresses. In a PIE, the load address is randomised at load time, and in the PIE itself all symbol addresses are offsets; gdb currently isn't clever enough to work this out. If you use PaX, in general you also need to do 'paxctl -mx' on the executable as well. $ gcc -ggdb3 -c x.c $ gcc -ggdb3 -nopie -o x-nopie x.c $ /sbin/paxctl -mx x-nopie $ gdb ./x-nopie GNU gdb 6.3 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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) run Starting program: /home/kquinn/x/x-nopie Program received signal SIGSEGV, Segmentation fault. 0x08048499 in main () at x.c:5 5 *ptr = 10; (gdb) bt full #0 0x08048499 in main () at x.c:5 ptr = (int *) 0x12345678 (gdb) Ah yes, that works beautifully. I thank you, sir. Is this actually documented somewhere, or is one to discover this when one obtains useless backtraces? If one compiles a package with USE="debug" (and FEATURES="nostrip"), and still obtains these useless backtraces (like happened to me with KDevelop), is it a bug on a package-by-package basis, or are the useless backtraces the expected standard behavior when using a hardened Gentoo? "Discover when faced with useless backtraces" is the usual method so far :) It's been in the forums a few times, probably also in the mailing lists, on IRC channels etc. I suppose it ought to be in the hardened FAQ; I'll see what I can do. |