Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / linkerscript / sections-nonalloc.s
bloba0669f701d8c90cbcd21db5083c9ebbcff2272a2
1 # REQUIRES: x86
2 # RUN: split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/main.s -o %t.o
5 ## Non-SHF_ALLOC sections are placed after all SHF_ALLOC sections. They will
6 ## thus not be contained in a PT_LOAD segment. data2 has a PT_LOAD segment,
7 ## even if it is preceded by a non-SHF_ALLOC section. Non-SHF_ALLOC orphan
8 ## sections have zero addresses.
9 ## NOTE: GNU ld assigns non-zero addresses to non-SHF_ALLOC non-orphan sections.
10 # RUN: ld.lld -T %t/a.lds %t.o -o %ta
11 # RUN: llvm-readelf -S -l %ta | FileCheck %s
13 # CHECK: [Nr] Name Type Address Off Size ES Flg Lk
14 # CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0
15 # CHECK-NEXT: [ 1] .bss NOBITS 0000000000000000 001000 000001 00 WA 0
16 # CHECK-NEXT: [ 2] data1 PROGBITS 0000000000000001 001001 000001 00 WA 0
17 # CHECK-NEXT: [ 3] data3 PROGBITS 0000000000000002 001002 000001 00 WA 0
18 # CHECK-NEXT: [ 4] other1 PROGBITS 0000000000000000 001008 000001 00 0
19 # CHECK-NEXT: [ 5] other2 PROGBITS 0000000000000000 001010 000001 00 0
20 ## Orphan placement places other3, .symtab, .shstrtab and .strtab after other2.
21 # CHECK-NEXT: [ 6] other3 PROGBITS 0000000000000000 001020 000001 00 0
22 # CHECK-NEXT: [ 7] .symtab SYMTAB 0000000000000000 001028 000030 18 9
23 # CHECK-NEXT: [ 8] .shstrtab STRTAB 0000000000000000 001058 00004d 00 0
24 # CHECK-NEXT: [ 9] .strtab STRTAB 0000000000000000 0010a5 000008 00 0
25 # CHECK-NEXT: [10] data2 PROGBITS 0000000000000003 001003 000001 00 WA 0
26 # CHECK-NEXT: [11] .text PROGBITS 0000000000000004 001004 000001 00 AX 0
28 # CHECK: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
29 # CHECK-NEXT: LOAD 0x001000 0x0000000000000000 0x0000000000000000 0x000004 0x000004 RW 0x1000
30 # CHECK-NEXT: LOAD 0x001004 0x0000000000000004 0x0000000000000004 0x000001 0x000001 R E 0x1000
31 # CHECK-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0
33 # RUN: ld.lld -T %t/b.lds %t.o -o %tb
34 # RUN: llvm-readelf -S -l %tb | FileCheck %s --check-prefix=CHECK1
36 # CHECK1: [Nr] Name Type Address Off Size ES Flg Lk
37 # CHECK1-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0
38 # CHECK1-NEXT: [ 1] .text PROGBITS 00000000000000b0 0000b0 000001 00 AX 0
39 # CHECK1-NEXT: [ 2] .bss NOBITS 00000000000000b1 0000b1 000001 00 WA 0
40 # CHECK1-NEXT: [ 3] data1 PROGBITS 00000000000000b2 0000b2 000001 00 WA 0
41 # CHECK1-NEXT: [ 4] data3 PROGBITS 00000000000000b3 0000b3 000001 00 WA 0
42 # CHECK1-NEXT: [ 5] other1 PROGBITS 0000000000000000 0000b8 000001 00 0
43 # CHECK1-NEXT: [ 6] other2 PROGBITS 0000000000000000 0000c0 000001 00 0
44 # CHECK1-NEXT: [ 7] other3 PROGBITS 0000000000000000 0000d0 000001 00 0
45 # CHECK1-NEXT: [ 8] .symtab SYMTAB 0000000000000000 0000d8 000030 18 10
46 # CHECK1-NEXT: [ 9] .shstrtab STRTAB 0000000000000000 000108 00004d 00 0
47 # CHECK1-NEXT: [10] .strtab STRTAB 0000000000000000 000155 000008 00 0
48 # CHECK1-NEXT: [11] data2 PROGBITS 00000000000000b4 0000b4 000001 00 WA 0
49 # CHECK1: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
50 # CHECK1-NEXT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0000b5 0x0000b5 RWE 0x1000
51 # CHECK1-NEXT: 0x60000000 0x0000b8 0x0000000000000000 0x0000000000000000 0x000009 0x000001 0x8
53 #--- a.lds
54 SECTIONS {
55 .bss : { *(.bss) }
56 data1 : { *(data1) }
57 other1 : { *(other1) }
58 other2 : { *(other2) }
59 data2 : { *(data2) }
60 .text : { *(.text) }
61 /DISCARD/ : { *(.comment) }
64 #--- b.lds
65 PHDRS {
66 text PT_LOAD FILEHDR PHDRS;
67 foo 0x60000000 FLAGS (0);
69 SECTIONS {
70 . = SIZEOF_HEADERS;
71 .text : { *(.text) } : text
72 .bss : { *(.bss) } : text
73 data1 : { *(data1) } : text
74 other1 : { *(other1) } : foo
75 other2 : { *(other2) } : foo
76 data2 : { *(data1) } : text
77 /DISCARD/ : { *(.comment) }
80 #--- main.s
81 .globl _start
82 _start: nop
83 .section data1,"aw"; .byte 0
84 .section data2,"aw"; .byte 0
85 .section data3,"aw"; .byte 0
86 .bss; .byte 0
88 .section other1; .p2align 2; .byte 0
89 .section other2; .p2align 3; .byte 0
90 .section other3; .p2align 4; .byte 0