How can ld linker script keep some objs' section?
Nick Clifton
nickc@redhat.com
Wed Nov 2 16:32:00 GMT 2011
Hi xunxun,
> In the end, I want to know now, are there some methods to only keep
> dllcrt2.o's or some objs' .eh_frame section?
Using linker garbage collection to discard unneeded .eh_frame sections
but keep the needed ones - no. But if you know before hand which object
files contain .eh_frame sections that you need to keep then - yes. You
just need to use a modified version of the KEEP directives, specifing
which object files to preserve. Eg:
KEEP (dllcrt2.o(.eh_frame))
KEEP (foo.o(.eh_frame))
This will ensure that the .eh_frame sections in dllcrt2.o and foo.o are
always retained.
> Or some methods to only keep all .eh_frame sections when building DLL,
> but not static build?
Use different linker scripts when building DLLs and static executables.
In one use the KEEP directive(s) and in the other omit them.
Cheers
Nick
More information about the Binutils
mailing list