add elf targethandler
llvm-svn: 173430
diff --git a/lld/lib/ReaderWriter/Native/ReaderNative.cpp b/lld/lib/ReaderWriter/Native/ReaderNative.cpp
index 814215f..36bc7fc 100644
--- a/lld/lib/ReaderWriter/Native/ReaderNative.cpp
+++ b/lld/lib/ReaderWriter/Native/ReaderNative.cpp
@@ -246,11 +246,11 @@
/// Instantiates a File object from a native object file. Ownership
/// of the MemoryBuffer is transfered to the resulting File object.
- static error_code make(std::unique_ptr<llvm::MemoryBuffer> &mb,
- StringRef path,
- std::vector<std::unique_ptr<lld::File>> &result) {
- const uint8_t* const base =
- reinterpret_cast<const uint8_t*>(mb->getBufferStart());
+ static error_code make(
+ const TargetInfo &ti, std::unique_ptr<llvm::MemoryBuffer> &mb,
+ StringRef path, std::vector<std::unique_ptr<lld::File> > &result) {
+ const uint8_t *const base =
+ reinterpret_cast<const uint8_t *>(mb->getBufferStart());
const NativeFileHeader* const header =
reinterpret_cast<const NativeFileHeader*>(base);
const NativeChunk *const chunks =
@@ -264,17 +264,16 @@
if ( header->fileSize > fileSize )
return make_error_code(native_reader_error::file_too_short);
- DEBUG_WITH_TYPE("ReaderNative", llvm::dbgs()
- << " Native File Header:"
- << " fileSize=" << header->fileSize
- << " chunkCount=" << header->chunkCount
- << "\n");
+ DEBUG_WITH_TYPE("ReaderNative",
+ llvm::dbgs() << " Native File Header:" << " fileSize="
+ << header->fileSize << " chunkCount="
+ << header->chunkCount << "\n");
// instantiate NativeFile object and add values to it as found
- std::unique_ptr<File> file(new File(std::move(mb), path));
+ std::unique_ptr<File> file(new File(ti, std::move(mb), path));
// process each chunk
- for(uint32_t i=0; i < header->chunkCount; ++i) {
+ for (uint32_t i = 0; i < header->chunkCount; ++i) {
error_code ec;
const NativeChunk* chunk = &chunks[i];
// sanity check chunk is within file
@@ -373,9 +372,10 @@
virtual const atom_collection<SharedLibraryAtom>& sharedLibrary() const {
return _sharedLibraryAtoms;
}
- virtual const atom_collection<AbsoluteAtom>& absolute() const {
- return _absoluteAtoms;
+ virtual const atom_collection<AbsoluteAtom> &absolute() const {
+ return _absoluteAtoms;
}
+ virtual const TargetInfo &getTargetInfo() const { return _targetInfo; }
private:
friend class NativeDefinedAtomV1;
@@ -728,25 +728,18 @@
assert(index > _targetsTableCount);
_targetsTable[index] = newAtom;
}
-
-
// private constructor, only called by make()
- File(std::unique_ptr<llvm::MemoryBuffer> mb, StringRef path) :
- lld::File(path),
- _buffer(std::move(mb)), // Reader now takes ownership of buffer
- _header(nullptr),
- _targetsTable(nullptr),
- _targetsTableCount(0),
- _strings(nullptr),
- _stringsMaxOffset(0),
- _addends(nullptr),
- _addendsMaxIndex(0),
- _contentStart(nullptr),
- _contentEnd(nullptr)
- {
- _header = reinterpret_cast<const NativeFileHeader*>
- (_buffer->getBufferStart());
+ File(const TargetInfo &ti, std::unique_ptr<llvm::MemoryBuffer> mb,
+ StringRef path)
+ : lld::File(path),
+ _buffer(std::move(mb)), // Reader now takes ownership of buffer
+ _header(nullptr), _targetsTable(nullptr), _targetsTableCount(0),
+ _strings(nullptr), _stringsMaxOffset(0), _addends(nullptr),
+ _addendsMaxIndex(0), _contentStart(nullptr), _contentEnd(nullptr),
+ _targetInfo(ti) {
+ _header =
+ reinterpret_cast<const NativeFileHeader *>(_buffer->getBufferStart());
}
template <typename T>
@@ -805,13 +798,13 @@
const char* _strings;
uint32_t _stringsMaxOffset;
const Reference::Addend* _addends;
- uint32_t _addendsMaxIndex;
- const uint8_t* _contentStart;
- const uint8_t* _contentEnd;
+ uint32_t _addendsMaxIndex;
+ const uint8_t *_contentStart;
+ const uint8_t *_contentEnd;
+ const TargetInfo &_targetInfo;
};
-
-inline const class lld::File& NativeDefinedAtomV1::file() const {
+inline const class lld::File &NativeDefinedAtomV1::file() const {
return *_file;
}
@@ -929,10 +922,11 @@
public:
Reader(const TargetInfo &ti)
: lld::Reader(ti) {}
-
- virtual error_code parseFile(std::unique_ptr<MemoryBuffer> mb,
- std::vector<std::unique_ptr<lld::File>> &result) {
- return File::make(mb, mb->getBufferIdentifier(), result);
+
+ virtual error_code parseFile(
+ std::unique_ptr<MemoryBuffer> mb,
+ std::vector<std::unique_ptr<lld::File> > &result) {
+ return File::make(_targetInfo, mb, mb->getBufferIdentifier(), result);
}
};
} // end namespace native