};
llvm::Triple getTriple() const { return _triple; }
- virtual bool is64Bits() const;
- virtual bool isLittleEndian() const = 0;
virtual uint64_t getPageSize() const { return 0x1000; }
OutputMagic getOutputMagic() const { return _outputMagic; }
uint16_t getOutputELFType() const { return _outputELFType; }
}
}
- bool isLittleEndian() const override {
- return AArch64ELFType::TargetEndianness == llvm::support::little;
- }
-
bool isCopyRelocation(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false;
_noAllowDynamicLibraries(false), _mergeRODataToTextSegment(true),
_demangle(true), _outputMagic(OutputMagic::DEFAULT), _sysrootPath("") {}
-bool ELFLinkingContext::is64Bits() const { return getTriple().isArch64Bit(); }
-
void ELFLinkingContext::addPasses(PassManager &pm) {
if (_runLayoutPass)
pm.add(std::unique_ptr<Pass>(new LayoutPass(registry())));
virtual void doPreFlight() {}
- void finalize() {}
+ void finalize() {
+ _eh.e_ident[llvm::ELF::EI_CLASS] =
+ (ELFT::Is64Bits) ? llvm::ELF::ELFCLASS64 : llvm::ELF::ELFCLASS32;
+ _eh.e_ident[llvm::ELF::EI_DATA] =
+ (ELFT::TargetEndianness == llvm::support::little)
+ ? llvm::ELF::ELFDATA2LSB
+ : llvm::ELF::ELFDATA2MSB;
+ _eh.e_type = this->_context.getOutputELFType();
+ _eh.e_machine = this->_context.getOutputMachine();
+ }
private:
Elf_Ehdr _eh;
}
}
- bool isLittleEndian() const override {
- return HexagonELFType::TargetEndianness == llvm::support::little;
- }
-
/// \brief Create Internal files for Init/Fini
void createInternalFiles(
std::vector<std::unique_ptr<File>> &result) const override;
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new MipsTargetHandler(*this))) {}
-bool MipsLinkingContext::isLittleEndian() const {
- return Mips32ElELFType::TargetEndianness == llvm::support::little;
-}
-
uint64_t MipsLinkingContext::getBaseAddress() const {
if (_baseAddress == 0 && getOutputELFType() == llvm::ELF::ET_EXEC)
return 0x400000;
MipsLinkingContext(llvm::Triple triple);
// ELFLinkingContext
- bool isLittleEndian() const override;
uint64_t getBaseAddress() const override;
StringRef entrySymbolName() const override;
StringRef getDefaultInterpreter() const override;
}
template <class ELFT> std::error_code OutputELFWriter<ELFT>::setELFHeader() {
- _elfHeader->e_ident(ELF::EI_CLASS,
- _context.is64Bits() ? ELF::ELFCLASS64 : ELF::ELFCLASS32);
- _elfHeader->e_ident(ELF::EI_DATA, _context.isLittleEndian()
- ? ELF::ELFDATA2LSB
- : ELF::ELFDATA2MSB);
_elfHeader->e_type(_context.getOutputELFType());
_elfHeader->e_machine(_context.getOutputMachine());
_elfHeader->e_ident(ELF::EI_VERSION, 1);
// HACK: We have to write out the header and program header here even though
// they are a member of a segment because only sections are written in the
// following loop.
+
+ // Finalize ELF Header / Program Headers.
+ _elfHeader->finalize();
+ _programHeader->finalize();
+
_elfHeader->write(this, _layout, *buffer);
_programHeader->write(this, _layout, *buffer);
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new PPCTargetHandler(*this))) {}
- bool isLittleEndian() const override { return false; }
-
/// \brief PPC has no relative relocations defined
bool isRelativeReloc(const Reference &) const override { return false; }
};
this->setOrder(order);
this->_flags = SHF_ALLOC;
// Set the alignment properly depending on the target architecture
- if (context.is64Bits())
- this->_align2 = 8;
- else
- this->_align2 = 4;
+ this->_align2 = ELFT::Is64Bits ? 8 : 4;
if (context.isRelaOutputFormat()) {
this->_entSize = sizeof(Elf_Rela);
this->_type = SHT_RELA;
this->_entSize = 4;
this->_type = SHT_HASH;
this->_flags = SHF_ALLOC;
- // Set the alignment properly depending on the target architecture
- if (context.is64Bits())
- this->_align2 = 8;
- else
- this->_align2 = 4;
+ this->_align2 = ELFT::Is64Bits ? 8 : 4;
this->_fsize = 0;
this->_msize = 0;
}
this->_entSize = 0;
this->_type = SHT_PROGBITS;
this->_flags = SHF_ALLOC;
- // Set the alignment properly depending on the target architecture
- if (context.is64Bits())
- this->_align2 = 8;
- else
- this->_align2 = 4;
+ this->_align2 = ELFT::Is64Bits ? 8 : 4;
// Minimum size for empty .eh_frame_hdr.
this->_fsize = 1 + 1 + 1 + 1 + 4;
this->_msize = this->_fsize;
: ELFLinkingContext(triple, std::unique_ptr<TargetHandlerBase>(
new X86TargetHandler(*this))) {}
- bool isLittleEndian() const override {
- return X86ELFType::TargetEndianness == llvm::support::little;
- }
-
/// \brief X86 has only two relative relocation
/// a) for supporting IFUNC relocs - R_386_IRELATIVE
/// b) for supporting relative relocs - R_386_RELATIVE
}
}
- bool isLittleEndian() const override {
- return X86_64ELFType::TargetEndianness == llvm::support::little;
- }
-
bool isCopyRelocation(const Reference &r) const override {
if (r.kindNamespace() != Reference::KindNamespace::ELF)
return false;