summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Relocations.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lld/ELF/Relocations.cpp')
-rw-r--r--lld/ELF/Relocations.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index 9eb10f940eb..d3cc608c1e2 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -679,9 +679,17 @@ static std::string maybeReportDiscarded(Undefined &Sym, InputSectionBase &Sec,
return "";
ArrayRef<Elf_Shdr_Impl<ELFT>> ObjSections =
CHECK(File->getObj().sections(), File);
- std::string Msg =
- "relocation refers to a symbol in a discarded section: " + toString(Sym) +
- "\n>>> defined in " + toString(File);
+
+ std::string Msg;
+ if (Sym.Type == ELF::STT_SECTION) {
+ Msg = "relocation refers to a discarded section: ";
+ Msg += CHECK(
+ File->getObj().getSectionName(&ObjSections[Sym.DiscardedSecIdx]), File);
+ } else {
+ Msg = "relocation refers to a symbol in a discarded section: " +
+ toString(Sym);
+ }
+ Msg += "\n>>> defined in " + toString(File);
Elf_Shdr_Impl<ELFT> ELFSec = ObjSections[Sym.DiscardedSecIdx - 1];
if (ELFSec.sh_type != SHT_GROUP)
OpenPOWER on IntegriCloud