diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -54,6 +54,7 @@ // Hexagon Linux uses 64K pages by default. defaultMaxPageSize = 0x10000; noneRel = R_HEX_NONE; + tlsGotRel = R_HEX_TPREL_32; } uint32_t Hexagon::calcEFlags() const { @@ -129,6 +130,11 @@ case R_HEX_GOT_11_X: case R_HEX_GOT_16_X: case R_HEX_GOT_32_6_X: + case R_HEX_IE_GOT_11_X: + case R_HEX_IE_GOT_16_X: + case R_HEX_IE_GOT_32_6_X: + case R_HEX_IE_GOT_HI16: + case R_HEX_IE_GOT_LO16: return R_GOTPLT; case R_HEX_TPREL_11_X: case R_HEX_TPREL_16: @@ -232,6 +238,7 @@ or32le(loc, applyMask(0x00203fe0, val & 0x3f)); break; case R_HEX_11_X: + case R_HEX_IE_GOT_11_X: case R_HEX_GOT_11_X: case R_HEX_GOTREL_11_X: case R_HEX_TPREL_11_X: @@ -242,6 +249,7 @@ break; case R_HEX_16_X: // These relocs only have 6 effective bits. case R_HEX_IE_16_X: + case R_HEX_IE_GOT_16_X: case R_HEX_GOT_16_X: case R_HEX_GOTREL_16_X: case R_HEX_TPREL_16_X: @@ -257,6 +265,7 @@ case R_HEX_32_6_X: case R_HEX_GOT_32_6_X: case R_HEX_GOTREL_32_6_X: + case R_HEX_IE_GOT_32_6_X: case R_HEX_IE_32_6_X: case R_HEX_TPREL_32_6_X: or32le(loc, applyMask(0x0fff3fff, val >> 6)); @@ -292,12 +301,14 @@ break; case R_HEX_GOTREL_HI16: case R_HEX_HI16: + case R_HEX_IE_GOT_HI16: case R_HEX_IE_HI16: case R_HEX_TPREL_HI16: or32le(loc, applyMask(0x00c03fff, val >> 16)); break; case R_HEX_GOTREL_LO16: case R_HEX_LO16: + case R_HEX_IE_GOT_LO16: case R_HEX_IE_LO16: case R_HEX_TPREL_LO16: or32le(loc, applyMask(0x00c03fff, val)); diff --git a/lld/test/ELF/hexagon-tls-ie-got.s b/lld/test/ELF/hexagon-tls-ie-got.s new file mode 100644 --- /dev/null +++ b/lld/test/ELF/hexagon-tls-ie-got.s @@ -0,0 +1,33 @@ +# REQUIRES: hexagon +# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %p/Inputs/hexagon-tls-ie.s -o %t2.o +# RUN: ld.lld -shared %t1.o %t2.o -o %t +# RUN: llvm-objdump -d --print-imm-hex %t | FileCheck %s +# RUN: llvm-readelf -r %t | FileCheck -check-prefix=CHECK-RELA %s + + .globl _start + .type _start, @function +_start: + +# R_HEX_IEGOT_32_6_X and R_HEX_IEGOT_16_X +# CHECK: { immext(#0xfffeffc0) +# CHECK-NEXT: r2 = memw(##0xfffefff0) } + r2 = memw(##a@IEGOT) + +# R_HEX_IEGOT_LO16 +# CHECK: { r2.l = #0xfff0 } + r2.l = #a@IEGOT +# R_HEX_IEGOT_HI16 +# CHECK: { r2.h = #0xfffe } + r2.h = #a@IEGOT + +# CHECK-RELA: Relocation section '.rela.dyn' +# CHECK-RELA-NEXT: Offset Info Type Sym. Value Symbol's Name + Addend +# CHECK-RELA-NEXT:000202e4 0000023f R_HEX_TPREL_32 00000000 a + 0 +# CHECK-RELA-NEXT:000202e8 0000033f R_HEX_TPREL_32 00000004 b + 0 +# CHECK-RELA-NEXT:000202ec 0000043f R_HEX_TPREL_32 00000008 c + 0 +# CHECK-RELA-NEXT:000202f0 0000053f R_HEX_TPREL_32 0000000c d + 0 + + r2 = memw(##b@IEGOT) + r2 = memw(##c@IEGOT) + r2 = memw(##d@IEGOT)