1# REQUIRES: x86 2# RUN: rm -rf %t && split-file %s %t && cd %t 3# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o 4# RUN: ld.lld --default-script=def.t b.t -T a.t a.o -o out 5# RUN: llvm-readelf -Ss out | FileCheck %s 6 7# CHECK: Name 8# CHECK: .foo2 9# CHECK-NEXT: .foo0 10# CHECK-NEXT: .foo1 11# CHECK: 1: 000000000000000c 0 NOTYPE GLOBAL DEFAULT 4 _start 12# CHECK-NEXT: 2: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS b 13# CHECK-NEXT: 3: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS a 14# CHECK-EMPTY: 15 16## In the absence of --script options, the default linker script is read. 17# RUN: ld.lld --default-script def.t b.t a.o -o out1 18# RUN: llvm-readelf -Ss out1 | FileCheck %s --check-prefix=CHECK1 19# RUN: ld.lld -dT def.t b.t a.o -o out1a && cmp out1 out1a 20## If multiple -dT options are specified, the last -dT wins. 21# RUN: ld.lld -dT a.t -dT def.t b.t a.o -o out1a && cmp out1 out1a 22 23# RUN: mkdir d && cp def.t d/default.t 24# RUN: ld.lld -L d -dT default.t b.t a.o -o out1a && cmp out1 out1a 25 26# CHECK1: Name 27# CHECK1: .foo2 28# CHECK1-NEXT: .foo1 29# CHECK1-NEXT: .foo0 30# CHECK1: 1: 000000000000000c 0 NOTYPE GLOBAL DEFAULT 4 _start 31# CHECK1-NEXT: 2: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS b 32# CHECK1-NEXT: 3: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS def 33# CHECK1-EMPTY: 34 35# RUN: not ld.lld --default-script not-exist.t b.t -T a.t a.o 2>&1 | FileCheck %s --check-prefix=ERR 36# ERR: error: cannot find linker script not-exist.t 37 38#--- a.s 39.globl _start 40_start: 41 42.section .foo0,"a"; .long 0 43.section .foo1,"a"; .long 0 44.section .foo2,"a"; .long 0 45 46#--- a.t 47a = 42; 48SECTIONS { 49 .foo2 : {} 50 .foo0 : {} 51 .foo1 : {} 52} 53 54#--- b.t 55b = 42; 56 57#--- def.t 58def = 42; 59SECTIONS { 60 .foo2 : {} 61 .foo1 : {} 62 .foo0 : {} 63} 64