[lld] r340413 - [ELF][HEXAGON] Add R_HEX_16_X relocation
Sid Manning via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 22 08:25:15 PDT 2018
Author: sidneym
Date: Wed Aug 22 08:25:15 2018
New Revision: 340413
URL: http://llvm.org/viewvc/llvm-project?rev=340413&view=rev
Log:
[ELF][HEXAGON] Add R_HEX_16_X relocation
This relocation has only 6-bits the remaining are in the extender.
Differential Revision: https://reviews.llvm.org/D50603
Modified:
lld/trunk/ELF/Arch/Hexagon.cpp
lld/trunk/test/ELF/hexagon.s
Modified: lld/trunk/ELF/Arch/Hexagon.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Arch/Hexagon.cpp?rev=340413&r1=340412&r2=340413&view=diff
==============================================================================
--- lld/trunk/ELF/Arch/Hexagon.cpp (original)
+++ lld/trunk/ELF/Arch/Hexagon.cpp Wed Aug 22 08:25:15 2018
@@ -112,6 +112,21 @@ static uint32_t findMaskR8(uint32_t Insn
return 0x00001fe0;
}
+static uint32_t findMaskR16(uint32_t Insn) {
+ if ((0xff000000 & Insn) == 0x48000000)
+ return 0x061f20ff;
+ if ((0xff000000 & Insn) == 0x49000000)
+ return 0x061f3fe0;
+ if ((0xff000000 & Insn) == 0x78000000)
+ return 0x00df3fe0;
+ if ((0xff000000 & Insn) == 0xb0000000)
+ return 0x0fe03fe0;
+
+ error("unrecognized instruction for R_HEX_16_X relocation: 0x" +
+ utohexstr(Insn));
+ return 0;
+}
+
static void or32le(uint8_t *P, int32_t V) { write32le(P, read32le(P) | V); }
void Hexagon::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
@@ -128,6 +143,9 @@ void Hexagon::relocateOne(uint8_t *Loc,
case R_HEX_12_X:
or32le(Loc, applyMask(0x000007e0, Val));
break;
+ case R_HEX_16_X: // This reloc only has 6 effective bits.
+ or32le(Loc, applyMask(findMaskR16(read32le(Loc)), Val & 0x3f));
+ break;
case R_HEX_32:
or32le(Loc, Val);
break;
Modified: lld/trunk/test/ELF/hexagon.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/hexagon.s?rev=340413&r1=340412&r2=340413&view=diff
==============================================================================
--- lld/trunk/test/ELF/hexagon.s (original)
+++ lld/trunk/test/ELF/hexagon.s Wed Aug 22 08:25:15 2018
@@ -177,3 +177,20 @@ r1:0=combine(r2,##_start);
r_hex_32:
.word _start
# CHECK: 00011000
+
+# R_HEX_16_X has 4 relocation mask variations
+# 0x48000000
+memw(##_start) = r0
+# CHECK: 4880c000 memw(##69632) = r0 }
+
+# 0x49000000
+r0 = memw(##_start)
+# CHECK: 4980c000 r0 = memw(##69632)
+
+# 0x78000000
+r0 = ##_start
+# CHECK: 7800c000 r0 = ##69632 }
+
+# 0xb0000000
+r0 = add(r1, ##_start)
+# CHECK: b001c000 r0 = add(r1,##69632) }
More information about the llvm-commits
mailing list