1# REQUIRES: x86 2## Regression test: add STT_SECTION even if synthetic sections are interleaved 3## with regular input sections. 4 5# RUN: rm -rf %t && split-file %s %t 6# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o 7# RUN: ld.lld --emit-relocs --no-relax -T %t/1.t %t/a.o -o %t/a1 8# RUN: llvm-objdump --no-print-imm-hex -dr %t/a1 | FileCheck %s --check-prefixes=CHECK,CHECK1 9# RUN: ld.lld --emit-relocs --no-relax -T %t/2.t %t/a.o -o %t/a2 10# RUN: llvm-objdump --no-print-imm-hex -dr %t/a2 | FileCheck %s --check-prefixes=CHECK,CHECK2 11 12# CHECK: <_start>: 13## %t/a1: bss is at offset 17. bss-4 = .bss + 0xd 14## %t/a2: bss is at offset 16. bss-4 = .bss + 0xc 15# CHECK-NEXT: movl [[#]](%rip), %eax 16# CHECK1-NEXT: R_X86_64_PC32 .bss+0xd 17# CHECK2-NEXT: R_X86_64_PC32 .bss+0xc 18# CHECK-NEXT: movl [[#]](%rip), %eax 19# CHECK-NEXT: R_X86_64_PC32 common-0x4 20# CHECK-NEXT: movl [[#]](%rip), %eax 21## %t/a1: input .data is at offset 8. 8-4 = 0x4 22## %t/a2: input .data is at offset 0. 0-4 = -0x4 23# CHECK1-NEXT: R_X86_64_GOTPCRELX .data+0x4 24# CHECK2-NEXT: R_X86_64_GOTPCRELX .data-0x4 25 26#--- a.s 27.globl _start 28_start: 29 movl bss(%rip), %eax 30 movl common(%rip), %eax 31## Compilers don't produce this. We just check the behavior. 32 movl .data@gotpcrel(%rip), %eax 33 34.section .data,"aw",@progbits 35.quad 0 36 37.section .bss,"aw",@nobits 38.space 16 39bss: 40.byte 0 41 42.comm common,1,1 43 44#--- 1.t 45SECTIONS { 46 .data : { *(.got) *(.data) } 47 .bss : { *(COMMON) *(.bss) } 48} 49 50#--- 2.t 51SECTIONS { 52 .data : { *(.data) *(.got) } 53 .bss : { *(.bss) *(COMMON) } 54} 55