[Gnu] Move code from .h to .cpp.

No change in functionality.

llvm-svn: 195582
This commit is contained in:
Shankar Easwaran 2013-11-24 22:29:19 +00:00
parent 3db89662c3
commit 98758cbe85
3 changed files with 63 additions and 45 deletions

View File

@ -71,51 +71,7 @@ public:
}
/// \brief Parse the input file to lld::File.
error_code parse(const LinkingContext &ctx, raw_ostream &diagnostics) {
ErrorOr<StringRef> filePath = getPath(ctx);
if (!filePath)
return error_code(filePath);
if (error_code ec = getBuffer(*filePath))
return ec;
if (ctx.logInputFiles())
diagnostics << *filePath << "\n";
if (filePath->endswith(".objtxt"))
return ctx.getYAMLReader().parseFile(_buffer, _files);
// Identify File type
llvm::sys::fs::file_magic FileType =
llvm::sys::fs::identify_magic(_buffer->getBuffer());
switch (FileType) {
case llvm::sys::fs::file_magic::elf_relocatable:
case llvm::sys::fs::file_magic::elf_shared_object:
// Call the default reader to read object files and shared objects
return _elfLinkingContext.getDefaultReader().parseFile(_buffer, _files);
case llvm::sys::fs::file_magic::archive: {
// Process archive files. If Whole Archive option is set,
// parse all members of the archive.
error_code ec;
std::unique_ptr<FileArchive> fileArchive(
new FileArchive(ctx, std::move(_buffer), ec, _isWholeArchive));
if (_isWholeArchive) {
fileArchive->parseAllMembers(_files);
_archiveFile = std::move(fileArchive);
} else {
_files.push_back(std::move(fileArchive));
}
return ec;
}
default:
// Process Linker script
return _elfLinkingContext.getLinkerScriptReader().parseFile(_buffer,
_files);
}
}
error_code parse(const LinkingContext &, raw_ostream &);
/// \brief This is used by Group Nodes, when there is a need to reset the
/// the file to be processed next. When handling a group node that contains

View File

@ -15,6 +15,7 @@ add_lld_library(lldDriver
DarwinLdDriver.cpp
Driver.cpp
GnuLdDriver.cpp
GnuLdInputGraph.cpp
WinLinkDriver.cpp
WinLinkInputGraph.cpp
UniversalDriver.cpp

View File

@ -0,0 +1,61 @@
//===- lib/Driver/GnuLdInputGraph.cpp -------------------------------------===//
//
// The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "lld/Driver/GnuLdInputGraph.h"
#include "lld/ReaderWriter/LinkerScript.h"
using namespace lld;
/// \brief Parse the input file to lld::File.
error_code ELFFileNode::parse(const LinkingContext &ctx,
raw_ostream &diagnostics) {
ErrorOr<StringRef> filePath = getPath(ctx);
if (!filePath)
return error_code(filePath);
if (error_code ec = getBuffer(*filePath))
return ec;
if (ctx.logInputFiles())
diagnostics << *filePath << "\n";
if (filePath->endswith(".objtxt"))
return ctx.getYAMLReader().parseFile(_buffer, _files);
// Identify File type
llvm::sys::fs::file_magic FileType =
llvm::sys::fs::identify_magic(_buffer->getBuffer());
switch (FileType) {
case llvm::sys::fs::file_magic::elf_relocatable:
case llvm::sys::fs::file_magic::elf_shared_object:
// Call the default reader to read object files and shared objects
return _elfLinkingContext.getDefaultReader().parseFile(_buffer, _files);
case llvm::sys::fs::file_magic::archive: {
// Process archive files. If Whole Archive option is set,
// parse all members of the archive.
error_code ec;
std::unique_ptr<FileArchive> fileArchive(
new FileArchive(ctx, std::move(_buffer), ec, _isWholeArchive));
if (_isWholeArchive) {
fileArchive->parseAllMembers(_files);
_archiveFile = std::move(fileArchive);
} else {
_files.push_back(std::move(fileArchive));
}
return ec;
}
default:
// Process Linker script
return _elfLinkingContext.getLinkerScriptReader().parseFile(_buffer,
_files);
break;
}
}