}
void AArch64::writeGotPlt(uint8_t *buf, const Symbol &) const {
- write64le(buf, in.plt->getVA());
+ write64(buf, in.plt->getVA());
}
void AArch64::writePltHeader(uint8_t *buf) const {
case R_AARCH64_ABS16:
case R_AARCH64_PREL16:
checkIntUInt(loc, val, 16, rel);
- write16le(loc, val);
+ write16(loc, val);
break;
case R_AARCH64_ABS32:
case R_AARCH64_PREL32:
checkIntUInt(loc, val, 32, rel);
- write32le(loc, val);
+ write32(loc, val);
break;
case R_AARCH64_PLT32:
checkInt(loc, val, 32, rel);
- write32le(loc, val);
+ write32(loc, val);
break;
case R_AARCH64_ABS64:
case R_AARCH64_PREL64:
- write64le(loc, val);
+ write64(loc, val);
break;
case R_AARCH64_ADD_ABS_LO12_NC:
or32AArch64Imm(loc, val);
StringSwitch<std::pair<ELFKind, uint16_t>>(s)
.Cases("aarch64elf", "aarch64linux", "aarch64_elf64_le_vec",
{ELF64LEKind, EM_AARCH64})
+ .Cases("aarch64elfb", "aarch64linuxb", {ELF64BEKind, EM_AARCH64})
.Cases("armelf", "armelf_linux_eabi", {ELF32LEKind, EM_ARM})
.Case("elf32_x86_64", {ELF32LEKind, EM_X86_64})
.Cases("elf32btsmip", "elf32btsmipn32", {ELF32BEKind, EM_MIPS})
static uint16_t getBitcodeMachineKind(StringRef path, const Triple &t) {
switch (t.getArch()) {
case Triple::aarch64:
+ case Triple::aarch64_be:
return EM_AARCH64;
case Triple::amdgcn:
case Triple::r600:
.Case("elf32-x86-64", {ELF32LEKind, EM_X86_64})
.Case("elf64-aarch64", {ELF64LEKind, EM_AARCH64})
.Case("elf64-littleaarch64", {ELF64LEKind, EM_AARCH64})
+ .Case("elf64-bigaarch64", {ELF64BEKind, EM_AARCH64})
.Case("elf32-powerpc", {ELF32BEKind, EM_PPC})
.Case("elf32-powerpcle", {ELF32LEKind, EM_PPC})
.Case("elf64-powerpc", {ELF64BEKind, EM_PPC64})
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs255.s -o %t255.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs257.s -o %t257.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/abs256.s -o %t256.be.o
.globl _start
_start:
// RUN: ld.lld %t.o %t256.o -o %t
// RUN: llvm-objdump -s --section=.data %t | FileCheck %s --check-prefixes=CHECK,LE
+// RUN: ld.lld %t.be.o %t256.be.o -o %t.be
+// RUN: llvm-objdump -s --section=.data %t.be | FileCheck %s --check-prefixes=CHECK,BE
// CHECK: Contents of section .data:
// 220158: S = 0x100, A = 0xfeff
// 22015c: S = 0x100, A = -0x8100
// S + A = 0x8000
// LE-NEXT: 220158 ffff0080
+// BE-NEXT: 220158 ffff8000
// RUN: not ld.lld %t.o %t255.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
// OVERFLOW1: relocation R_AARCH64_ABS16 out of range: -32769 is not in [-32768, 65535]; references foo
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs255.s -o %t255.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs257.s -o %t257.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/abs256.s -o %t256.be.o
.globl _start
_start:
// RUN: ld.lld %t.o %t256.o -o %t
// RUN: llvm-objdump -s --section=.data %t | FileCheck %s --check-prefixes=CHECK,LE
+// RUN: ld.lld %t.be.o %t256.be.o -o %t.be
+// RUN: llvm-objdump -s --section=.data %t.be | FileCheck %s --check-prefixes=CHECK,BE
// CHECK: Contents of section .data:
// 220158: S = 0x100, A = 0xfffffeff
// 22015c: S = 0x100, A = -0x80000100
// S + A = 0x80000000
// LE-NEXT: 220158 ffffffff 00000080
+// BE-NEXT: 220158 ffffffff 80000000
// RUN: not ld.lld %t.o %t255.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
// OVERFLOW1: relocation R_AARCH64_ABS32 out of range: -2147483649 is not in [-2147483648, 4294967295]; references foo
// RUN: ld.lld %t.o %t256.o -o %t
// RUN: llvm-objdump -s %t | FileCheck %s --check-prefixes=CHECK,LE
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/abs256.s -o %t256.be.o
+// RUN: ld.lld %t.be.o %t256.be.o -o %t.be
+// RUN: llvm-objdump -s %t.be | FileCheck %s --check-prefixes=CHECK,BE
+
.globl _start
_start:
.section .R_AARCH64_ABS64, "ax",@progbits
// S + A = 0x124
// CHECK: Contents of section .R_AARCH64_ABS64:
// LE-NEXT: 210120 24010000 00000000
+// BE-NEXT: 210120 00000000 00000124
.section .R_AARCH64_PREL64, "ax",@progbits
.xword foo - . + 0x24
// S + A - P = 0x100 + 0x24 - 0x210128 = 0xffffffffffdefffc
// CHECK: Contents of section .R_AARCH64_PREL64:
// LE-NEXT: 210128 fcffdeff ffffffff
+// BE-NEXT: 210128 ffffffff ffdefffc
// RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT
// RUN: llvm-readobj --dynamic-table -r %tout | FileCheck %s
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/shared2.s -o %t1.be.o
+// RUN: ld.lld %t1.be.o --shared --soname=t.so -o %t.be.so
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+// RUN: ld.lld --hash-style=sysv %t.be.so %t.be.o -o %t.be
+// RUN: llvm-objdump -d --no-show-raw-insn %t.be | FileCheck %s --check-prefix=DISASM
+// RUN: llvm-objdump -s %t.be | FileCheck %s --check-prefix=GOTPLT_BE
+// RUN: llvm-readobj --dynamic-table -r %t.be | FileCheck %s
+
// Check that the PLTRELSZ tag does not include the IRELATIVE relocations
// CHECK: DynamicSection [
// CHECK: 0x0000000000000008 RELASZ 48 (bytes)
// GOTPLT-NEXT: 230460 f0022100 00000000 00000000 00000000
// GOTPLT-NEXT: 230470 00000000 00000000
+// GOTPLT_BE: Contents of section .got.plt:
+// GOTPLT_BE-NEXT: 230440 00000000 00000000 00000000 00000000
+// GOTPLT_BE-NEXT: 230450 00000000 00000000 00000000 002102f0
+// GOTPLT_BE-NEXT: 230460 00000000 002102f0 00000000 00000000
+// GOTPLT_BE-NEXT: 230470 00000000 00000000
+
// Check that a PLT header is written and the ifunc entries appear last
// DISASM: Disassembly of section .text:
// DISASM-EMPTY:
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs255.s -o %t255.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs257.s -o %t257.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/abs256.s -o %t256.be.o
.globl _start
_start:
// if it is already fixed. Then, update addends accordingly.
// RUN: ld.lld -z max-page-size=4096 %t.o %t256.o -o %t
// RUN: llvm-objdump -s --section=.data %t | FileCheck %s --check-prefixes=CHECK,LE
+// RUN: ld.lld -z max-page-size=4096 %t.be.o %t256.be.o -o %t.be
+// RUN: llvm-objdump -s --section=.data %t.be | FileCheck %s --check-prefixes=CHECK,BE
// CHECK: Contents of section .data:
// 202158: S = 0x100, A = 0x212157, P = 0x202158
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs255.s -o %t255.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs257.s -o %t257.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/abs256.s -o %t256.be.o
.globl _start
_start:
// if it is already fixed. Then, update addends accordingly.
// RUN: ld.lld -z max-page-size=4096 %t.o %t256.o -o %t
// RUN: llvm-objdump -s --section=.data %t | FileCheck %s --check-prefixes=CHECK,LE
+// RUN: ld.lld -z max-page-size=4096 %t.be.o %t256.be.o -o %t.be
+// RUN: llvm-objdump -s --section=.data %t.be | FileCheck %s --check-prefixes=CHECK,BE
// CHECK: Contents of section .data:
// 202158: S = 0x100, A = 0x100202057, P = 0x202158
// 20215c: S = 0x100, A = -0x7fdfdfa4, P = 0x20215c
// S + A - P = 0x80000000
// LE-NEXT: 202158 ffffffff 00000080
+// BE-NEXT: 202158 ffffffff 80000000
// RUN: not ld.lld -z max-page-size=4096 %t.o %t255.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
// OVERFLOW1: relocation R_AARCH64_PREL32 out of range: -2147483649 is not in [-2147483648, 4294967295]; references foo
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs255.s -o %t255.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs256.s -o %t256.o
// RUN: llvm-mc -filetype=obj -triple=aarch64 %S/Inputs/abs257.s -o %t257.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+// RUN: llvm-mc -filetype=obj -triple=aarch64_be %S/Inputs/abs256.s -o %t256.be.o
/// Check for overflow with a R_AACH64_PLT32 relocation.
// RUN: ld.lld -z max-page-size=4096 %t.o %t256.o -o %t2
-// RUN: llvm-objdump -s --section=.data %t2 | FileCheck %s
+// RUN: llvm-objdump -s --section=.data %t2 | FileCheck %s --check-prefixes=CHECK,LE
+// RUN: ld.lld -z max-page-size=4096 %t.be.o %t256.be.o -o %t2.be
+// RUN: llvm-objdump -s --section=.data %t2.be | FileCheck %s --check-prefixes=CHECK,BE
// CHECK: Contents of section .data:
/// 202158: S = 0x100, A = 0x80202057, P = 0x202158
/// S + A - P = 0x80000000
/// 202160: S = 0x100, A = 0, P = 0x202160
/// S + A - P = 0xffdfdfa0
-// CHECK-NEXT: 202158 ffffff7f 00000080 a0dfdfff
+// LE-NEXT: 202158 ffffff7f 00000080 a0dfdfff
+// BE-NEXT: 202158 7fffffff 80000000 ffdfdfa0
// RUN: not ld.lld -z max-page-size=4096 %t.o %t255.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=OVERFLOW1
// OVERFLOW1: relocation R_AARCH64_PLT32 out of range: -2147483649 is not in [-2147483648, 2147483647]; references foo
# RUN: ld.lld -m aarch64_elf64_le_vec %t.o -o %taosp
# RUN: llvm-readobj --file-headers %taosp | FileCheck --check-prefixes=AARCH64,LE %s
+# RUN: llvm-mc -filetype=obj -triple=aarch64_be %s -o %t.be.o
+# RUN: ld.lld %t.be.o -o %t
+# RUN: llvm-readobj --file-headers %t | FileCheck --check-prefixes=AARCH64,BE %s
+# RUN: ld.lld -m aarch64linuxb %t.be.o -o %t1.be
+# RUN: llvm-readobj --file-headers %t1.be | FileCheck --check-prefixes=AARCH64,BE %s
+# RUN: ld.lld -m aarch64elfb %t.be.o -o %t2.be
+# RUN: llvm-readobj --file-headers %t2.be | FileCheck --check-prefixes=AARCH64,BE %s
+# RUN: echo 'OUTPUT_FORMAT(elf64-bigaarch64)' > %t.script
+# RUN: ld.lld %t.script %t.be.o -o %t3.be
+# RUN: llvm-readobj --file-headers %t3.be | FileCheck --check-prefixes=AARCH64,BE %s
+
# AARCH64: ElfHeader {
# AARCH64-NEXT: Ident {
# AARCH64-NEXT: Magic: (7F 45 4C 46)
# AARCH64-NEXT: Class: 64-bit (0x2)
# LE-NEXT: DataEncoding: LittleEndian (0x1)
+# BE-NEXT: DataEncoding: BigEndian (0x2)
# AARCH64-NEXT: FileVersion: 1
# AARCH64-NEXT: OS/ABI: SystemV (0x0)
# AARCH64-NEXT: ABIVersion: 0
--- /dev/null
+; REQUIRES: aarch64
+;; Test we can infer the e_machine value EM_AARCH64 from a bitcode file.
+
+; RUN: split-file %s %t
+; RUN: llvm-as %t/le.s -o %t/le.o
+; RUN: ld.lld %t/le.o -o %t/le
+; RUN: llvm-readobj -h %t/le | FileCheck %s --check-prefixes=CHECK,LE
+
+; RUN: llvm-as %t/be.s -o %t/be.o
+; RUN: ld.lld %t/be.o -o %t/be
+; RUN: llvm-readobj -h %t/be | FileCheck %s --check-prefixes=CHECK,BE
+
+; LE: DataEncoding: LittleEndian
+; BE: DataEncoding: BigEndian
+; CHECK: Machine: EM_AARCH64
+
+;--- le.s
+target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64-unknown-linux-gnu"
+
+define void @_start() {
+entry:
+ ret void
+}
+
+;--- be.s
+target datalayout = "E-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
+target triple = "aarch64_be-unknown-linux-gnu"
+
+define void @_start() {
+entry:
+ ret void
+}