dead function elimination

jimmy jimmyb@huawei.com
Mon Dec 18 08:25:00 GMT 2006


Nick Clifton wrote:
> Hi Jimmy,
> 
>> I thght the linker alone was supposed to be able to do 
>> dead-procedure-elimination.
> 
> No.  It is a nice feature, but it is not a requirement of a linker.
> 
>> After all can't the linker determine which procedures are unreferenced 
>> in the final executable?
> 
> Which is exactly what the --ffunction-sections and --gc-sections 
> switches do.
> 
>> If i'm not mistaken the diablo linker can do this?
> 
> It probably can.
> 
> Cheers
>   Nick
> 

If i understand things correctly, there is a restriction on 
'--gc-sections' that it doesn't work if the link is dynamic. What if my 
scenario is like this:

	libsomething.a - some static library built with -ffunction-sections & 
-fdata-sections

	src.o - my source code also built with -ffucntion-sections

final step:

	ld -o exec --gc-sections src.o -lsomething

In the above step, ld simply says

'/usr/bin/ld: Warning: gc-sections option ignored'

My aim here was to remove unreferenced functions from both my code & the 
static library, but at the same time using libc as an '.so' (obviously 
that makes sense, cos it's shared across many apps & probably not built 
with -ffunction-sections to use a static link).

Is there any way to achieve this?


-jb
-- 
mathematician, n.:
         Some one who believes imaginary things appear right before your 
i's.




More information about the Binutils mailing list