This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
How can ld linker script keep some objs' section?
- From: xunxun <xunxun1982 at gmail dot com>
- To: binutils <binutils at sourceware dot org>
- Date: Tue, 01 Nov 2011 16:44:30 +0800
- Subject: How can ld linker script keep some objs' section?
Hi, all
I want to use ld's --gc-sections option on MinGW.
Depend on the bug: http://sourceware.org/bugzilla/show_bug.cgi?id=11539
We can use static build with --gc-sections successfully, but failed
use it when building and using DLL build.
I compared the linker map between before and after using
--gc-sections, and found that --gc-sections will remove the obj's section:
.eh_frame 0x6da05000 0xcc
e:/mysoft/programmingtools/compiler/mingw/bin/../lib/gcc/i686-w64-mingw32/4.6.2/../../../../i686-w64-mingw32/lib/../lib/dllcrt2.o
So I try to keep all .eh_frame sections in pe.sc linker script,
you can modify *(.eh_frame*) to KEEP (*(.eh_frame))
then the built dll can be used successfully, but because of all
.eh_frame sections being kept, the dll size reduced by --gc-sections
becomes more smaller, and it will influence static build's size to be
larger.
In the end, I want to know now, are there some methods to only
keep dllcrt2.o's or some objs' .eh_frame section?
Or some methods to only keep all .eh_frame sections when
building DLL, but not static build?
Many thanks.
--
Best Regards,
xunxun