Skip to content

Commit

Permalink
[AArch64] Add support for got relocated LDR's
Browse files Browse the repository at this point in the history
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

llvm-svn: 338673
  • Loading branch information
davemgreen committed Aug 2, 2018
1 parent dffce95 commit ea60446
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ unsigned AArch64ELFObjectWriter::getRelocType(MCContext &Ctx,
case AArch64::fixup_aarch64_ldr_pcrel_imm19:
if (SymLoc == AArch64MCExpr::VK_GOTTPREL)
return R_CLS(TLSIE_LD_GOTTPREL_PREL19);
if (SymLoc == AArch64MCExpr::VK_GOT)
return R_CLS(GOT_LD_PREL19);
return R_CLS(LD_PREL_LO19);
case AArch64::fixup_aarch64_pcrel_branch14:
return R_CLS(TSTBR14);
Expand Down
7 changes: 7 additions & 0 deletions llvm/test/MC/AArch64/arm64-elf-relocs.s
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,10 @@ trickQuestion:
// certainly be accepted when assembling.
add x3, x5, :lo12:imm
// CHECK: add x3, x5, :lo12:imm

ldr x24, #:got:sym
ldr d22, :got:sym
// CHECK: ldr x24, :got:sym
// CHECK: ldr d22, :got:sym
// CHECK-OBJ-LP64: R_AARCH64_GOT_LD_PREL19 sym
// CHECK-OBJ-LP64: R_AARCH64_GOT_LD_PREL19 sym
3 changes: 3 additions & 0 deletions llvm/test/MC/AArch64/elf-reloc-pcreladdressing.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@
adrp x5, :got:some_label
ldr x0, [x5, #:got_lo12:some_label]

ldr x0, :got:some_label

// OBJ: Relocations [
// OBJ-NEXT: Section {{.*}} .rela.text {
// OBJ-NEXT: 0x0 R_AARCH64_ADR_PREL_LO21 some_label 0x0
// OBJ-NEXT: 0x4 R_AARCH64_ADR_PREL_PG_HI21 some_label 0x0
// OBJ-NEXT: 0x8 R_AARCH64_ADR_GOT_PAGE some_label 0x0
// OBJ-NEXT: 0xC R_AARCH64_LD64_GOT_LO12_NC some_label 0x0
// OBJ-NEXT: 0x10 R_AARCH64_GOT_LD_PREL19 some_label 0x0
// OBJ-NEXT: }
// OBJ-NEXT: ]
4 changes: 4 additions & 0 deletions llvm/test/MC/AArch64/inline-asm-modifiers.s
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,17 @@ test_inline_modifier_A: // @test_inline_modifier_A
//APP
adrp x0, :gottprel:var_tlsie
//NO_APP
//APP
ldr x0, :got:var_got
//NO_APP
ret
.Ltmp2:
.size test_inline_modifier_A, .Ltmp2-test_inline_modifier_A
// CHECK: R_AARCH64_ADR_PREL_PG_HI21 var_simple
// CHECK: R_AARCH64_ADR_GOT_PAGE var_got
// CHECK: R_AARCH64_TLSDESC_ADR_PAGE21 var_tlsgd
// CHECK: R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 var_tlsie
// CHECK: R_AARCH64_GOT_LD_PREL19 var_got

.globl test_inline_modifier_wx
.type test_inline_modifier_wx,@function
Expand Down

0 comments on commit ea60446

Please sign in to comment.