Reduce code duplication.

llvm-svn: 270657
This commit is contained in:
Rui Ueyama 2016-05-25 04:10:14 +00:00
parent b12b158f20
commit e66f45c6eb
1 changed files with 11 additions and 25 deletions

View File

@ -700,15 +700,6 @@ void X86_64TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
case R_X86_64_32S:
case R_X86_64_TPOFF32:
case R_X86_64_GOT32:
checkInt<32>(Val, Type);
write32le(Loc, Val);
break;
case R_X86_64_64:
case R_X86_64_DTPOFF64:
case R_X86_64_SIZE64:
case R_X86_64_PC64:
write64le(Loc, Val);
break;
case R_X86_64_GOTPCREL:
case R_X86_64_GOTPCRELX:
case R_X86_64_REX_GOTPCRELX:
@ -722,6 +713,12 @@ void X86_64TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
checkInt<32>(Val, Type);
write32le(Loc, Val);
break;
case R_X86_64_64:
case R_X86_64_DTPOFF64:
case R_X86_64_SIZE64:
case R_X86_64_PC64:
write64le(Loc, Val);
break;
default:
fatal("unrecognized reloc " + Twine(Type));
}
@ -1075,14 +1072,17 @@ void AArch64TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
uint64_t Val) const {
switch (Type) {
case R_AARCH64_ABS16:
case R_AARCH64_PREL16:
checkIntUInt<16>(Val, Type);
write16le(Loc, Val);
break;
case R_AARCH64_ABS32:
case R_AARCH64_PREL32:
checkIntUInt<32>(Val, Type);
write32le(Loc, Val);
break;
case R_AARCH64_ABS64:
case R_AARCH64_PREL64:
write64le(Loc, Val);
break;
case R_AARCH64_ADD_ABS_LO12_NC:
@ -1093,6 +1093,8 @@ void AArch64TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
or32le(Loc, (Val & 0xFFF) << 10);
break;
case R_AARCH64_ADR_GOT_PAGE:
case R_AARCH64_ADR_PREL_PG_HI21:
case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
checkInt<33>(Val, Type);
updateAArch64Addr(Loc, (Val >> 12) & 0x1FFFFF); // X[32:12]
break;
@ -1100,11 +1102,6 @@ void AArch64TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
checkInt<21>(Val, Type);
updateAArch64Addr(Loc, Val & 0x1FFFFF);
break;
case R_AARCH64_ADR_PREL_PG_HI21:
case R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21:
checkInt<33>(Val, Type);
updateAArch64Addr(Loc, (Val >> 12) & 0x1FFFFF); // X[32:12]
break;
case R_AARCH64_CALL26:
case R_AARCH64_JUMP26:
checkInt<28>(Val, Type);
@ -1134,17 +1131,6 @@ void AArch64TargetInfo::relocateOne(uint8_t *Loc, uint32_t Type,
case R_AARCH64_LDST64_ABS_LO12_NC:
or32le(Loc, (Val & 0xFF8) << 7);
break;
case R_AARCH64_PREL16:
checkIntUInt<16>(Val, Type);
write16le(Loc, Val);
break;
case R_AARCH64_PREL32:
checkIntUInt<32>(Val, Type);
write32le(Loc, Val);
break;
case R_AARCH64_PREL64:
write64le(Loc, Val);
break;
case R_AARCH64_TSTBR14:
checkInt<16>(Val, Type);
or32le(Loc, (Val & 0xFFFC) << 3);