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


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"?
>
> For a real world case, see this Mozilla bug:
>  https://bugzilla.mozilla.org/show_bug.cgi?id=678977
>
> (Sorry if this is a dup post. But gmane seemed to drop my previous message)

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.

Ian


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