Index: include/llvm/Support/ELFRelocs/AArch64.def =================================================================== --- include/llvm/Support/ELFRelocs/AArch64.def +++ include/llvm/Support/ELFRelocs/AArch64.def @@ -157,7 +157,7 @@ ELF_RELOC(R_AARCH64_P32_LDST128_ABS_LO12_NC, 0x011) ELF_RELOC(R_AARCH64_P32_GOT_LD_PREL19, 0x019) ELF_RELOC(R_AARCH64_P32_ADR_GOT_PAGE, 0x01a) -ELF_RELOC(R_AARCH64_P32_LD64_GOT_LO12_NC, 0x01b) +ELF_RELOC(R_AARCH64_P32_LD32_GOT_LO12_NC, 0x01b) ELF_RELOC(R_AARCH64_P32_LD32_GOTPAGE_LO14, 0x01c) ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G1, 0x057) ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0, 0x058) Index: lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp =================================================================== --- lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp +++ lib/Target/AArch64/MCTargetDesc/AArch64ELFObjectWriter.cpp @@ -245,6 +245,16 @@ return R_CLS(TLSLE_LDST32_TPREL_LO12); if (SymLoc == AArch64MCExpr::VK_TPREL && IsNC) return R_CLS(TLSLE_LDST32_TPREL_LO12_NC); + if (SymLoc == AArch64MCExpr::VK_GOT && IsNC) { + if (IsILP32) { + return ELF::R_AARCH64_P32_LD32_GOT_LO12_NC; + } else { + Ctx.reportError(Fixup.getLoc(), + "Bad LP64 reloc: fixup_aarch64_ldst_imm12_scale4 " + "VK_GOT IsNC"); + return ELF::R_AARCH64_NONE; + } + } Ctx.reportError(Fixup.getLoc(), "invalid fixup for 32-bit load/store instruction"); @@ -253,7 +263,8 @@ if (SymLoc == AArch64MCExpr::VK_ABS && IsNC) return R_CLS(LDST64_ABS_LO12_NC); if (SymLoc == AArch64MCExpr::VK_GOT && IsNC) - return R_CLS(LD64_GOT_LO12_NC); + return IsILP32 ? ELF::R_AARCH64_P32_LD32_GOT_LO12_NC + : ELF::R_AARCH64_LD64_GOT_LO12_NC; if (SymLoc == AArch64MCExpr::VK_DTPREL && !IsNC) return R_CLS(TLSLD_LDST64_DTPREL_LO12); if (SymLoc == AArch64MCExpr::VK_DTPREL && IsNC) Index: test/MC/AArch64/adrp-relocation.s =================================================================== --- test/MC/AArch64/adrp-relocation.s +++ test/MC/AArch64/adrp-relocation.s @@ -1,4 +1,6 @@ // RUN: llvm-mc -triple=aarch64-linux-gnu -filetype=obj -o - %s| llvm-readobj -r - | FileCheck %s +// RUN: llvm-mc -target-abi=ilp32 -triple=aarch64-linux-gnu -filetype=obj \ +// RUN: -o - %s| llvm-readobj -r - | FileCheck -check-prefix=CHECK-ILP32 %s .text // These should produce an ADRP/ADD pair to calculate the address of // testfn. The important point is that LLVM shouldn't think it can deal with the @@ -16,3 +18,7 @@ // CHECK: R_AARCH64_ADR_GOT_PAGE sym // CHECK: R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 sym // CHECK: R_AARCH64_TLSDESC_ADR_PAGE21 sym +// CHECK-ILP32: R_AARCH64_P32_ADR_PREL_PG_HI21 sym +// CHECK-ILP32: R_AARCH64_P32_ADR_GOT_PAGE sym +// CHECK-ILP32: R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21 sym +// CHECK-ILP32: R_AARCH64_P32_TLSDESC_ADR_PAGE21 sym Index: test/MC/AArch64/arm32-elf-relocs.s =================================================================== --- test/MC/AArch64/arm32-elf-relocs.s +++ test/MC/AArch64/arm32-elf-relocs.s @@ -196,37 +196,37 @@ // CHECK-OBJ-ILP32 R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC sym ldr x28, [x27, :lo12:sym] - ldr d26, [x25, #:lo12:sym] + ldr d26, [x25, :lo12:sym] // CHECK: ldr x28, [x27, :lo12:sym] // CHECK: ldr d26, [x25, :lo12:sym] // CHECK-OBJ-ILP32 R_AARCH64_P32_LDST64_ABS_LO12_NC sym // CHECK-OBJ-ILP32 R_AARCH64_P32_LDST64_ABS_LO12_NC sym - ldr x24, [x23, #:got_lo12:sym] + ldr x24, [x23, :got_lo12:sym] ldr d22, [x21, :got_lo12:sym] // CHECK: ldr x24, [x23, :got_lo12:sym] // CHECK: ldr d22, [x21, :got_lo12:sym] -// CHECK-OBJ-ILP32 R_AARCH64_LD32_GOT_LO12_NC sym -// CHECK-OBJ-ILP32 R_AARCH64_LD32_GOT_LO12_NC sym +// CHECK-OBJ-ILP32 R_AARCH64_P32_LD32_GOT_LO12_NC sym +// CHECK-OBJ-ILP32 R_AARCH64_P32_LD32_GOT_LO12_NC sym ldr x24, [x23, :dtprel_lo12_nc:sym] - ldr d22, [x21, #:dtprel_lo12:sym] + ldr d22, [x21, :dtprel_lo12:sym] // CHECK: ldr x24, [x23, :dtprel_lo12_nc:sym] // CHECK: ldr d22, [x21, :dtprel_lo12:sym] // CHECK-OBJ-ILP32 R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12_NC sym // CHECK-OBJ-ILP32 R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12 sym - ldr x24, [x23, #:tprel_lo12:sym] + ldr x24, [x23, :tprel_lo12:sym] ldr d22, [x21, :tprel_lo12_nc:sym] // CHECK: ldr x24, [x23, :tprel_lo12:sym] // CHECK: ldr d22, [x21, :tprel_lo12_nc:sym] // CHECK-OBJ-ILP32 R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12 sym // CHECK-OBJ-ILP32 R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC sym -# ldr x24, [x23, :gottprel_lo12:sym] -# ldr d22, [x21, #:gottprel_lo12:sym] + ldr x24, [x23, :gottprel_lo12:sym] + ldr d22, [x21, :gottprel_lo12:sym] - ldr x24, [x23, #:tlsdesc_lo12:sym] + ldr x24, [x23, :tlsdesc_lo12:sym] ldr d22, [x21, :tlsdesc_lo12:sym] // CHECK: ldr x24, [x23, :tlsdesc_lo12:sym] // CHECK: ldr d22, [x21, :tlsdesc_lo12:sym]