From f7149554029129edb893f7271f4f584a11ef1d9a Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 11 Mar 2016 18:46:51 +0000 Subject: [PATCH] Revert r263252: "[ELF] - Change all messages to lowercase to be consistent." This reverts commit r263252 because the change contained unrelated changes. llvm-svn: 263272 --- lld/ELF/Driver.cpp | 14 +-- lld/ELF/InputFiles.cpp | 112 ++++++++++--------- lld/ELF/InputFiles.h | 15 ++- lld/ELF/InputSection.cpp | 17 +-- lld/ELF/LinkerScript.cpp | 8 +- lld/ELF/OutputSections.cpp | 8 +- lld/ELF/SymbolTable.cpp | 42 ++++--- lld/ELF/Symbols.cpp | 6 +- lld/ELF/Target.cpp | 24 ++-- lld/test/ELF/basic.s | 2 +- lld/test/ELF/driver.test | 6 +- lld/test/ELF/invalid-cie-reference.s | 2 +- lld/test/ELF/invalid-elf.test | 13 +-- lld/test/ELF/invalid-relocations.test | 2 +- lld/test/ELF/libsearch.s | 4 +- lld/test/ELF/linkerscript-sections-padding.s | 4 +- lld/test/ELF/merge-string-error.s | 2 +- lld/test/ELF/merge-string-no-null.s | 2 +- lld/test/ELF/mips-gnu-hash.s | 2 +- lld/test/ELF/ppc64-addr16-error.s | 2 +- lld/test/ELF/relocation-in-merge.s | 2 +- lld/test/ELF/relocation-past-merge-end.s | 2 +- lld/test/ELF/splitstacks.s | 2 +- lld/test/ELF/sysroot.s | 2 +- lld/test/ELF/writable-merge.s | 2 +- 25 files changed, 156 insertions(+), 141 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 99a53291876f..2fd24e4b77ad 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -61,9 +61,9 @@ static std::pair parseEmulation(StringRef S) { if (S == "aarch64linux") return {ELF64LEKind, EM_AARCH64}; if (S == "i386pe" || S == "i386pep" || S == "thumb2pe") - error("windows targets are not supported on the ELF frontend: " + S); + error("Windows targets are not supported on the ELF frontend: " + S); else - error("unknown emulation: " + S); + error("Unknown emulation: " + S); return {ELFNoneKind, 0}; } @@ -112,7 +112,7 @@ void LinkerDriver::addFile(StringRef Path) { return; case file_magic::elf_shared_object: if (Config->Relocatable) { - error("attempted static link of dynamic object " + Path); + error("Attempted static link of dynamic object " + Path); return; } Files.push_back(createSharedFile(MBRef)); @@ -126,7 +126,7 @@ void LinkerDriver::addFile(StringRef Path) { void LinkerDriver::addLibrary(StringRef Name) { std::string Path = searchLibrary(Name); if (Path.empty()) - error("unable to find library -l" + Name); + error("Unable to find library -l" + Name); else addFile(Path); } @@ -137,7 +137,7 @@ static void checkOptions(opt::InputArgList &Args) { // The MIPS ABI as of 2016 does not support the GNU-style symbol lookup // table which is a relatively new feature. if (Config->EMachine == EM_MIPS && Config->GnuHash) - error("the .gnu.hash section is not compatible with the MIPS target."); + error("The .gnu.hash section is not compatible with the MIPS target."); if (Config->EMachine == EM_AMDGPU && !Config->Entry.empty()) error("-e option is not valid for AMDGPU."); @@ -262,7 +262,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { if (auto *Arg = Args.getLastArg(OPT_O)) { StringRef Val = Arg->getValue(); if (Val.getAsInteger(10, Config->Optimize)) - error("invalid optimization level"); + error("Invalid optimization level"); } if (auto *Arg = Args.getLastArg(OPT_hash_style)) { @@ -273,7 +273,7 @@ void LinkerDriver::readConfigs(opt::InputArgList &Args) { } else if (S == "both") { Config->GnuHash = true; } else if (S != "sysv") - error("unknown hash style: " + S); + error("Unknown hash style: " + S); } for (auto *Arg : Args.filtered(OPT_undefined)) diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 021b14c38dd8..fcc05c2a2c6c 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -53,7 +53,7 @@ ELFFileBase::getElfSymbols(bool OnlyGlobals) { uint32_t NumSymbols = std::distance(Syms.begin(), Syms.end()); uint32_t FirstNonLocal = Symtab->sh_info; if (FirstNonLocal > NumSymbols) - fatal("invalid sh_info in symbol table"); + fatal("Invalid sh_info in symbol table"); if (OnlyGlobals) return make_range(Syms.begin() + FirstNonLocal, Syms.end()); @@ -137,7 +137,7 @@ elf::ObjectFile::getShtGroupEntries(const Elf_Shdr &Sec) { ArrayRef Entries = check(Obj.template getSectionContentsAsArray(&Sec)); if (Entries.empty() || Entries[0] != GRP_COMDAT) - fatal("unsupported SHT_GROUP format"); + fatal("Unsupported SHT_GROUP format"); return Entries.slice(1); } @@ -148,7 +148,7 @@ static bool shouldMerge(const typename ELFFile::Elf_Shdr &Sec) { if (!(Flags & SHF_MERGE)) return false; if (Flags & SHF_WRITE) - fatal("writable SHF_MERGE sections are not supported"); + fatal("Writable SHF_MERGE sections are not supported"); uintX_t EntSize = Sec.sh_entsize; if (!EntSize || Sec.sh_size % EntSize) fatal("SHF_MERGE section size must be a multiple of sh_entsize"); @@ -187,7 +187,7 @@ void elf::ObjectFile::initializeSections( continue; for (uint32_t SecIndex : getShtGroupEntries(Sec)) { if (SecIndex >= Size) - fatal("invalid section index in group"); + fatal("Invalid section index in group"); Sections[SecIndex] = InputSection::Discarded; } break; @@ -204,7 +204,7 @@ void elf::ObjectFile::initializeSections( case SHT_REL: { uint32_t RelocatedSectionIndex = Sec.sh_info; if (RelocatedSectionIndex >= Size) - fatal("invalid relocated section index"); + fatal("Invalid relocated section index"); InputSectionBase *RelocatedSection = Sections[RelocatedSectionIndex]; // Strictly speaking, a relocation section must be included in the @@ -213,7 +213,7 @@ void elf::ObjectFile::initializeSections( if (RelocatedSection == InputSection::Discarded) continue; if (!RelocatedSection) - fatal("unsupported relocation reference"); + fatal("Unsupported relocation reference"); if (Config->Relocatable) { // For -r, relocation sections are handled as regular input sections. Sections[I] = new (Alloc) InputSection(this, &Sec); @@ -221,10 +221,10 @@ void elf::ObjectFile::initializeSections( S->RelocSections.push_back(&Sec); } else if (auto *S = dyn_cast>(RelocatedSection)) { if (S->RelocSection) - fatal("multiple relocation sections to .eh_frame are not supported"); + fatal("Multiple relocation sections to .eh_frame are not supported"); S->RelocSection = &Sec; } else { - fatal("relocations pointing to SHF_MERGE are not supported"); + fatal("Relocations pointing to SHF_MERGE are not supported"); } break; } @@ -247,7 +247,7 @@ elf::ObjectFile::createInputSection(const Elf_Shdr &Sec) { return InputSection::Discarded; if (Name == ".note.GNU-split-stack") - error("objects using splitstacks are not supported"); + error("Objects using splitstacks are not supported"); // A MIPS object file has a special section that contains register // usage info, which needs to be handled by the linker specially. @@ -281,7 +281,7 @@ elf::ObjectFile::getSection(const Elf_Sym &Sym) const { if (Index == 0) return nullptr; if (Index >= Sections.size() || !Sections[Index]) - fatal("invalid section index"); + fatal("Invalid section index"); InputSectionBase *S = Sections[Index]; if (S == InputSectionBase::Discarded) return S; @@ -397,7 +397,7 @@ template void SharedFile::parseSoName() { if (Dyn.d_tag == DT_SONAME) { uintX_t Val = Dyn.getVal(); if (Val >= this->StringTable.size()) - fatal("invalid DT_SONAME entry"); + fatal("Invalid DT_SONAME entry"); SoName = StringRef(this->StringTable.data() + Val); return; } @@ -433,7 +433,51 @@ static uint8_t getGvVisibility(const GlobalValue *GV) { case GlobalValue::ProtectedVisibility: return STV_PROTECTED; } - llvm_unreachable("unknown visibility"); + llvm_unreachable("Unknown visibility"); +} + +SymbolBody * +BitcodeFile::createSymbolBody(const DenseSet &KeptComdats, + const IRObjectFile &Obj, + const BasicSymbolRef &Sym) { + const GlobalValue *GV = Obj.getSymbolGV(Sym.getRawDataRefImpl()); + assert(GV); + if (const Comdat *C = GV->getComdat()) + if (!KeptComdats.count(C)) + return nullptr; + + uint8_t Visibility = getGvVisibility(GV); + + SmallString<64> Name; + raw_svector_ostream OS(Name); + Sym.printName(OS); + StringRef NameRef = Saver.save(StringRef(Name)); + + const Module &M = Obj.getModule(); + SymbolBody *Body; + uint32_t Flags = Sym.getFlags(); + bool IsWeak = Flags & BasicSymbolRef::SF_Weak; + if (Flags & BasicSymbolRef::SF_Undefined) { + Body = new (Alloc) Undefined(NameRef, IsWeak, Visibility, false); + } else if (Flags & BasicSymbolRef::SF_Common) { + const DataLayout &DL = M.getDataLayout(); + uint64_t Size = DL.getTypeAllocSize(GV->getValueType()); + Body = new (Alloc) + DefinedCommon(NameRef, Size, GV->getAlignment(), IsWeak, Visibility); + } else { + Body = new (Alloc) DefinedBitcode(NameRef, IsWeak, Visibility); + } + Body->IsTls = GV->isThreadLocal(); + return Body; +} + +bool BitcodeFile::shouldSkip(const BasicSymbolRef &Sym) { + uint32_t Flags = Sym.getFlags(); + if (!(Flags & BasicSymbolRef::SF_Global)) + return true; + if (Flags & BasicSymbolRef::SF_FormatSpecific) + return true; + return false; } void BitcodeFile::parse(DenseSet &ComdatGroups) { @@ -448,43 +492,9 @@ void BitcodeFile::parse(DenseSet &ComdatGroups) { KeptComdats.insert(&P.second); } - for (const BasicSymbolRef &Sym : Obj->symbols()) { - const GlobalValue *GV = Obj->getSymbolGV(Sym.getRawDataRefImpl()); - assert(GV); - uint32_t Flags = Sym.getFlags(); - if (const Comdat *C = GV->getComdat()) - if (!KeptComdats.count(C)) - continue; - if (!(Flags & BasicSymbolRef::SF_Global)) - continue; - if (GV->hasAppendingLinkage()) { - ExtraKeeps.push_back(GV->getName().copy(Alloc)); - continue; - } - if (Flags & BasicSymbolRef::SF_FormatSpecific) - continue; - uint8_t Visibility = getGvVisibility(GV); - - SmallString<64> Name; - raw_svector_ostream OS(Name); - Sym.printName(OS); - StringRef NameRef = Saver.save(StringRef(Name)); - - SymbolBody *Body; - bool IsWeak = Flags & BasicSymbolRef::SF_Weak; - if (Flags & BasicSymbolRef::SF_Undefined) { - Body = new (Alloc) Undefined(NameRef, IsWeak, Visibility, false); - } else if (Flags & BasicSymbolRef::SF_Common) { - const DataLayout &DL = M.getDataLayout(); - uint64_t Size = DL.getTypeAllocSize(GV->getValueType()); - Body = new (Alloc) - DefinedCommon(NameRef, Size, GV->getAlignment(), IsWeak, Visibility); - } else { - Body = new (Alloc) DefinedBitcode(NameRef, IsWeak, Visibility); - } - Body->IsTls = GV->isThreadLocal(); - SymbolBodies.push_back(Body); - } + for (const BasicSymbolRef &Sym : Obj->symbols()) + if (!shouldSkip(Sym)) + SymbolBodies.push_back(createSymbolBody(KeptComdats, *Obj, Sym)); } template @@ -506,7 +516,7 @@ template