summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/InputFiles.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 566da9cb843..cd29311ccdc 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -226,7 +226,10 @@ void elf::ObjectFile<ELFT>::initializeSections(
if (Sections[I] == &InputSection<ELFT>::Discarded)
continue;
- if (!Config->Relocatable && (Sec.sh_flags & SHF_EXCLUDE)) {
+ // SHF_EXCLUDE'ed sections are discarded by the linker. However,
+ // if -r is given, we'll let the final link discard such sections.
+ // This is compatible with GNU.
+ if ((Sec.sh_flags & SHF_EXCLUDE) && !Config->Relocatable) {
Sections[I] = &InputSection<ELFT>::Discarded;
continue;
}
OpenPOWER on IntegriCloud