forked from OSchip/llvm-project
[lld][Hexagon] Add GOTREL relocations.
Add GOTREL relocation support. (S + A - GOT) Differential Revision: https://reviews.llvm.org/D66260 llvm-svn: 369258
This commit is contained in:
parent
1c1f8f215d
commit
a0a4c6b722
|
@ -100,6 +100,12 @@ RelExpr Hexagon::getRelExpr(RelType type, const Symbol &s,
|
|||
case R_HEX_B22_PCREL_X:
|
||||
case R_HEX_B32_PCREL_X:
|
||||
return R_PLT_PC;
|
||||
case R_HEX_GOTREL_11_X:
|
||||
case R_HEX_GOTREL_16_X:
|
||||
case R_HEX_GOTREL_32_6_X:
|
||||
case R_HEX_GOTREL_HI16:
|
||||
case R_HEX_GOTREL_LO16:
|
||||
return R_GOTPLTREL;
|
||||
case R_HEX_GOT_11_X:
|
||||
case R_HEX_GOT_16_X:
|
||||
case R_HEX_GOT_32_6_X:
|
||||
|
@ -198,6 +204,7 @@ void Hexagon::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {
|
|||
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:
|
||||
|
@ -205,6 +212,7 @@ void Hexagon::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {
|
|||
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:
|
||||
|
@ -213,6 +221,7 @@ void Hexagon::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {
|
|||
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 @@ void Hexagon::relocateOne(uint8_t *loc, RelType type, uint64_t val) const {
|
|||
case R_HEX_B32_PCREL_X:
|
||||
or32le(loc, applyMask(0x0fff3fff, val >> 6));
|
||||
break;
|
||||
case R_HEX_GOTREL_HI16:
|
||||
case R_HEX_HI16:
|
||||
or32le(loc, applyMask(0x00c03fff, val >> 16));
|
||||
break;
|
||||
case R_HEX_GOTREL_LO16:
|
||||
case R_HEX_LO16:
|
||||
or32le(loc, applyMask(0x00c03fff, val));
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# REQUIRES: hexagon
|
||||
# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %s -o %t.o
|
||||
# RUN: llvm-mc -filetype=obj -triple=hexagon-unknown-elf %S/Inputs/hexagon-shared.s -o %t2.o
|
||||
# RUN: ld.lld -shared %t2.o -o %t2.so
|
||||
# RUN: ld.lld -shared %t.o %t2.so -o %t3.so
|
||||
# RUN: llvm-objdump --print-imm-hex -d -j .text %t3.so | FileCheck --check-prefix=TEXT %s
|
||||
|
||||
.global foo
|
||||
foo:
|
||||
|
||||
.Lpc:
|
||||
|
||||
# R_HEX_GOTREL_LO16
|
||||
r0.l = #LO(.Lpc@GOTREL)
|
||||
# R_HEX_GOTREL_HI16
|
||||
r0.h = #HI(.Lpc@GOTREL)
|
||||
# R_HEX_GOTREL_11_X
|
||||
r0 = memw(r1+##.Lpc@GOTREL)
|
||||
# R_HEX_GOTREL_32_6_X and R_HEX_GOTREL_16_X
|
||||
r0 = ##(.Lpc@GOTREL)
|
||||
|
||||
# TEXT: r0.l = #0x0 }
|
||||
# TEXT: r0.h = #0xfffe }
|
||||
# TEXT: immext(#0xfffe0000)
|
||||
# TEXT: r0 = memw(r1+##-0x20000) }
|
||||
# TEXT: immext(#0xfffe0000)
|
||||
# TEXT: r0 = ##-0x20000 }
|
Loading…
Reference in New Issue