This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Quick --gc-sections question


On Mon, Nov 7, 2011 at 9:13 PM, Ian Lance Taylor <iant@google.com> wrote:
> Octoploid <cryptooctoploid@gmail.com> writes:
>
>> Please consider:
>>
>> ?% cat check.c
>> __attribute__((visibility("default"))) void fun () {}
>> int main () { ?}
>>
>> ?% gcc -ffunction-sections -rdynamic
>> -Wl,--gc-sections,--print-gc-sections check.c 2>&1 | grep .text.fun
>> /usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/../../../../x86_64-pc-linux-gnu/bin/ld:
>> removing unused section from '.text.fun' in file '/tmp/cc22IotY.o'
>>
>> ?% gcc -rdynamic -Wl,--gc-sections,--print-gc-sections check.c 2>&1 |
>> grep .text.fun
>> ?%
>>
>> Is this the expected behavior? And if yes, how can one tell the
>> compiler and linker to always keep the fun() function with
>> "-ffunction-sections -rdynamic -Wl,--gc-sections"?
>>

> I'll note that this was recently fixed in gold. ?If --export-dynamic is
> passed to the linker, I think we should not garbage collect globally
> visible functions.

Thanks. I didn't notice the gold fix.

 % ld -v
GNU gold (GNU Binutils 2.22.51.20111107) 1.11
 % gcc -ffunction-sections -rdynamic
-Wl,--gc-sections,--print-gc-sections check.c 2>&1 | grep .text.fun
 % ld -v
GNU ld (GNU Binutils) 2.22.51.20111021
 % gcc -ffunction-sections -rdynamic
-Wl,--gc-sections,--print-gc-sections check.c 2>&1 | grep .text.fun
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.0/../../../../x86_64-pc-linux-gnu/bin/ld:
Removing unused section '.text.fun' in file '/tmp/cc7CLEIa.o'




-- 
controlled by gamma light


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]