summaryrefslogtreecommitdiffstats
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2015-10-01 15:23:09 +0000
committerRui Ueyama <ruiu@google.com>2015-10-01 15:23:09 +0000
commit983ed2b7499d9737e5de399a1e1cd57b3701ef6e (patch)
tree20b8e69576f93338ca94b97c5607044a31a0f480 /lld/ELF/LinkerScript.cpp
parent812f57e6dc8280a503f1b9cab69b045b84ca7d81 (diff)
downloadbcm5719-llvm-983ed2b7499d9737e5de399a1e1cd57b3701ef6e.tar.gz
bcm5719-llvm-983ed2b7499d9737e5de399a1e1cd57b3701ef6e.zip
ELF2: Define Driver::addFile() as a one-stop place to open a file.
Opening a file and dispatching to readLinkerScript() or createFile() is a common operation. We want to use that at least from Driver and from LinkerScript. In COFF, we had the same problem. This patch resolves the problem in the same way as we did for COFF. Now, if you have a path that you want to open, just call Driver->addFile(StringRef). That function opens the file and handles that as if that were given by command line. This function is the only place we call identify_magic(). llvm-svn: 249023
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 746af74b6b9..44c045ad17c 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -26,7 +26,7 @@ using namespace lld::elf2;
namespace {
class LinkerScript {
public:
- LinkerScript(SymbolTable *T, StringRef S) : Symtab(T), Tokens(tokenize(S)) {}
+ LinkerScript(StringRef S) : Tokens(tokenize(S)) {}
void run();
private:
@@ -40,7 +40,6 @@ private:
void readGroup();
void readOutputFormat();
- SymbolTable *Symtab;
std::vector<StringRef> Tokens;
size_t Pos = 0;
};
@@ -125,7 +124,7 @@ void LinkerScript::readAsNeeded() {
StringRef Tok = next();
if (Tok == ")")
return;
- Symtab->addFile(createFile(openFile(Tok)));
+ Driver->addFile(Tok);
}
}
@@ -139,7 +138,7 @@ void LinkerScript::readGroup() {
readAsNeeded();
continue;
}
- Symtab->addFile(createFile(openFile(Tok)));
+ Driver->addFile(Tok);
}
}
@@ -151,6 +150,6 @@ void LinkerScript::readOutputFormat() {
}
// Entry point. The other functions or classes are private to this file.
-void lld::elf2::readLinkerScript(SymbolTable *Symtab, MemoryBufferRef MB) {
- LinkerScript(Symtab, MB.getBuffer()).run();
+void lld::elf2::readLinkerScript(MemoryBufferRef MB) {
+ LinkerScript(MB.getBuffer()).run();
}
OpenPOWER on IntegriCloud