[PATCH] D77807: [LLD][ELF] Implement --discard-* for cases when -r or --emit-relocs are used.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 10 10:53:58 PDT 2020


MaskRay added a comment.

In D77807#1974123 <https://reviews.llvm.org/D77807#1974123>, @grimar wrote:

> I'd suggest to wait to hear what other reviewers think about the latest changes and my suggestions in general before continuing.


Honestly I am wondering whether a linker change is justified.

> For -shared --discard-locals --emit-relocs, the patch strips .Lunused . However, .L temporary symbols are usually already discarded by the assembler.

`.L` in object files is uncommon so we probably should not worry much about the additional symbols lld retains but GNU linkers discard.

> For -shared --discard-all --emit-relocs, this patch appears to be a bug fix. Previously we discard all local symbols.

This discards local symbols as well. My question is why we have these unreferenced local symbols in object files and why we need to save .symtab space for them.

An assembler can convert a local symbol reference to a local symbol to a STT_SECTION relative relocation or resolve the fixup at assembly time. If the intention is to discard the unreferenced local symbols, a better way may be to not generate the local symbols in the object files. Alternatively, generate `.L` temporary labels which are a special kind of local symbols which usually don't survive in the object file.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77807/new/

https://reviews.llvm.org/D77807





More information about the llvm-commits mailing list