why -pie?

tridge at samba.org tridge at samba.org
Wed Dec 20 22:54:28 GMT 2006


Metze,

I've been bitten by the -pie compile flag in Samba3. I noticed you
added it in r19093, can you explain why its needed?

It breaks gdb on smbd on 2 different syystems I've tried it on. It
means you get garbage in a backtrace on a crash, and you can't set
breakpoints in gdb. Perhaps there are some versions of gdb where it
works, but I've tested both 6.5 and 6.4.90 on x86 boxes and both don't
work with binaries linked with -pie.

If it is needed for some reason I can't think of, then I at least
think we should make it off by default. Not being able to get
backtraces is pretty bad.

For a simple test, try this:

  gdb bin/smbd
  b main
  start

It fails with:

 Cannot insert breakpoint 1.
 Error accessing memory address 0xb87: Input/output error.

It seems that the reason is that gdb doesn't know that the binary
might be loaded at an address other than the one in the elf
header. While a later version of gdb might work, we don't want to lose
backtraces from anyone who hasn't downloaded and built gdb for
themselves.

Cheers, Tridge


More information about the samba-technical mailing list