From e66f45c6eb50e54af83dc563a77c9e0f4f5854cf Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 25 May 2016 04:10:14 +0000 Subject: [PATCH] Reduce code duplication. llvm-svn: 270657 --- lld/ELF/Target.cpp | 36 +++++++++++------------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/lld/ELF/Target.cpp b/lld/ELF/Target.cpp index ec88ec0774c8..79dfe0c15551 100644 --- a/lld/ELF/Target.cpp +++ b/lld/ELF/Target.cpp @@ -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);