[ELF][HEXAGON] Add R_HEX_B9_PCREL and R_HEX_B9_PCREL_X relocation support
authorSid Manning <sidneym@codeaurora.org>
Sat, 25 Aug 2018 21:25:35 +0000 (21:25 +0000)
committerSid Manning <sidneym@codeaurora.org>
Sat, 25 Aug 2018 21:25:35 +0000 (21:25 +0000)
Differential Revision: https://reviews.llvm.org/D51045

llvm-svn: 340692

lld/ELF/Arch/Hexagon.cpp
lld/test/ELF/hexagon.s

index 085320f..10096bd 100644 (file)
@@ -53,6 +53,8 @@ static uint32_t applyMask(uint32_t Mask, uint32_t Data) {
 RelExpr Hexagon::getRelExpr(RelType Type, const Symbol &S,
                             const uint8_t *Loc) const {
   switch (Type) {
+  case R_HEX_B9_PCREL:
+  case R_HEX_B9_PCREL_X:
   case R_HEX_B15_PCREL:
   case R_HEX_B15_PCREL_X:
   case R_HEX_B22_PCREL:
@@ -152,6 +154,12 @@ void Hexagon::relocateOne(uint8_t *Loc, RelType Type, uint64_t Val) const {
   case R_HEX_32_6_X:
     or32le(Loc, applyMask(0x0fff3fff, Val >> 6));
     break;
+  case R_HEX_B9_PCREL:
+    or32le(Loc, applyMask(0x003000fe, Val >> 2));
+    break;
+  case R_HEX_B9_PCREL_X:
+    or32le(Loc, applyMask(0x003000fe, Val & 0x3f));
+    break;
   case R_HEX_B15_PCREL:
     or32le(Loc, applyMask(0x00df20fe, Val >> 2));
     break;
index 53191dd..f5874c8 100644 (file)
@@ -194,3 +194,11 @@ r0 = ##_start
 # 0xb0000000
 r0 = add(r1, ##_start)
 # CHECK: b001c000   r0 = add(r1,##69632) }
+
+# R_HEX_B9_PCREL:
+{r0=#1 ; jump #_start}
+# CHECK: jump 0x11000
+
+# R_HEX_B9_PCREL_X:
+{r0=#1 ; jump ##_start}
+# CHECK: jump 0x11000