Quick --gc-sections question

Octoploid cryptooctoploid@gmail.com
Mon Nov 7 19:25:00 GMT 2011


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)
-- 
controlled by gamma light



More information about the Binutils mailing list