diff options
-rw-r--r-- | lld/ELF/DWARF.cpp | 6 | ||||
-rw-r--r-- | lld/ELF/InputFiles.cpp | 10 | ||||
-rw-r--r-- | lld/ELF/Relocations.cpp | 8 | ||||
-rw-r--r-- | lld/ELF/ScriptParser.cpp | 32 | ||||
-rw-r--r-- | lld/ELF/Symbols.cpp | 12 |
5 files changed, 33 insertions, 35 deletions
diff --git a/lld/ELF/DWARF.cpp b/lld/ELF/DWARF.cpp index 3c2c7f70f2c..58ac056b7e2 100644 --- a/lld/ELF/DWARF.cpp +++ b/lld/ELF/DWARF.cpp @@ -58,7 +58,7 @@ namespace { template <class RelTy> struct LLDRelocationResolver { // In the ELF ABIs, S sepresents the value of the symbol in the relocation // entry. For Rela, the addend is stored as part of the relocation entry. - static uint64_t Resolve(object::RelocationRef Ref, uint64_t S, + static uint64_t resolve(object::RelocationRef Ref, uint64_t S, uint64_t /* A */) { return S + Ref.getRawDataRefImpl().p; } @@ -66,7 +66,7 @@ template <class RelTy> struct LLDRelocationResolver { template <class ELFT> struct LLDRelocationResolver<Elf_Rel_Impl<ELFT, false>> { // For Rel, the addend A is supplied by the caller. - static uint64_t Resolve(object::RelocationRef /*Ref*/, uint64_t S, + static uint64_t resolve(object::RelocationRef /*Ref*/, uint64_t S, uint64_t A) { return S + A; } @@ -110,7 +110,7 @@ LLDDwarfObj<ELFT>::findAux(const InputSectionBase &Sec, uint64_t Pos, DataRefImpl D; D.p = getAddend<ELFT>(Rel); return RelocAddrEntry{SecIndex, RelocationRef(D, nullptr), - LLDRelocationResolver<RelTy>::Resolve, Val}; + LLDRelocationResolver<RelTy>::resolve, Val}; } template <class ELFT> diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index e7bbfa19d3a..4d65ef37214 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -55,7 +55,7 @@ static ELFKind getELFKind(MemoryBufferRef MB, StringRef ArchiveName) { unsigned char Endian; std::tie(Size, Endian) = getElfArchType(MB.getBuffer()); - auto Fatal = [&](StringRef Msg) { + auto Report = [&](StringRef Msg) { StringRef Filename = MB.getBufferIdentifier(); if (ArchiveName.empty()) fatal(Filename + ": " + Msg); @@ -64,16 +64,16 @@ static ELFKind getELFKind(MemoryBufferRef MB, StringRef ArchiveName) { }; if (!MB.getBuffer().startswith(ElfMagic)) - Fatal("not an ELF file"); + Report("not an ELF file"); if (Endian != ELFDATA2LSB && Endian != ELFDATA2MSB) - Fatal("corrupted ELF file: invalid data encoding"); + Report("corrupted ELF file: invalid data encoding"); if (Size != ELFCLASS32 && Size != ELFCLASS64) - Fatal("corrupted ELF file: invalid file class"); + Report("corrupted ELF file: invalid file class"); size_t BufSize = MB.getBuffer().size(); if ((Size == ELFCLASS32 && BufSize < sizeof(Elf32_Ehdr)) || (Size == ELFCLASS64 && BufSize < sizeof(Elf64_Ehdr))) - Fatal("corrupted ELF file: file is too short"); + Report("corrupted ELF file: file is too short"); if (Size == ELFCLASS32) return (Endian == ELFDATA2LSB) ? ELF32LEKind : ELF32BEKind; diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp index 61080eca7a1..bdd4d7cdc23 100644 --- a/lld/ELF/Relocations.cpp +++ b/lld/ELF/Relocations.cpp @@ -566,10 +566,10 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol &SS) { // See if this symbol is in a read-only segment. If so, preserve the symbol's // memory protection by reserving space in the .bss.rel.ro section. - bool IsReadOnly = isReadOnly<ELFT>(SS); - BssSection *Sec = make<BssSection>(IsReadOnly ? ".bss.rel.ro" : ".bss", - SymSize, SS.Alignment); - if (IsReadOnly) + bool IsRO = isReadOnly<ELFT>(SS); + BssSection *Sec = + make<BssSection>(IsRO ? ".bss.rel.ro" : ".bss", SymSize, SS.Alignment); + if (IsRO) In.BssRelRo->getParent()->addSection(Sec); else In.Bss->getParent()->addSection(Sec); diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp index 0ab2a96c9c8..ab96b8e3773 100644 --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -40,14 +40,21 @@ using namespace llvm::support::endian; using namespace lld; using namespace lld::elf; -static bool isUnderSysroot(StringRef Path); - namespace { class ScriptParser final : ScriptLexer { public: - ScriptParser(MemoryBufferRef MB) - : ScriptLexer(MB), - IsUnderSysroot(isUnderSysroot(MB.getBufferIdentifier())) {} + ScriptParser(MemoryBufferRef MB) : ScriptLexer(MB) { + // Initialize IsUnderSysroot + if (Config->Sysroot == "") + return; + StringRef Path = MB.getBufferIdentifier(); + for (; !Path.empty(); Path = sys::path::parent_path(Path)) { + if (!sys::fs::equivalent(Config->Sysroot, Path)) + continue; + IsUnderSysroot = true; + return; + } + } void readLinkerScript(); void readVersionScript(); @@ -118,7 +125,7 @@ private: readSymbols(); // True if a script being read is in a subdirectory specified by -sysroot. - bool IsUnderSysroot; + bool IsUnderSysroot = false; // A set to detect an INCLUDE() cycle. StringSet<> Seen; @@ -131,15 +138,6 @@ static StringRef unquote(StringRef S) { return S; } -static bool isUnderSysroot(StringRef Path) { - if (Config->Sysroot == "") - return false; - for (; !Path.empty(); Path = sys::path::parent_path(Path)) - if (sys::fs::equivalent(Config->Sysroot, Path)) - return true; - return false; -} - // Some operations only support one non absolute value. Move the // absolute one to the right hand side for convenience. static void moveAbsRight(ExprValue &A, ExprValue &B) { @@ -1449,8 +1447,8 @@ std::vector<SymbolVersion> ScriptParser::readVersionExtern() { std::vector<SymbolVersion> Ret; while (!errorCount() && peek() != "}") { StringRef Tok = next(); - bool HasWildcard = !Tok.startswith("\"") && hasWildcard(Tok); - Ret.push_back({unquote(Tok), IsCXX, HasWildcard}); + Ret.push_back( + {unquote(Tok), IsCXX, !Tok.startswith("\"") && hasWildcard(Tok)}); if (consume("}")) return Ret; expect(";"); diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 00ecc41524f..172bdf17814 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -317,18 +317,18 @@ void elf::maybeWarnUnorderableSymbol(const Symbol *Sym) { const InputFile *File = Sym->File; auto *D = dyn_cast<Defined>(Sym); - auto Warn = [&](StringRef S) { warn(toString(File) + S + Sym->getName()); }; + auto Report = [&](StringRef S) { warn(toString(File) + S + Sym->getName()); }; if (Sym->isUndefined()) - Warn(": unable to order undefined symbol: "); + Report(": unable to order undefined symbol: "); else if (Sym->isShared()) - Warn(": unable to order shared symbol: "); + Report(": unable to order shared symbol: "); else if (D && !D->Section) - Warn(": unable to order absolute symbol: "); + Report(": unable to order absolute symbol: "); else if (D && isa<OutputSection>(D->Section)) - Warn(": unable to order synthetic symbol: "); + Report(": unable to order synthetic symbol: "); else if (D && !D->Section->Repl->isLive()) - Warn(": unable to order discarded symbol: "); + Report(": unable to order discarded symbol: "); } // Returns a symbol for an error message. |