using gcc-3.4.6 and building a PIE binary with -z relro results in an ELF that, when stripped, causes the PT_GNU_RELRO to shrink the memsize more than the filesize ... perhaps this is a dupe of Bug 3281 ... $ gcc-3.4.6 dumpelf.c -o dumpelf -fPIE -Wl,-z,relro $ readelf -Wl dumpelf | grep GNU_REL GNU_RELRO 0x007d50 0x00607d50 0x00607d50 0x0002b0 0x0002b0 R 0x1 $ strip dumpelf $ readelf -Wl dumpelf | grep GNU_REL GNU_RELRO 0x007d50 0x00607d50 0x00607d50 0x000288 0x000280 R 0x1 the filesize (0x288) is larger than the memsize (0x280) looking at the relevant section headers: [17] .ctors PROGBITS 00607d50 007d50 000010 00 WA 0 0 8 [18] .dtors PROGBITS 00607d60 007d60 000010 00 WA 0 0 8 [19] .jcr PROGBITS 00607d70 007d70 000008 00 WA 0 0 8 [20] .data.rel.ro PROGBITS 00607d80 007d80 0000a0 00 WA 0 0 32 [21] .dynamic DYNAMIC 00607e20 007e20 000190 10 WA 5 0 8 [22] .got PROGBITS 00607fb0 007fb0 000028 08 WA 0 0 8 we see the filesize of the PT is correct (0x7d50 + 0x288 covers all these sections) but the memsize of the PT does not include the last few entries of the .got (0x7d50 + 0x280 is 0x8 bytes short of the end of the .got)
Created attachment 2004 [details] unstripped x86_64 dumpelf linked with vanilla binutils-2.18
Does it with the current Linux binutils?
thought i had tested 2.18.50.0.1 already, but i guess not ... strip in 2.18.50.0.1 does not mess up the PT, but strip in 2.18 does i'll give the branch a spin as well
current 2.18 branch as well as CVS head exhibit same bug as the 2.18 release
(In reply to comment #4) > current 2.18 branch as well as CVS head exhibit same bug as the 2.18 release In Linux binutils source tree, there is a patch for bug 3281 under "patches" You can try it on binutils from CVS and binutils 2.18.
after applying binutils-tls-relro-14.patch to HEAD, strip did not break PT_GNU_RELRO header (memsize == filesize)
(In reply to comment #6) > after applying binutils-tls-relro-14.patch to HEAD, strip did not break > PT_GNU_RELRO header (memsize == filesize) But it still increases memsize/filesize by 8. I will look into it.
A patch is posted at http://sourceware.org/ml/binutils/2007-09/msg00208.html
Fixed by http://sourceware.org/ml/binutils/2007-09/msg00229.html
Fixed.