idea for ld feature: eliding unreferenced input sections

Roland McGrath roland@frob.com
Wed Jul 7 15:52:00 GMT 1999


How hard do people think it would be to add an ld feature as follows?

I have in mind a new option, perhaps `--remove-unneeded-sections', that
would tell ld to discard from the output any input sections to which no
relocs in other sections refer.  It could be positional and apply to some
input files and not others, or it could just take the input section
containing the entry point as the root of the section dependency graph. 

I am thinking of using this in combination with something like gcc's
`-ffunction-sections' to achieve the effect of splitting up object files
and omitting the unreferenced ones from the link.

You can think of it as a moral equivalent to `--no-whole-archive' (the
default state of the switch being inverted, of course), considering each
object file to be an "archive of sections".  (The important difference is
that you still have a local symbol scope in each "archive" object file.)


Comments?


Thanks,
Roland


More information about the Binutils mailing list