Project

General

Profile

Feature #6509

ld should support -z discard-unused=sections

Added by Joshua M. Clulow almost 5 years ago. Updated almost 5 years ago.

Status:
New
Priority:
Normal
Category:
cmd - userland programs
Start date:
2015-12-13
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

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.


Related issues

Related to illumos gate - Feature #4435: feature request: add ld -z discard-unused=New2013-12-27

Actions

History

#1

Updated by Joshua M. Clulow almost 5 years ago

  • Description updated (diff)
#2

Updated by Richard PALO almost 5 years ago

#3

Updated by Joshua M. Clulow almost 5 years ago

It's more of a subset: I don't intend to implement all of the modes of -z discard-unused=* at this time.

#4

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.

#5

Updated by Joshua M. Clulow about 1 month ago

  • Related to Feature #4435: feature request: add ld -z discard-unused= added

Also available in: Atom PDF