1# REQUIRES: loongarch 2# RUN: rm -rf %t && split-file %s %t 3 4# RUN: yaml2obj %t/blob.yaml -o %t/blob.o 5# RUN: yaml2obj %t/v0-lp64d.yaml -o %t/v0-lp64d.o 6# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnu %t/start.s -o %t/v1-lp64d.o 7# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnusf %t/start.s -o %t/v1-lp64s.o 8# RUN: llvm-mc --filetype=obj --triple=loongarch64-unknown-gnu %t/bar.s -o %t/v1-b-lp64d.o 9 10## Check that binary input results in e_flags=0 output. 11# RUN: ld.lld -m elf64loongarch -b binary %t/blob.bin -o %t/blob.out 12# RUN: llvm-readobj -h %t/blob.out | FileCheck --check-prefix=EMPTY %s 13# EMPTY: Flags [ 14# EMPTY-NEXT: ] 15 16## Check that interlink between e_flags=0 and normal input (that contain code) 17## is allowed. 18## Also check that the e_flags logic work as intended regardless of input file 19## order. 20# RUN: ld.lld %t/blob.o %t/v1-lp64d.o -o %t/v1-lp64d.out 21# RUN: ld.lld %t/v1-lp64s.o %t/blob.o -o %t/v1-lp64s.out 22# RUN: llvm-readobj -h %t/v1-lp64d.out | FileCheck --check-prefix=V1-LP64D %s 23# RUN: llvm-readobj -h %t/v1-lp64s.out | FileCheck --check-prefix=V1-LP64S %s 24# V1-LP64D: Flags [ (0x43) 25# V1-LP64S: Flags [ (0x41) 26 27## Check that interlink between different ABIs is disallowed. 28# RUN: not ld.lld %t/v1-lp64s.o %t/v1-b-lp64d.o -o /dev/null 2>&1 | FileCheck -DFILE1=%t/v1-b-lp64d.o -DFILE2=%t/v1-lp64s.o --check-prefix=INTERLINK-ERR %s 29# INTERLINK-ERR: error: [[FILE1]]: cannot link object files with different ABI from [[FILE2]] 30 31## Check that interlink between different object ABI versions is disallowed. 32# RUN: not ld.lld %t/v0-lp64d.o %t/v1-b-lp64d.o %t/blob.o -o /dev/null 2>&1 | FileCheck -DFILE=%t/v0-lp64d.o --check-prefix=VERSION-ERR %s 33# VERSION-ERR: error: [[FILE]]: unsupported object file ABI version 34 35#--- blob.bin 36BLOB 37 38#--- blob.yaml 39--- !ELF 40FileHeader: 41 Class: ELFCLASS64 42 Data: ELFDATA2LSB 43 Type: ET_REL 44 Machine: EM_LOONGARCH 45 SectionHeaderStringTable: .strtab 46Sections: 47 - Name: .data 48 Type: SHT_PROGBITS 49 Flags: [ SHF_WRITE, SHF_ALLOC ] 50 AddressAlign: 0x1 51 Content: 424C4F42 52Symbols: 53 - Name: blob 54 Section: .data 55 Binding: STB_GLOBAL 56 57#--- v0-lp64d.yaml 58--- !ELF 59FileHeader: 60 Class: ELFCLASS64 61 Data: ELFDATA2LSB 62 Type: ET_REL 63 Machine: EM_LOONGARCH 64 Flags: [ EF_LOONGARCH_ABI_DOUBLE_FLOAT ] 65 SectionHeaderStringTable: .strtab 66Sections: 67 - Name: .text 68 Type: SHT_PROGBITS 69 Flags: [ SHF_ALLOC, SHF_EXECINSTR ] 70 AddressAlign: 0x4 71 Content: 0000a002 72 73#--- start.s 74.global _start 75_start: 76 la $a0, blob 77 ld.b $a0, $a0, 0 78 li.w $a7, 94 79 syscall 0 80 81#--- bar.s 82bar: 83 move $a0, $zero 84 ret 85