Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -468,7 +468,7 @@ /*CanOmitFromDynSym*/ false, this) ->body(); - return elf::Symtab::X->addRegular(Name, *Sym, Sec)->body(); + return elf::Symtab::X->addRegular(Name, *Sym, Sec, this)->body(); } } @@ -796,11 +796,13 @@ Sections.push_back(Section); elf::Symtab::X->addRegular(StartName, STV_DEFAULT, STT_OBJECT, 0, 0, - STB_GLOBAL, Section); + STB_GLOBAL, Section, nullptr); elf::Symtab::X->addRegular(EndName, STV_DEFAULT, STT_OBJECT, - Data.size(), 0, STB_GLOBAL, Section); + Data.size(), 0, STB_GLOBAL, Section, + nullptr); elf::Symtab::X->addRegular(SizeName, STV_DEFAULT, STT_OBJECT, - Data.size(), 0, STB_GLOBAL, nullptr); + Data.size(), 0, STB_GLOBAL, nullptr, + nullptr); } static bool isBitcode(MemoryBufferRef MB) { Index: ELF/LinkerScript.cpp =================================================================== --- ELF/LinkerScript.cpp +++ ELF/LinkerScript.cpp @@ -65,7 +65,7 @@ template static void addRegular(SymbolAssignment *Cmd) { uint8_t Visibility = Cmd->Hidden ? STV_HIDDEN : STV_DEFAULT; Symbol *Sym = Symtab::X->addRegular(Cmd->Name, Visibility, STT_NOTYPE, - 0, 0, STB_GLOBAL, nullptr); + 0, 0, STB_GLOBAL, nullptr, nullptr); Cmd->Sym = Sym->body(); // If we have no SECTIONS then we don't have '.' and don't call Index: ELF/Relocations.cpp =================================================================== --- ELF/Relocations.cpp +++ ELF/Relocations.cpp @@ -342,7 +342,7 @@ if (AbsVal && RelE) { if (Body.isUndefined() && !Body.isLocal() && Body.symbol()->isWeak()) return true; - error("relocation " + getRelName(Type) + + error(getFilename(Body.File) + "relocation " + getRelName(Type) + " cannot refer to absolute symbol " + Body.getName()); return true; } Index: ELF/SymbolTable.h =================================================================== --- ELF/SymbolTable.h +++ ELF/SymbolTable.h @@ -60,9 +60,9 @@ Symbol *addRegular(StringRef Name, uint8_t StOther, uint8_t Type, uintX_t Value, uintX_t Size, uint8_t Binding, - InputSectionBase *Section); + InputSectionBase *Section, InputFile *File); Symbol *addRegular(StringRef Name, const Elf_Sym &Sym, - InputSectionBase *Section); + InputSectionBase *Section, InputFile *File); Symbol *addSynthetic(StringRef N, OutputSectionBase *Section, uintX_t Value, uint8_t StOther); Index: ELF/SymbolTable.cpp =================================================================== --- ELF/SymbolTable.cpp +++ ELF/SymbolTable.cpp @@ -128,8 +128,8 @@ template DefinedRegular *SymbolTable::addAbsolute(StringRef Name, uint8_t Visibility) { - Symbol *Sym = - addRegular(Name, Visibility, STT_NOTYPE, 0, 0, STB_GLOBAL, nullptr); + Symbol *Sym = addRegular(Name, Visibility, STT_NOTYPE, 0, 0, STB_GLOBAL, + nullptr, nullptr); return cast>(Sym->body()); } @@ -398,21 +398,22 @@ template Symbol *SymbolTable::addRegular(StringRef Name, const Elf_Sym &Sym, - InputSectionBase *Section) { + InputSectionBase *Section, + InputFile *File) { return addRegular(Name, Sym.st_other, Sym.getType(), Sym.st_value, - Sym.st_size, Sym.getBinding(), Section); + Sym.st_size, Sym.getBinding(), Section, File); } template Symbol *SymbolTable::addRegular(StringRef Name, uint8_t StOther, uint8_t Type, uintX_t Value, uintX_t Size, uint8_t Binding, - InputSectionBase *Section) { + InputSectionBase *Section, + InputFile *File) { Symbol *S; bool WasInserted; std::tie(S, WasInserted) = insert(Name, Type, StOther & 3, - /*CanOmitFromDynSym*/ false, - Section ? Section->getFile() : nullptr); + /*CanOmitFromDynSym*/ false, File); int Cmp = compareDefinedNonCommon(S, WasInserted, Binding); if (Cmp > 0) replaceBody>(S, Name, StOther, Type, Value, Size,