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

Igor Kudrin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 08:40:47 PDT 2020


ikudrin created this revision.
ikudrin added reviewers: grimar, ruiu, MaskRay.
ikudrin added projects: lld, LLVM.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

When discarding local symbols with `-discard-all` or `-discard-locals`, the ones which are used in relocations should be preserved. LLD used the simplest approach and just ignored those switches when `-emit-relocs` or `-r` are specified. The patch implements handling the switches for the cases when relocations are kept by identifying used local symbols and allowing removing only unused ones. This makes the behavior of LLD compatible with GNU linkers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77807

Files:
  lld/ELF/Driver.cpp
  lld/ELF/Writer.cpp
  lld/test/ELF/dont-discard-used-locals.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77807.256312.patch
Type: text/x-patch
Size: 4578 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/8edd9da1/attachment.bin>


More information about the llvm-commits mailing list