summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lld/ELF/Driver.cpp2
-rw-r--r--lld/ELF/Driver.h3
-rw-r--r--lld/ELF/LinkerScript.cpp4
-rw-r--r--lld/ELF/LinkerScript.h8
4 files changed, 11 insertions, 6 deletions
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index f12806d91c6..ea275807449 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 a8c6e9c4228..c7b2d9ffad5 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 536109fa625..4f39acba57a 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 61ad59468cb..7eb07730fc7 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<StringRef, StringRef> RevSections;
+
+ llvm::BumpPtrAllocator Alloc;
};
extern LinkerScript *Script;
OpenPOWER on IntegriCloud