Strange strip/bfd behavior on x86_64 when --emit-relocs was used.
Ignacy Gawedzki
i@lri.fr
Wed Mar 30 16:32:00 GMT 2011
Hi,
I have a strange issue with strip on x86_64.
It happens in the following quite simple case:
echo 'void f(void) {}' > foo.c
cc -c foo.c
cc -shared -nostartfiles -o foo.so -Wl,--emit-relocs foo.o
Now foo.so has a .rela.eh_frame section, as per readelf -S. If I understand
correctly, libbfd's bfd_map_over_sections doesn't call the callback on .rel*
sections, since it's doing something clever with it. Nevertheless, if I strip
foo.so once, the .rela.eh_frame section is still there according to readelf
-S. Now libbfd's bfd_map_over_sections strangely calls the callback on it.
If I strip foo.so again, then .rela.eh_frame is still there, but strangely at
the same offset as the .comment section. If I try to strip foo.so once more,
I get the following errors:
BFD: st3ppeRZ: section `.dynamic' can't be allocated in segment 1
LOAD: .dynamic
BFD: st3ppeRZ: The first section in the PT_DYNAMIC segment is not the .dynamic
section
strip:st3ppeRZ[.note.gnu.build-id]: Bad value
BFD: st3ppeRZ: section `.dynamic' can't be allocated in segment 1
LOAD: .dynamic
BFD: st3ppeRZ: The first section in the PT_DYNAMIC segment is not the .dynamic
section
strip:st3ppeRZ: Bad value
So there's obviously something wrong. I suppose strip should be idempotent.
This happens with:
GNU strip (GNU Binutils for Ubuntu) 2.20.51-system.20100908
Whereas with
GNU strip (GNU Binutils for Debian) 2.21.0.20110302
I have a slightly different behavior. After the third strip, I get
BFD: st8Of0vN: section `.dynamic' can't be allocated in segment 1
LOAD: .dynamic
but a binary output is produced. After a fourth strip, I get
BFD: stk8iNOY: warning: allocated section `.dynamic' not in segment
I tried to ask strip to explicitly remove that .rela.eh_frame section from the
freshly produced foo.so, but it skips it (as per ltrace). It works only when
I ask strip a second time. :/
Is it a known issue or maybe am I doing something wrong?
Thanks for your help.
Ignacy
--
"The whole problem with the world is that fools and fanatics are
always so certain of themselves, and wiser people so full of doubts."
- Bertrand Russell
More information about the Binutils
mailing list