ELF: Remove readLinkerScript and define LinkerScript::read instead.
llvm-svn: 260598
diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp
index f12806d..ea27580 100644
--- a/lld/ELF/Driver.cpp
+++ b/lld/ELF/Driver.cpp
@@ -98,7 +98,7 @@
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 a8c6e9c..c7b2d9f 100644
--- a/lld/ELF/Driver.h
+++ b/lld/ELF/Driver.h
@@ -53,9 +53,6 @@
#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 536109f..4f39acb 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -370,7 +370,7 @@
}
// 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 61ad5946..7eb0773 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 @@
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 @@
// Inverse map of Sections.
llvm::DenseMap<StringRef, StringRef> RevSections;
+
+ llvm::BumpPtrAllocator Alloc;
};
extern LinkerScript *Script;