How do I debug with gdb?
First gotcha is that GDB can’t resolve symbols in PIEs; it doesn’t realise that the addresses are relative in PIEs not absolute. This shows up when you try to get a backtrace for example, and see a stream of lines with ‘??’ where the symbol should be. To get around this, do the final link stage with -nopie – all the preceding object compilations can still be with -fPIE as normal (i.e. the default with the hardened compiler) so that your executable is as close as possible to the real thing, but the final link must create a regular executable. Try adding -nopie to LDFLAGS if you’re building with emerge. Another way of accomplishing this, it to emerge =sys-devel/gdb-6.3-r5, which contains a special patch that makes it able to debug executeables linked with -pie. The second gotcha is that PaX may prevent GDB from setting breakpoints, depending on how the kernel is configured. This includes the breakpoint at main which you need to get started. To stop PaX doing this, the executable being de