xref: /llvm-project/lld/test/ELF/linkerscript/empty-synthetic-removed-flags.s (revision a40f651a065ef28fee17bc1f22cce08247eff950)
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3# RUN: echo "SECTIONS { .foo : { *(.foo) } .bar : { *(.got.plt) BYTE(0x11) }}" > %t.script
4# RUN: ld.lld -o %t --script %t.script %t.o
5# RUN: llvm-readobj -S %t | FileCheck %s
6
7## We have ".got.plt" synthetic section with SHF_ALLOC|SHF_WRITE flags.
8## It is empty, so linker removes it, but it has to keep ".got.plt" output
9## section because of the BYTE command. Here we check that the output section
10## still remembers what the flags of .got.plt are.
11
12# CHECK:     Section {
13# CHECK:       Index: 2
14# CHECK:       Name: .bar
15# CHECK-NEXT:  Type: SHT_PROGBITS
16# CHECK-NEXT:  Flags [
17# CHECK-NEXT:    SHF_ALLOC
18# CHECK-NEXT:    SHF_WRITE
19# CHECK-NEXT:  ]
20
21## Check flags are not the same if we omit empty synthetic section in script.
22# RUN: echo "SECTIONS { .foo : { *(.foo) } .bar : { BYTE(0x11) }}" > %t.script
23# RUN: ld.lld -o %t --script %t.script %t.o
24# RUN: llvm-readobj -S %t | FileCheck --check-prefix=EMPTY %s
25
26# EMPTY:     Section {
27# EMPTY:       Index: 2
28# EMPTY:       Name: .bar
29# EMPTY-NEXT:  Type: SHT_PROGBITS
30# EMPTY-NEXT:  Flags [
31# EMPTY-NEXT:    SHF_ALLOC
32# EMPTY-NEXT:  ]
33
34.section .foo,"ax"
35.quad 0
36