Index: test/ELF/relro-bss.s =================================================================== --- /dev/null +++ test/ELF/relro-bss.s @@ -0,0 +1,34 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: llvm-readelf -l %t | FileCheck --check-prefix=SEGMENT %s +# RUN: llvm-readelf -S %t | FileCheck %s + +# SEGMENT: .text +# SEGMENT-NEXT: .data.rel.ro .bss.rel.ro +# SEGMENT-NEXT: .data .bss + +# Because .bss.rel.ro is nobits, .data is placed in the next page +# (sh_offset = alignTo(0x2001, 4096) = 0x3000). + +# [Nr] Name Type Address Off Size +# CHECK: .data.rel.ro PROGBITS 0000000000202000 002000 000001 +# CHECK-NEXT: .bss.rel.ro NOBITS 0000000000202001 002001 002000 +# CHECK-NEXT: .data PROGBITS 0000000000205000 003000 000001 +# CHECK-NEXT: .bss NOBITS 0000000000205001 003001 000001 + +.globl _start +_start: + ret + +.section .data.rel.ro, "aw" +.space 1 + +.section .bss.rel.ro, "aw", @nobits +.space 8192 + +.section .data, "aw" +.space 1 + +.section .bss, "aw" +.space 1