diff options
author | Rafael Auler <rafaelauler@gmail.com> | 2015-02-03 16:08:57 +0000 |
---|---|---|
committer | Rafael Auler <rafaelauler@gmail.com> | 2015-02-03 16:08:57 +0000 |
commit | ee95c3b5c57f7b3e4fe369f543b14d2b677789f1 (patch) | |
tree | fdf645ab3567e69f856bda9277e2cdaa9979e2ef /lld/lib/ReaderWriter/LinkerScript.cpp | |
parent | 0285fc869ddcdce44ebd301580cd3dd6797e0dc2 (diff) | |
download | bcm5719-llvm-ee95c3b5c57f7b3e4fe369f543b14d2b677789f1.tar.gz bcm5719-llvm-ee95c3b5c57f7b3e4fe369f543b14d2b677789f1.zip |
Make ELFLinkingContext own LinkerScript buffers
Currently, no one owns script::Parser buffers, but yet ELFLinkingContext gets
updated with StringRef pointers to data inside Parser buffers. Since this buffer
is locally owned inside GnuLdDriver::evalLinkerScript(), as soon as this
function finishes, all pointers in ELFLinkingContext that comes from linker
scripts get invalid. The problem is that we need someone to own linker scripts
data structures and, since ELFLinkingContext transports references to linker
scripts data, we can simply make it also own all linker scripts data.
Differential Revision: http://reviews.llvm.org/D7323
llvm-svn: 227975
Diffstat (limited to 'lld/lib/ReaderWriter/LinkerScript.cpp')
-rw-r--r-- | lld/lib/ReaderWriter/LinkerScript.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lld/lib/ReaderWriter/LinkerScript.cpp b/lld/lib/ReaderWriter/LinkerScript.cpp index c8dbfdd32fb..24dfe1beee6 100644 --- a/lld/lib/ReaderWriter/LinkerScript.cpp +++ b/lld/lib/ReaderWriter/LinkerScript.cpp @@ -892,67 +892,67 @@ void Sections::dump(raw_ostream &os) const { } // Parser functions -LinkerScript *Parser::parse() { +std::error_code Parser::parse() { // Get the first token. _lex.lex(_tok); // Parse top level commands. while (true) { switch (_tok._kind) { case Token::eof: - return &_script; + return std::error_code(); case Token::semicolon: consumeToken(); break; case Token::kw_output: { auto output = parseOutput(); if (!output) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(output); break; } case Token::kw_output_format: { auto outputFormat = parseOutputFormat(); if (!outputFormat) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(outputFormat); break; } case Token::kw_output_arch: { auto outputArch = parseOutputArch(); if (!outputArch) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(outputArch); break; } case Token::kw_group: { auto group = parseGroup(); if (!group) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(group); break; } case Token::kw_as_needed: // Not allowed at top level. error(_tok, "AS_NEEDED not allowed at top level."); - return nullptr; + return LinkerScriptReaderError::parse_error; case Token::kw_entry: { Entry *entry = parseEntry(); if (!entry) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(entry); break; } case Token::kw_search_dir: { SearchDir *searchDir = parseSearchDir(); if (!searchDir) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(searchDir); break; } case Token::kw_sections: { Sections *sections = parseSections(); if (!sections) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(sections); break; } @@ -962,18 +962,17 @@ LinkerScript *Parser::parse() { case Token::kw_provide_hidden: { const Command *cmd = parseSymbolAssignment(); if (!cmd) - return nullptr; + return LinkerScriptReaderError::parse_error; _script._commands.push_back(cmd); break; } default: // Unexpected. error(_tok, "expected linker script command"); - return nullptr; + return LinkerScriptReaderError::parse_error; } } - - return nullptr; + return LinkerScriptReaderError::parse_error; } const Expression *Parser::parseFunctionCall() { |