[lld] r227787 - [ELF] Implement action for OUTPUT linker script command
Davide Italiano
davide at freebsd.org
Sun Feb 1 22:28:13 PST 2015
Author: davide
Date: Mon Feb 2 00:28:12 2015
New Revision: 227787
URL: http://llvm.org/viewvc/llvm-project?rev=227787&view=rev
Log:
[ELF] Implement action for OUTPUT linker script command
Reviewed by: ruiu, shankarke
Modified:
lld/trunk/lib/Driver/GnuLdDriver.cpp
lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=227787&r1=227786&r2=227787&view=diff
==============================================================================
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Mon Feb 2 00:28:12 2015
@@ -280,9 +280,7 @@ GnuLdDriver::evalLinkerScript(ELFLinking
if (!script)
return LinkerScriptReaderError::parse_error;
// Evaluate script commands.
- // Currently we only recognize this subset of linker script commands:
- // - GROUP()
- // - SEARCH_DIR()
+ // Currently we only recognize this subset of linker script commands.
for (const script::Command *c : script->_commands) {
if (auto *group = dyn_cast<script::Group>(c))
if (std::error_code ec = evaluateLinkerScriptGroup(ctx, path, group, diag))
@@ -291,6 +289,8 @@ GnuLdDriver::evalLinkerScript(ELFLinking
ctx.addSearchPath(searchDir->getSearchPath());
if (auto *entry = dyn_cast<script::Entry>(c))
ctx.setEntrySymbolName(entry->getEntryName());
+ if (auto *output = dyn_cast<script::Output>(c))
+ ctx.setOutputPath(output->getOutputFileName());
}
return std::error_code();
}
Modified: lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp?rev=227787&r1=227786&r2=227787&view=diff
==============================================================================
--- lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp (original)
+++ lld/trunk/unittests/DriverTests/GnuLdDriverTest.cpp Mon Feb 2 00:28:12 2015
@@ -204,3 +204,16 @@ TEST_F(GnuLdParserTest, LinkerScriptEntr
StringRef entrySymbol = _context->entrySymbolName();
EXPECT_EQ("blah", entrySymbol);
}
+
+TEST_F(GnuLdParserTest, LinkerScriptOutput) {
+ parse("ld", "a.o", nullptr);
+ std::unique_ptr<MemoryBuffer> mb = MemoryBuffer::getMemBuffer(
+ "OUTPUT(\"/path/to/output\")", "foo.so");
+ std::string s;
+ raw_string_ostream out(s);
+ std::error_code ec = GnuLdDriver::evalLinkerScript(
+ *_context, std::move(mb), out);
+ EXPECT_FALSE(ec);
+ StringRef output = _context->outputPath();
+ EXPECT_EQ("/path/to/output", output);
+}
More information about the llvm-commits
mailing list