2 ## TYPE=<value> customizes the output section type.
4 # RUN: rm -rf %t && split-file %s %t
5 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t/a.s -o %t/a.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t/mismatch.s -o %t/mismatch.o
7 # RUN: ld.lld -T %t/a.lds %t/a.o -o %t/a
8 # RUN: llvm-readelf -S %t/a | FileCheck %s
10 # RUN: ld.lld -r -T %t/a.lds %t/a.o -o %t/a.ro
11 # RUN: llvm-readelf -S %t/a.ro | FileCheck %s
13 # CHECK: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
14 # CHECK-NEXT: [ 0] NULL [[#%x,]] [[#%x,]] 000000 00 0 0 0
15 # CHECK-NEXT: [ 1] progbits PROGBITS [[#%x,]] [[#%x,]] 000001 00 A 0 0 1
16 # CHECK-NEXT: [ 2] note NOTE [[#%x,]] [[#%x,]] 000002 00 A 0 0 1
17 # CHECK-NEXT: [ 3] nobits NOBITS [[#%x,]] [[#%x,]] 000001 00 A 0 0 1
18 # CHECK-NEXT: [ 4] init_array INIT_ARRAY [[#%x,]] [[#%x,]] 000008 00 A 0 0 1
19 # CHECK-NEXT: [ 5] fini_array FINI_ARRAY [[#%x,]] [[#%x,]] 000008 00 A 0 0 1
20 # CHECK-NEXT: [ 6] preinit_array PREINIT_ARRAY [[#%x,]] [[#%x,]] 000008 00 A 0 0 1
21 # CHECK-NEXT: [ 7] group GROUP [[#%x,]] [[#%x,]] 000004 00 A [[#SYMTAB:]] 0 1
22 # CHECK-NEXT: [ 8] expr 0x42: <unknown> [[#%x,]] [[#%x,]] 000001 00 A 0 0 1
23 # CHECK: [[[#SYMTAB]]] .symtab SYMTAB
25 # RUN: not ld.lld -T %t/a.lds %t/a.o %t/mismatch.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR1
27 # ERR1: error: section type mismatch for progbits
28 # ERR1-NEXT: >>> {{.*}}.o:(progbits): SHT_NOTE
29 # ERR1-NEXT: >>> output section progbits: SHT_PROGBITS
30 # ERR1: error: section type mismatch for expr
31 # ERR1-NEXT: >>> {{.*}}.o:(expr): Unknown
32 # ERR1-NEXT: >>> output section expr: Unknown
34 # RUN: ld.lld -T %t/a.lds %t/a.o %t/mismatch.o -o %t/mismatch --noinhibit-exec
35 # RUN: llvm-readelf -S %t/mismatch | FileCheck %s --check-prefix=MISMATCH
37 ## Mismatched progbits and expr are changed to SHT_PROGBITS.
38 # MISMATCH: progbits PROGBITS
40 # MISMATCH: expr 0x42: <unknown>
42 # RUN: not ld.lld -T %t/unknown1.lds %t/a.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN1
43 # UNKNOWN1: error: {{.*}}.lds:1: symbol not found: foo
45 ## For a symbol named SHT_*, give a better diagnostic.
46 # RUN: not ld.lld -T %t/unknown2.lds %t/a.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN2
47 # UNKNOWN2: error: {{.*}}.lds:1: unknown section type SHT_DYNAMIC
49 # RUN: not ld.lld -T %t/parseerr1.lds %t/a.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=PARSEERR1
50 # PARSEERR1: error: {{.*}}.lds:1: = expected, but got )
59 ## Compatible with TYPE = SHT_NOTE below.
60 .section note,"a",@note
65 progbits
(TYPE
=SHT_PROGBITS
) : { BYTE
(1) }
66 note
(TYPE
= SHT_NOTE
) : { BYTE
(7) *(note
) }
67 nobits
( TYPE
=SHT_NOBITS
) : { BYTE
(8) }
68 init_array
(TYPE
=SHT_INIT_ARRAY
) : { QUAD
(myinit
) }
69 fini_array
(TYPE
=SHT_FINI_ARRAY
) : { QUAD
(15) }
70 preinit_array
(TYPE
=SHT_PREINIT_ARRAY
) : { QUAD
(16) }
71 group
(TYPE
=17) : { LONG
(17) }
72 expr
(TYPE
=0x41+1) : { BYTE
(0x42) *(expr
) }
76 .section progbits,"a",@note
79 .section expr,"a",@12345
83 SECTIONS
{ err
(TYPE
=foo
) : {} }
86 SECTIONS
{ err
(TYPE
=SHT_DYNAMIC
) : {} }
89 SECTIONS
{ err
(TYPE
) : {} }