[ELF] Support -r --gc-sections
authorFangrui Song <i@maskray.me>
Thu, 23 Jul 2020 15:16:01 +0000 (08:16 -0700)
committerFangrui Song <maskray@google.com>
Thu, 23 Jul 2020 15:16:01 +0000 (08:16 -0700)
commit4e80c768c28fa919aa3d4fd662af8ea99feda4d6
treecc5ac39065ffb0ed9637386febbc203ae9f3b7fc
parent23d1800433d93b94a0c098e97f6f26889b22cb6a
[ELF] Support -r --gc-sections

-r --gc-sections is usually not useful because it just makes intermediate output
smaller. https://bugs.llvm.org/show_bug.cgi?id=46700#c7 mentions a use case:
validating the absence of undefined symbols ealier than in the final link.

After D84129 (SHT_GROUP support in -r links), we can support -r
--gc-sections without extra code. So let's allow it.

Reviewed By: grimar, jhenderson

Differential Revision: https://reviews.llvm.org/D84131
lld/ELF/Driver.cpp
lld/ELF/InputFiles.cpp
lld/test/ELF/driver.test
lld/test/ELF/relocatable-gc.s [new file with mode: 0644]