ld should support -z discard-unused=sections
It would appear that Solaris
ld has grown a new option:
-z discard-unused=sections. This behaviour is used by LLVM, which somewhat coarsely assumes it is available on all descendants of Solaris.
A section is considered unused for the purpose of this option, according to the Linker & Libraries Guide, if all of following conditions are met:
- The section provides no global symbols.
- The section contributes to an allocatable segment.
- The section is not referenced by any other used section, from any object, that contributes to the link-edit.
The existing option
-z ignore performs this elision of unused ELF sections, but it also drops dynamic dependencies that are not referenced as part of the link-edit.
Updated by Richard PALO almost 5 years ago
To be most useful, we need both 'sections' and 'unused-dependencies', in particular for current sufferance in pkgsrc, and if those two are done it is almost ridiculous not to do files although I do agree that it can be manually determined with -z guidance.