[PATCH] D50577: Add R_HEX_8_X relocation support

Sid Manning via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 10 11:39:48 PDT 2018


sidneym created this revision.
sidneym added reviewers: ruiu, kparzysz, shankare, bcain.
Herald added subscribers: arichardson, emaste.
Herald added a reviewer: espindola.

Another relocation with a non-uniform relocation mask, but just 3 in this case.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D50577

Files:
  ELF/Arch/Hexagon.cpp
  test/ELF/hexagon.s


Index: test/ELF/hexagon.s
===================================================================
--- test/ELF/hexagon.s
+++ test/ELF/hexagon.s
@@ -159,3 +159,16 @@
 # R_HEX_LO16
 r0.l = #LO(_start)
 # CHECK: r0.l = #4096
+
+# R_HEX_8_X has 3 relocation mask variations
+#0xde000000
+r0=sub(##_start,asl(r1,#4))
+# CHECK: de00c406   	r0 = sub(##69632,asl(r0,#4)) }
+
+#0x3c000000
+memw(r0+#0) = ##_start
+# CHECK: 3c40c000   	memw(r0+#0) = ##69632 }
+
+# The rest:
+r1:0=combine(r2,##_start);
+# CHECK: 7302e000   	r1:0 = combine(r2,##69632) }
Index: ELF/Arch/Hexagon.cpp
===================================================================
--- ELF/Arch/Hexagon.cpp
+++ ELF/Arch/Hexagon.cpp
@@ -104,6 +104,14 @@
   return 0;
 }
 
+static uint32_t findMaskR8(uint32_t Insn) {
+  if ((0xff000000 & Insn) == 0xde000000)
+    return 0x00e020e8;
+  if ((0xff000000 & Insn) == 0x3c000000)
+    return 0x0000207f;
+  return 0x00001fe0;
+}
+
 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 {
@@ -114,6 +122,9 @@
   case R_HEX_6_X:
     or32le(Loc, applyMask(findMaskR6(read32le(Loc)), Val));
     break;
+  case R_HEX_8_X:
+    or32le(Loc, applyMask(findMaskR8(read32le(Loc)), Val));
+    break;
   case R_HEX_12_X:
     or32le(Loc, applyMask(0x000007e0, Val));
     break;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50577.160162.patch
Type: text/x-patch
Size: 1368 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180810/08b35673/attachment.bin>


More information about the llvm-commits mailing list