diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2011-12-22 22:21:47 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2011-12-22 22:21:47 +0000 |
| commit | e61724aa000611168fd774b7a297edef5dbb98a5 (patch) | |
| tree | e3e8ea9691a68cf7e72abf879079b82751c260f6 /llvm/lib | |
| parent | ea2319112f59c9395c7be0edee6e8a0d88505794 (diff) | |
| download | bcm5719-llvm-e61724aa000611168fd774b7a297edef5dbb98a5.tar.gz bcm5719-llvm-e61724aa000611168fd774b7a297edef5dbb98a5.zip | |
Move all the dependencies on X86FixupKinds.h to a single method in preparation
to moving it to lib/Target/X86.
llvm-svn: 147190
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/MC/WinCOFFObjectWriter.cpp | 61 |
1 files changed, 34 insertions, 27 deletions
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp index 484443a69aa..36e184ec511 100644 --- a/llvm/lib/MC/WinCOFFObjectWriter.cpp +++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp @@ -120,6 +120,8 @@ public: }; class WinCOFFObjectWriter : public MCObjectWriter { + unsigned getRelocType(unsigned FixupKind) const; + public: typedef std::vector<COFFSymbol*> symbols; @@ -627,6 +629,32 @@ void WinCOFFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm, } } +unsigned WinCOFFObjectWriter::getRelocType(unsigned FixupKind) const { + switch (FixupKind) { + case FK_PCRel_4: + case X86::reloc_riprel_4byte: + case X86::reloc_riprel_4byte_movq_load: + return Is64Bit ? COFF::IMAGE_REL_AMD64_REL32 : COFF::IMAGE_REL_I386_REL32; + break; + case FK_Data_4: + case X86::reloc_signed_4byte: + return Is64Bit ? COFF::IMAGE_REL_AMD64_ADDR32 : COFF::IMAGE_REL_I386_DIR32; + break; + case FK_Data_8: + if (Is64Bit) + return COFF::IMAGE_REL_AMD64_ADDR64; + else + llvm_unreachable("unsupported relocation type"); + break; + case X86::reloc_coff_secrel32: + return Is64Bit ? COFF::IMAGE_REL_AMD64_SREL32 : COFF::IMAGE_REL_I386_SECREL; + break; + default: + llvm_unreachable("unsupported relocation type"); + } +} + + void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout, const MCFragment *Fragment, @@ -695,34 +723,13 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm, if (CrossSection) FixupKind = FK_PCRel_4; - switch (FixupKind) { - case FK_PCRel_4: - case X86::reloc_riprel_4byte: - case X86::reloc_riprel_4byte_movq_load: - Reloc.Data.Type = Is64Bit ? COFF::IMAGE_REL_AMD64_REL32 - : COFF::IMAGE_REL_I386_REL32; - // FIXME: Can anyone explain what this does other than adjust for the size - // of the offset? + Reloc.Data.Type = getRelocType(FixupKind); + + // FIXME: Can anyone explain what this does other than adjust for the size + // of the offset? + if (Reloc.Data.Type == COFF::IMAGE_REL_AMD64_REL32 || + Reloc.Data.Type == COFF::IMAGE_REL_I386_REL32) FixedValue += 4; - break; - case FK_Data_4: - case X86::reloc_signed_4byte: - Reloc.Data.Type = Is64Bit ? COFF::IMAGE_REL_AMD64_ADDR32 - : COFF::IMAGE_REL_I386_DIR32; - break; - case FK_Data_8: - if (Is64Bit) - Reloc.Data.Type = COFF::IMAGE_REL_AMD64_ADDR64; - else - llvm_unreachable("unsupported relocation type"); - break; - case X86::reloc_coff_secrel32: - Reloc.Data.Type = Is64Bit ? COFF::IMAGE_REL_AMD64_SREL32 - : COFF::IMAGE_REL_I386_SECREL; - break; - default: - llvm_unreachable("unsupported relocation type"); - } coff_section->Relocations.push_back(Reloc); } |

