diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:10:56 +0000 |
commit | 044eb2f6afba375a914ac9d8024f8f5142bb912e (patch) | |
tree | 1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /lib/MC/ELFObjectWriter.cpp | |
parent | eb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff) | |
download | src-044eb2f6afba375a914ac9d8024f8f5142bb912e.tar.gz src-044eb2f6afba375a914ac9d8024f8f5142bb912e.zip |
Vendor import of llvm trunk r321017:vendor/llvm/llvm-trunk-r321017
Notes
Notes:
svn path=/vendor/llvm/dist/; revision=326938
svn path=/vendor/llvm/llvm-trunk-r321017/; revision=326939; tag=vendor/llvm/llvm-trunk-r321017
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index c8dd63011943..e11eaaa30603 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -162,9 +162,10 @@ class ELFObjectWriter : public MCObjectWriter { bool ZLibStyle, unsigned Alignment); public: - ELFObjectWriter(MCELFObjectTargetWriter *MOTW, raw_pwrite_stream &OS, - bool IsLittleEndian) - : MCObjectWriter(OS, IsLittleEndian), TargetObjectWriter(MOTW) {} + ELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW, + raw_pwrite_stream &OS, bool IsLittleEndian) + : MCObjectWriter(OS, IsLittleEndian), + TargetObjectWriter(std::move(MOTW)) {} ~ELFObjectWriter() override = default; @@ -1108,7 +1109,7 @@ void ELFObjectWriter::writeRelocations(const MCAssembler &Asm, if (is64Bit()) { write(Entry.Offset); - if (TargetObjectWriter->isN64()) { + if (TargetObjectWriter->getEMachine() == ELF::EM_MIPS) { write(uint32_t(Index)); write(TargetObjectWriter->getRSsym(Entry.Type)); @@ -1131,6 +1132,23 @@ void ELFObjectWriter::writeRelocations(const MCAssembler &Asm, if (hasRelocationAddend()) write(uint32_t(Entry.Addend)); + + if (TargetObjectWriter->getEMachine() == ELF::EM_MIPS) { + if (uint32_t RType = TargetObjectWriter->getRType2(Entry.Type)) { + write(uint32_t(Entry.Offset)); + + ERE32.setSymbolAndType(0, RType); + write(ERE32.r_info); + write(uint32_t(0)); + } + if (uint32_t RType = TargetObjectWriter->getRType3(Entry.Type)) { + write(uint32_t(Entry.Offset)); + + ERE32.setSymbolAndType(0, RType); + write(ERE32.r_info); + write(uint32_t(0)); + } + } } } } @@ -1369,8 +1387,9 @@ bool ELFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl( InSet, IsPCRel); } -MCObjectWriter *llvm::createELFObjectWriter(MCELFObjectTargetWriter *MOTW, - raw_pwrite_stream &OS, - bool IsLittleEndian) { - return new ELFObjectWriter(MOTW, OS, IsLittleEndian); +std::unique_ptr<MCObjectWriter> +llvm::createELFObjectWriter(std::unique_ptr<MCELFObjectTargetWriter> MOTW, + raw_pwrite_stream &OS, bool IsLittleEndian) { + return llvm::make_unique<ELFObjectWriter>(std::move(MOTW), OS, + IsLittleEndian); } |