Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 6e63f1c

Browse files
committed
[AArch64] Add support for got relocated LDR's
As a part of adding the tiny codemodel, we need to support ldr's with :got: relocations on them. This seems to be mostly already done, just needs the relocation type support. Differential Revision: https://reviews.llvm.org/D50137 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338673 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e815ef9 commit 6e63f1c

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
169169
case AArch64::fixup_aarch64_ldr_pcrel_imm19:
170170
if (SymLoc == AArch64MCExpr::VK_GOTTPREL)
171171
return R_CLS(TLSIE_LD_GOTTPREL_PREL19);
172+
if (SymLoc == AArch64MCExpr::VK_GOT)
173+
return R_CLS(GOT_LD_PREL19);
172174
return R_CLS(LD_PREL_LO19);
173175
case AArch64::fixup_aarch64_pcrel_branch14:
174176
return R_CLS(TSTBR14);

test/MC/AArch64/arm64-elf-relocs.s

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,10 @@ trickQuestion:
269269
// certainly be accepted when assembling.
270270
add x3, x5, :lo12:imm
271271
// CHECK: add x3, x5, :lo12:imm
272+
273+
ldr x24, #:got:sym
274+
ldr d22, :got:sym
275+
// CHECK: ldr x24, :got:sym
276+
// CHECK: ldr d22, :got:sym
277+
// CHECK-OBJ-LP64: R_AARCH64_GOT_LD_PREL19 sym
278+
// CHECK-OBJ-LP64: R_AARCH64_GOT_LD_PREL19 sym

test/MC/AArch64/elf-reloc-pcreladdressing.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@
77
adrp x5, :got:some_label
88
ldr x0, [x5, #:got_lo12:some_label]
99

10+
ldr x0, :got:some_label
11+
1012
// OBJ: Relocations [
1113
// OBJ-NEXT: Section {{.*}} .rela.text {
1214
// OBJ-NEXT: 0x0 R_AARCH64_ADR_PREL_LO21 some_label 0x0
1315
// OBJ-NEXT: 0x4 R_AARCH64_ADR_PREL_PG_HI21 some_label 0x0
1416
// OBJ-NEXT: 0x8 R_AARCH64_ADR_GOT_PAGE some_label 0x0
1517
// OBJ-NEXT: 0xC R_AARCH64_LD64_GOT_LO12_NC some_label 0x0
18+
// OBJ-NEXT: 0x10 R_AARCH64_GOT_LD_PREL19 some_label 0x0
1619
// OBJ-NEXT: }
1720
// OBJ-NEXT: ]

test/MC/AArch64/inline-asm-modifiers.s

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,17 @@ test_inline_modifier_A: // @test_inline_modifier_A
6868
//APP
6969
adrp x0, :gottprel:var_tlsie
7070
//NO_APP
71+
//APP
72+
ldr x0, :got:var_got
73+
//NO_APP
7174
ret
7275
.Ltmp2:
7376
.size test_inline_modifier_A, .Ltmp2-test_inline_modifier_A
7477
// CHECK: R_AARCH64_ADR_PREL_PG_HI21 var_simple
7578
// CHECK: R_AARCH64_ADR_GOT_PAGE var_got
7679
// CHECK: R_AARCH64_TLSDESC_ADR_PAGE21 var_tlsgd
7780
// CHECK: R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 var_tlsie
81+
// CHECK: R_AARCH64_GOT_LD_PREL19 var_got
7882

7983
.globl test_inline_modifier_wx
8084
.type test_inline_modifier_wx,@function

0 commit comments

Comments
 (0)