xref: /llvm-project/lld/test/ELF/linkerscript/tbss.s (revision 9bd29a73d17add45234a35de5f6ad7ca8321f7f9)
1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3# RUN: echo 'SECTIONS { \
4# RUN:   . = SIZEOF_HEADERS; \
5# RUN:   .text : { *(.text) } \
6# RUN:   .tbss : { __tbss_start = .; *(.tbss) __tbss_end = .; } \
7# RUN:   second_tbss : { second_tbss_start = .; *(second_tbss) second_tbss_end = .; } \
8# RUN:   bar : { *(bar) } \
9# RUN: }' > %t.lds
10# RUN: ld.lld -T %t.lds %t.o -o %t1
11# RUN: llvm-readelf -S -s %t1 | FileCheck %s
12
13# RUN: echo 'PHDRS { text PT_LOAD; }' > %th.lds
14# RUN: cat %th.lds %t.lds > %t2.lds
15# RUN: ld.lld -T %t.lds %t.o -o %t2
16# RUN: llvm-readelf -S -s %t2 | FileCheck %s
17
18## Test that a tbss section doesn't affect the start address of the next section.
19
20# CHECK: Name        Type     Address              Off                Size   ES Flg
21# CHECK: .tbss       NOBITS   [[#%x,ADDR:]]        [[#%x,OFF:]]       000004 00 WAT
22# CHECK: second_tbss NOBITS   {{0+}}[[#%x,ADDR+4]] {{0+}}[[#%x,OFF]]  000001 00 WAT
23# CHECK: bar         PROGBITS {{0+}}[[#%x,ADDR]]   {{0+}}[[#%x,OFF]]  000004 00  WA
24
25## Test that . in a tbss section represents the current location, even if the
26## address will be reset.
27
28# CHECK: Value                {{.*}} Name
29# CHECK: {{0+}}[[#%x,ADDR]]   {{.*}} __tbss_start
30# CHECK: {{0+}}[[#%x,ADDR+4]] {{.*}} __tbss_end
31# CHECK: {{0+}}[[#%x,ADDR+4]] {{.*}} second_tbss_start
32# CHECK: {{0+}}[[#%x,ADDR+5]] {{.*}} second_tbss_end
33
34.globl _start
35_start:
36  nop
37
38.section .tbss,"awT",@nobits
39  .long 0
40.section second_tbss,"awT",@nobits
41  .byte 0
42.section bar, "aw"
43  .long 0
44