This is the mail archive of the binutils@sources.redhat.com 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: Fw: Does ld removes uncalled functions from final exe ?


Hi Valery,

I wrote simple test program to discover wheter ld removes unreachable code.

The linker does not do this by default. To achieve the affect you want compile your code with the -ffunction-sections switch specified and then link with the -gc-sections switch. eg like this:


  gcc -ffunction-sections -c test.c testfx.c
  gcc -Wl,-gc-sections test.o testfx.o

Cheers
  Nick


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