Hi, Yeah I can imagine why it would be hard to do --gc-sections for dynamically linked executables . You would have to worry about the semantics of weak symbol definitions , weak function definitions to worry about. Other than that I can't think of any other issues off the cuff. It looks as though no one has done it yet and possibly would be a nifty feature to have, though using google I could only find this thread as a reference : http://sources.redhat.com/ml/binutils/2001-11/msg00339.html and more specifically this reply : http://sources.redhat.com/ml/binutils/2001-11/msg00350.html In any case maybe future discussions about this should possibly move to binutils@xxxxxxxxxxxxxxxxxx and maybe no longer here. cheers Ramana --- Ramana Radhakrishnan GNU Tools Support codito ergo sum (www.codito.com) > Following up the thread titled "RE: ld warning (was Optimization, remove > unused code from Image)": > >> Will retry on a Linux machine where everything is GNU, and see if I have >> better results there. > > #Compilation : gcc version 3.3.1 (SuSE Linux) > $> gcc -c -ffunction-sections *.c > > #Linking : GNU ld version 2.14.90.0.5 20030722 (SuSE Linux) > $> gcc -Wl,--gc-sections *.o > > $> file a.out > a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for > GNU/Linux 2.2.5, dynamically linked (uses shared libs), not stripped > > a.out works fine, but contains the uncalled function func3() in the code > section. > > If I link it statically, however: > $> gcc -Wl,--gc-sections,-static *.o > > $> file a.out > a.out: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), > statically linked, not stripped > > > And a.out doesn't contain func3(). AND, it doesn't contain func2() either. > > So, unused code has been removed - but only (as man ld stipulates) if you > link statically. > > Cheers, > Srikanth Madani > Düsseldorf, NRW > > > > > ________________________________________________________________ > The source files are: > > $> cat hello.c > int main(void) { > printf("\nHello world!\n"); > func1(); > exit(0); > } > $> > > > $> cat fun1.c > void func1(void) { > printf("\nIn function func1()\n"); > } > void func2(void) { > func3(); > } > $> > > > $> cat fun2.c > void func3(void) { > printf("\nIn function func3()\n"); > } > $> > ---- Ramana Radhakrishnan Codito Technologies