No change in functionality.
llvm-svn: 228379
/// Public function for testing.
static std::error_code evalLinkerScript(ELFLinkingContext &ctx,
std::unique_ptr<MemoryBuffer> mb,
- raw_ostream &diag);
+ raw_ostream &diag, bool nostdlib);
/// A factory method to create an instance of ELFLinkingContext.
static std::unique_ptr<ELFLinkingContext>
_scripts.push_back(std::move(script));
}
- /// \brief nostdlib support.
- bool nostdlib() const { return _nostdlib; }
- void setNoStdLib(bool nostdlib) { _nostdlib = nostdlib; }
-
private:
ELFLinkingContext() LLVM_DELETED_FUNCTION;
return std::error_code();
}
-std::error_code
-GnuLdDriver::evalLinkerScript(ELFLinkingContext &ctx,
- std::unique_ptr<MemoryBuffer> mb,
- raw_ostream &diag) {
+std::error_code GnuLdDriver::evalLinkerScript(ELFLinkingContext &ctx,
+ std::unique_ptr<MemoryBuffer> mb,
+ raw_ostream &diag,
+ bool nostdlib) {
// Read the script file from disk and parse.
StringRef path = mb->getBufferIdentifier();
auto parser = llvm::make_unique<script::Parser>(std::move(mb));
ctx.getNodes().push_back(llvm::make_unique<GroupEnd>(groupSize));
}
if (auto *searchDir = dyn_cast<script::SearchDir>(c))
- if (!ctx.nostdlib())
+ if (!nostdlib)
ctx.addSearchPath(searchDir->getSearchPath());
if (auto *entry = dyn_cast<script::Entry>(c))
ctx.setEntrySymbolName(entry->getEntryName());
if (!(hasNoStdLib = parsedArgs->hasArg(OPT_nostdlib)))
ctx->addDefaultSearchDirs(baseTriple);
- // -nostdlib support.
- ctx->setNoStdLib(hasNoStdLib);
-
// Handle --demangle option(For compatibility)
if (parsedArgs->getLastArg(OPT_demangle))
ctx->setDemangleSymbols(true);
diag << "Cannot open " << path << ": " << ec.message() << "\n";
return false;
}
- std::error_code ec = evalLinkerScript(*ctx, std::move(mb.get()), diag);
+ std::error_code ec =
+ evalLinkerScript(*ctx, std::move(mb.get()), diag, hasNoStdLib);
if (ec) {
diag << path << ": Error parsing linker script: "
<< ec.message() << "\n";
_mergeCommonStrings(false), _useShlibUndefines(true),
_dynamicLinkerArg(false), _noAllowDynamicLibraries(false),
_mergeRODataToTextSegment(true), _demangle(true), _alignSegments(true),
- _nostdlib(false), _outputMagic(OutputMagic::DEFAULT),
- _initFunction("_init"), _finiFunction("_fini"), _sysrootPath("") {}
+ _outputMagic(OutputMagic::DEFAULT), _initFunction("_init"),
+ _finiFunction("_fini"), _sysrootPath("") {}
void ELFLinkingContext::addPasses(PassManager &pm) {
pm.add(std::unique_ptr<Pass>(new elf::OrderPass()));
_ctx = std::move(GnuLdDriver::createELFLinkingContext(triple));
}
- void parse(StringRef script) {
+ void parse(StringRef script, bool nostdlib = false) {
std::unique_ptr<MemoryBuffer> mb = MemoryBuffer::getMemBuffer(
script, "foo.so");
std::string s;
raw_string_ostream out(s);
- std::error_code ec = GnuLdDriver::evalLinkerScript(
- *_ctx, std::move(mb), out);
+ std::error_code ec =
+ GnuLdDriver::evalLinkerScript(*_ctx, std::move(mb), out, nostdlib);
EXPECT_FALSE(ec);
};
// Test that search paths are ignored when nostdlib is set.
TEST_F(LinkerScriptTest, IgnoreSearchDirNoStdLib) {
- _ctx->setNoStdLib(true);
- parse("SEARCH_DIR(\"/foo/bar\")");
+ parse("SEARCH_DIR(\"/foo/bar\")", true /*nostdlib*/);
std::vector<StringRef> paths = _ctx->getSearchPaths();
EXPECT_EQ((size_t)0, paths.size());
}