mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 20:59:51 +00:00
Move all the dependencies on X86FixupKinds.h to a single method in preparation
to moving it to lib/Target/X86. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147190 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4050bc4cab
commit
b156c5d376
@ -120,6 +120,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class WinCOFFObjectWriter : public MCObjectWriter {
|
class WinCOFFObjectWriter : public MCObjectWriter {
|
||||||
|
unsigned getRelocType(unsigned FixupKind) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef std::vector<COFFSymbol*> symbols;
|
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,
|
void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
||||||
const MCAsmLayout &Layout,
|
const MCAsmLayout &Layout,
|
||||||
const MCFragment *Fragment,
|
const MCFragment *Fragment,
|
||||||
@ -695,34 +723,13 @@ void WinCOFFObjectWriter::RecordRelocation(const MCAssembler &Asm,
|
|||||||
if (CrossSection)
|
if (CrossSection)
|
||||||
FixupKind = FK_PCRel_4;
|
FixupKind = FK_PCRel_4;
|
||||||
|
|
||||||
switch (FixupKind) {
|
Reloc.Data.Type = getRelocType(FixupKind);
|
||||||
case FK_PCRel_4:
|
|
||||||
case X86::reloc_riprel_4byte:
|
// FIXME: Can anyone explain what this does other than adjust for the size
|
||||||
case X86::reloc_riprel_4byte_movq_load:
|
// of the offset?
|
||||||
Reloc.Data.Type = Is64Bit ? COFF::IMAGE_REL_AMD64_REL32
|
if (Reloc.Data.Type == COFF::IMAGE_REL_AMD64_REL32 ||
|
||||||
: COFF::IMAGE_REL_I386_REL32;
|
Reloc.Data.Type == COFF::IMAGE_REL_I386_REL32)
|
||||||
// FIXME: Can anyone explain what this does other than adjust for the size
|
|
||||||
// of the offset?
|
|
||||||
FixedValue += 4;
|
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);
|
coff_section->Relocations.push_back(Reloc);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user