[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
Thu Apr 9 23:22:00 PDT 2020


MaskRay added a comment.

I still need some time to understand GNU linkers' behavior. Here are some inlined comments.



================
Comment at: lld/test/ELF/dont-discard-used-locals.s:1
+## This test checks that --discard-all and --discard-locals remove unreferenced
+## local symbols when used with -r or --emit-relocs, while preserving ones which
----------------
Rename this to `discard-locals-*` to improve discoverability.



================
Comment at: lld/test/ELF/dont-discard-used-locals.s:8
+
+# RUN: ld.lld -discard-none -shared -emit-relocs %t -o - | \
+# RUN:  llvm-nm --just-symbol-name - | \ 
----------------
For the option name, prefer the double-dash form unless the single dash form is prevailing (e.g. -pie -shared )


================
Comment at: lld/test/ELF/dont-discard-used-locals.s:13
+# RUN: ld.lld -discard-locals -shared -emit-relocs %t -o - | \
+# RUN:  llvm-nm --just-symbol-name - | \ 
+# RUN:  FileCheck %s --check-prefix=DISCARD_LOCALS
----------------
No need to use `--just-symbol-name`. FileCheck allows you to omit the leading `t` `T`


================
Comment at: lld/test/ELF/dont-discard-used-locals.s:33
+# DISCARD_NONE: .LUnused
+# DISCARD_NONE: .LUsed
+# DISCARD_NONE: Unused
----------------
Add `-NEXT:` if applicable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77807





More information about the llvm-commits mailing list