[PATCH] D66260: [lld][Hexagon] Add GOTREL relocations
Sid Manning via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 16:16:07 PDT 2019
sidneym created this revision.
sidneym added reviewers: bcain, ruiu, shankare, kparzysz.
sidneym added a project: lld.
Herald added subscribers: MaskRay, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
Add support for GOTREL relocations and test case.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D66260
Files:
lld/ELF/Arch/Hexagon.cpp
lld/test/ELF/hexagon-gotrel.s
Index: lld/test/ELF/hexagon-gotrel.s
===================================================================
--- /dev/null
+++ lld/test/ELF/hexagon-gotrel.s
@@ -0,0 +1,27 @@
+# REQUIRES: hexagon
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t
+# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %S/Inputs/hexagon-shared.s -o %t2.o
+# RUN: ld.lld -shared %t2.o -soname %t3.so -o %t3.so
+# RUN: ld.lld -shared %t %t3.so -soname %t4.so -o %t4.so
+# RUN: llvm-objdump --print-imm-hex -d -j .text %t4.so | FileCheck --check-prefix=TEXT %s
+
+.global foo
+foo:
+
+.Lpc:
+
+# R_HEX_GOTREL_LO16
+ r0.l = #LO(.Lpc at GOTREL)
+# R_HEX_GOTREL_HI16
+ r0.h = #HI(.Lpc at GOTREL)
+# R_HEX_GOTREL_11_X
+ r0 = memw(r1+##.Lpc at GOTREL)
+# R_HEX_GOTREL_32_6_X and R_HEX_GOTREL_16_X
+ r0 = ##(.Lpc at GOTREL)
+
+# TEXT: r0.l = #0x0 }
+# TEXT: r0.h = #0xfffe }
+# TEXT: immext(#0xfffe0000)
+# TEXT: r0 = memw(r1+##-0x20000) }
+# TEXT: immext(#0xfffe0000)
+# TEXT: r0 = ##-0x20000 }
Index: lld/ELF/Arch/Hexagon.cpp
===================================================================
--- lld/ELF/Arch/Hexagon.cpp
+++ lld/ELF/Arch/Hexagon.cpp
@@ -99,6 +99,12 @@
case R_HEX_B22_PCREL_X:
case R_HEX_B32_PCREL_X:
return R_PLT_PC;
+ case R_HEX_GOTREL_LO16:
+ case R_HEX_GOTREL_HI16:
+ case R_HEX_GOTREL_11_X:
+ case R_HEX_GOTREL_16_X:
+ case R_HEX_GOTREL_32_6_X:
+ return R_GOTPLTREL;
case R_HEX_GOT_11_X:
case R_HEX_GOT_16_X:
case R_HEX_GOT_32_6_X:
@@ -197,6 +203,7 @@
break;
case R_HEX_11_X:
case R_HEX_GOT_11_X:
+ case R_HEX_GOTREL_11_X:
or32le(loc, applyMask(findMaskR11(read32le(loc)), val & 0x3f));
break;
case R_HEX_12_X:
@@ -204,6 +211,7 @@
break;
case R_HEX_16_X: // These relocs only have 6 effective bits.
case R_HEX_GOT_16_X:
+ case R_HEX_GOTREL_16_X:
or32le(loc, applyMask(findMaskR16(read32le(loc)), val & 0x3f));
break;
case R_HEX_32:
@@ -212,6 +220,7 @@
break;
case R_HEX_32_6_X:
case R_HEX_GOT_32_6_X:
+ case R_HEX_GOTREL_32_6_X:
or32le(loc, applyMask(0x0fff3fff, val >> 6));
break;
case R_HEX_B9_PCREL:
@@ -240,9 +249,11 @@
or32le(loc, applyMask(0x0fff3fff, val >> 6));
break;
case R_HEX_HI16:
+ case R_HEX_GOTREL_HI16:
or32le(loc, applyMask(0x00c03fff, val >> 16));
break;
case R_HEX_LO16:
+ case R_HEX_GOTREL_LO16:
or32le(loc, applyMask(0x00c03fff, val));
break;
default:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D66260.215278.patch
Type: text/x-patch
Size: 2429 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190814/2ba5e846/attachment.bin>
More information about the llvm-commits
mailing list