From f9de0d6904cde91fb4b9c7701be2f907717f2c07 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 11 Feb 2016 21:38:55 +0000 Subject: [PATCH] ELF: Remove readLinkerScript and define LinkerScript::read instead. llvm-svn: 260598 --- lld/ELF/Driver.cpp | 2 +- lld/ELF/Driver.h | 3 --- lld/ELF/LinkerScript.cpp | 4 ++-- lld/ELF/LinkerScript.h | 8 ++++++++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index f12806d91c6f..ea2758074496 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -98,7 +98,7 @@ void LinkerDriver::addFile(StringRef Path) { switch (identify_magic(MBRef.getBuffer())) { case file_magic::unknown: - readLinkerScript(&Alloc, MBRef); + Script->read(MBRef); return; case file_magic::archive: if (WholeArchive) { diff --git a/lld/ELF/Driver.h b/lld/ELF/Driver.h index a8c6e9c4228c..c7b2d9ffad5a 100644 --- a/lld/ELF/Driver.h +++ b/lld/ELF/Driver.h @@ -53,9 +53,6 @@ enum { #undef OPTION }; -// Parses a linker script. Calling this function updates the Symtab and Config. -void readLinkerScript(llvm::BumpPtrAllocator *A, MemoryBufferRef MB); - std::string findFromSearchPaths(StringRef Path); std::string searchLibrary(StringRef Path); std::string buildSysrootedPath(llvm::StringRef Dir, llvm::StringRef File); diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp index 536109fa625d..4f39acba57a9 100644 --- a/lld/ELF/LinkerScript.cpp +++ b/lld/ELF/LinkerScript.cpp @@ -370,7 +370,7 @@ static bool isUnderSysroot(StringRef Path) { } // Entry point. The other functions or classes are private to this file. -void elf2::readLinkerScript(BumpPtrAllocator *A, MemoryBufferRef MB) { +void LinkerScript::read(MemoryBufferRef MB) { StringRef Path = MB.getBufferIdentifier(); - ScriptParser(A, MB.getBuffer(), isUnderSysroot(Path)).run(); + ScriptParser(&Alloc, MB.getBuffer(), isUnderSysroot(Path)).run(); } diff --git a/lld/ELF/LinkerScript.h b/lld/ELF/LinkerScript.h index 61ad59468cba..7eb07730fc71 100644 --- a/lld/ELF/LinkerScript.h +++ b/lld/ELF/LinkerScript.h @@ -13,6 +13,8 @@ #include "lld/Core/LLVM.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/MapVector.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/MemoryBuffer.h" namespace lld { namespace elf2 { @@ -23,6 +25,10 @@ class LinkerScript { friend class ScriptParser; public: + // Parses a linker script. Calling this function may update + // this object and Config. + void read(MemoryBufferRef MB); + StringRef getOutputSection(StringRef InputSection); bool isDiscarded(StringRef InputSection); int compareSections(StringRef A, StringRef B); @@ -35,6 +41,8 @@ private: // Inverse map of Sections. llvm::DenseMap RevSections; + + llvm::BumpPtrAllocator Alloc; }; extern LinkerScript *Script;