Check Live instead of the section type.
By the time we get here all live sections should have been combined
into InputSections.
llvm-svn: 304243
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 2628977..5ebb9f3 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -291,12 +291,14 @@
size_t SizeBefore = Ret.size();
for (InputSectionBase *Sec : InputSections) {
- if (!isa<InputSection>(Sec))
- continue;
-
if (Sec->Assigned)
continue;
+ if (!Sec->Live) {
+ reportDiscarded(Sec);
+ continue;
+ }
+
// For -emit-relocs we have to ignore entries like
// .rela.dyn : { *(.rela.data) }
// which are common because they are in the default bfd script.
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index f117690..9f70155 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -351,7 +351,7 @@
Type == SHT_NOTE;
}
-static void reportDiscarded(InputSectionBase *IS) {
+void elf::reportDiscarded(InputSectionBase *IS) {
if (!Config->PrintGcSections)
return;
message("removing unused section from '" + IS->Name + "' in file '" +
diff --git a/lld/ELF/OutputSections.h b/lld/ELF/OutputSections.h
index 08655a9..9e4bf6e 100644
--- a/lld/ELF/OutputSections.h
+++ b/lld/ELF/OutputSections.h
@@ -149,6 +149,7 @@
};
uint64_t getHeaderSize();
+void reportDiscarded(InputSectionBase *IS);
} // namespace elf
} // namespace lld