2018-10-23 09:19:18 +08:00
|
|
|
# REQUIRES: aarch64
|
2021-02-07 03:50:57 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o
|
|
|
|
# RUN: ld.lld %t.o -o %t
|
|
|
|
# RUN: llvm-readobj --file-headers %t | FileCheck --check-prefixes=AARCH64,LE %s
|
|
|
|
# RUN: ld.lld -m aarch64linux %t.o -o %t1
|
|
|
|
# RUN: llvm-readobj --file-headers %t1 | FileCheck --check-prefixes=AARCH64,LE %s
|
|
|
|
# RUN: ld.lld -m aarch64elf %t.o -o %t2
|
|
|
|
# RUN: llvm-readobj --file-headers %t2 | FileCheck --check-prefixes=AARCH64,LE %s
|
|
|
|
# RUN: echo 'OUTPUT_FORMAT(elf64-littleaarch64)' > %t.script
|
|
|
|
# RUN: ld.lld %t.script %t.o -o %t3
|
|
|
|
# RUN: llvm-readobj --file-headers %t3 | FileCheck --check-prefixes=AARCH64,LE %s
|
|
|
|
|
2021-02-09 00:55:28 +08:00
|
|
|
# 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
|
|
|
|
|
2021-02-09 02:34:57 +08:00
|
|
|
## Test OUTPUT_FORMAT(default, big, little).
|
|
|
|
# RUN: echo 'OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", "elf64-littleaarch64")' > %t.script
|
|
|
|
# RUN: ld.lld -EL -T %t.script %t.o -o %t4.le
|
|
|
|
# RUN: llvm-readobj --file-headers %t4.le | FileCheck --check-prefixes=AARCH64,LE %s
|
|
|
|
# RUN: not ld.lld -EB -T %t.script %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR_BE %s
|
|
|
|
|
|
|
|
# RUN: not ld.lld -T %t.script %t.be.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR_LE %s
|
|
|
|
# RUN: not ld.lld -EL -T %t.script %t.be.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR_LE %s
|
|
|
|
# RUN: ld.lld -EB -T %t.script %t.be.o -o %t4.be
|
|
|
|
# RUN: llvm-readobj --file-headers %t4.be | FileCheck --check-prefixes=AARCH64,BE %s
|
|
|
|
|
|
|
|
# ERR_LE: error: {{.*}}.o is incompatible with elf64-littleaarch64
|
|
|
|
# ERR_BE: error: {{.*}}.o is incompatible with elf64-bigaarch64
|
|
|
|
|
2018-10-23 09:19:18 +08:00
|
|
|
# AARCH64: ElfHeader {
|
|
|
|
# AARCH64-NEXT: Ident {
|
|
|
|
# AARCH64-NEXT: Magic: (7F 45 4C 46)
|
|
|
|
# AARCH64-NEXT: Class: 64-bit (0x2)
|
2021-02-07 03:50:57 +08:00
|
|
|
# LE-NEXT: DataEncoding: LittleEndian (0x1)
|
2021-02-09 00:55:28 +08:00
|
|
|
# BE-NEXT: DataEncoding: BigEndian (0x2)
|
2018-10-23 09:19:18 +08:00
|
|
|
# AARCH64-NEXT: FileVersion: 1
|
|
|
|
# AARCH64-NEXT: OS/ABI: SystemV (0x0)
|
|
|
|
# AARCH64-NEXT: ABIVersion: 0
|
|
|
|
# AARCH64-NEXT: Unused: (00 00 00 00 00 00 00)
|
|
|
|
# AARCH64-NEXT: }
|
|
|
|
# AARCH64-NEXT: Type: Executable (0x2)
|
|
|
|
# AARCH64-NEXT: Machine: EM_AARCH64 (0xB7)
|
|
|
|
# AARCH64-NEXT: Version: 1
|
|
|
|
# AARCH64-NEXT: Entry:
|
|
|
|
# AARCH64-NEXT: ProgramHeaderOffset: 0x40
|
|
|
|
# AARCH64-NEXT: SectionHeaderOffset:
|
|
|
|
# AARCH64-NEXT: Flags [ (0x0)
|
|
|
|
# AARCH64-NEXT: ]
|
|
|
|
|
2021-02-07 03:50:57 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %tfbsd.o
|
|
|
|
# RUN: echo 'OUTPUT_FORMAT(elf64-aarch64-freebsd)' > %tfbsd.script
|
|
|
|
# RUN: ld.lld %tfbsd.script %tfbsd.o -o %tfbsd
|
|
|
|
# RUN: llvm-readobj --file-headers %tfbsd | FileCheck --check-prefix=AARCH64-FBSD %s
|
Recognize FreeBSD specific BFD names in OUTPUT_FORMAT
Summary:
After rLLD344952 ("Add OUTPUT_FORMAT linker script directive support"),
using BFD names such as `elf64-x86-64-freebsd` the `OUTPUT_FORMAT`
linker script command does not work anymore, resulting in errors like:
```
ld: error: /home/dim/src/clang800-import/stand/efi/loader/arch/amd64/ldscript.amd64:2: unknown output format name: elf64-x86-64-freebsd
>>> OUTPUT_FORMAT("elf64-x86-64-freebsd", "elf64-x86-64-freebsd", "elf64-x86-64-freebsd")
>>> ^
```
To fix this, recognize a `-freebsd` suffix in BFD names, and also set
`Configuration::OSABI` to `ELFOSABI_FREEBSD` for those cases.
Add and/or update several test cases to check for the correct results of
these new `OUTPUT_FORMAT` arguments.
Reviewers: ruiu, atanasyan, grimar, hokein, emaste, espindola
Reviewed By: ruiu
Subscribers: nemanjai, javed.absar, arichardson, krytarowski, kristof.beyls, kbarton, llvm-commits
Differential Revision: https://reviews.llvm.org/D57283
llvm-svn: 352606
2019-01-30 14:31:52 +08:00
|
|
|
# AARCH64-FBSD: ElfHeader {
|
|
|
|
# AARCH64-FBSD-NEXT: Ident {
|
|
|
|
# AARCH64-FBSD-NEXT: Magic: (7F 45 4C 46)
|
|
|
|
# AARCH64-FBSD-NEXT: Class: 64-bit (0x2)
|
|
|
|
# AARCH64-FBSD-NEXT: DataEncoding: LittleEndian (0x1)
|
|
|
|
# AARCH64-FBSD-NEXT: FileVersion: 1
|
|
|
|
# AARCH64-FBSD-NEXT: OS/ABI: FreeBSD (0x9)
|
|
|
|
# AARCH64-FBSD-NEXT: ABIVersion: 0
|
|
|
|
# AARCH64-FBSD-NEXT: Unused: (00 00 00 00 00 00 00)
|
|
|
|
# AARCH64-FBSD-NEXT: }
|
|
|
|
# AARCH64-FBSD-NEXT: Type: Executable (0x2)
|
|
|
|
# AARCH64-FBSD-NEXT: Machine: EM_AARCH64 (0xB7)
|
|
|
|
# AARCH64-FBSD-NEXT: Version: 1
|
|
|
|
# AARCH64-FBSD-NEXT: Entry:
|
|
|
|
# AARCH64-FBSD-NEXT: ProgramHeaderOffset: 0x40
|
|
|
|
# AARCH64-FBSD-NEXT: SectionHeaderOffset:
|
|
|
|
# AARCH64-FBSD-NEXT: Flags [ (0x0)
|
|
|
|
# AARCH64-FBSD-NEXT: ]
|
|
|
|
|
2018-10-23 09:19:18 +08:00
|
|
|
.globl _start
|
|
|
|
_start:
|