diff options
author | Sid Manning <sidneym@quicinc.com> | 2019-08-19 13:32:32 +0000 |
---|---|---|
committer | Sid Manning <sidneym@quicinc.com> | 2019-08-19 13:32:32 +0000 |
commit | a0a4c6b7224e029d736c0e2f58df1493770d93c4 (patch) | |
tree | a3ad0c34474f4b062358425536dccd7ee15fd014 | |
parent | 1c1f8f215d89f1946ec4942c0d4ce8d4bd4f33f3 (diff) | |
download | bcm5719-llvm-a0a4c6b7224e029d736c0e2f58df1493770d93c4.tar.gz bcm5719-llvm-a0a4c6b7224e029d736c0e2f58df1493770d93c4.zip |
[lld][Hexagon] Add GOTREL relocations.
Add GOTREL relocation support. (S + A - GOT)
Differential Revision: https://reviews.llvm.org/D66260
llvm-svn: 369258
-rw-r--r-- | lld/ELF/Arch/Hexagon.cpp | 11 | ||||
-rw-r--r-- | lld/test/ELF/hexagon-gotrel.s | 27 |
2 files changed, 38 insertions, 0 deletions
diff --git a/lld/ELF/Arch/Hexagon.cpp b/lld/ELF/Arch/Hexagon.cpp index e805b550a11..6e9335f3030 100644 --- a/lld/ELF/Arch/Hexagon.cpp +++ b/lld/ELF/Arch/Hexagon.cpp @@ -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; diff --git a/lld/test/ELF/hexagon-gotrel.s b/lld/test/ELF/hexagon-gotrel.s new file mode 100644 index 00000000000..52edc0dc59e --- /dev/null +++ b/lld/test/ELF/hexagon-gotrel.s @@ -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 } |