#ifndef LLD_READER_WRITER_ELF_TARGET_INFO_H
#define LLD_READER_WRITER_ELF_TARGET_INFO_H
+#include "lld/Core/LinkerOptions.h"
#include "lld/Core/TargetInfo.h"
#include "llvm/Object/ELF.h"
#include "llvm/Support/ELF.h"
uint16_t getOutputType() const;
uint16_t getOutputMachine() const;
+ virtual uint64_t getBaseAddress() const { return _options._baseAddress; }
+
static std::unique_ptr<ELFTargetInfo> create(const LinkerOptions &lo);
template <typename ELFT>
if (_segments.empty())
return;
- uint64_t virtualAddress = _targetInfo.getLinkerOptions()._baseAddress;
+ uint64_t virtualAddress = _targetInfo.getBaseAddress();
// HACK: This is a super dirty hack. The elf header and program header are
// not part of a section, but we need them to be loaded at the base address
virtual uint64_t getPageSize() const { return 0x1000; }
+ virtual uint64_t getBaseAddress() const {
+ if (_options._baseAddress == 0)
+ return 0x400000;
+ return _options._baseAddress;
+ }
+
};
} // elf
} // lld
-RUN: lld-core -reader ELF -writer ELF -o %t1 %p/Inputs/phdr.i386 | elf-dump %t1 | FileCheck -check-prefix=ED %s
+RUN: lld-core -reader ELF -writer ELF -o %t1 %p/Inputs/phdr.i386 | elf-dump %t1 | FileCheck -check-prefix=ED %s
+
+RUN: lld -core -target x86_64-linux -output=%t1 %p/Inputs/relocs.x86-64 \
+RUN: && llvm-objdump -p %t1 | FileCheck %s -check-prefix=X86_64
ED: # Program Header 0
ED: (('p_type', 0x00000001)
ED: ('p_memsz', 0x0000008c)
ED: ('p_align', 0x00001000)
ED: ),
+
+X86_64: vaddr 0x0000000000400000