Files
clang-p2996/lld/test/ELF/linkerscript/merge-sections.s
Fangrui Song 011b785505 [ELF] Create readonly PT_LOAD in the presence of a SECTIONS command
This essentially drops the change by r288021 (discussed with Georgii Rymar
and Peter Smith and noted down in the release note of lld 10).

GNU ld>=2.31 enables -z separate-code by default for Linux x86. By
default (in the absence of a PHDRS command) a readonly PT_LOAD is
created, which is different from its traditional behavior.

Not emulating GNU ld's traditional behavior is good for us because it
improves code consistency (we create a readonly PT_LOAD in the absence
of a SECTIONS command).

Users can add --no-rosegment to restore the previous behavior (combined
readonly and read-executable sections in a single RX PT_LOAD).
2020-03-19 19:11:11 -07:00

62 lines
1.5 KiB
ArmAsm

# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
# RUN: echo "SECTIONS { \
# RUN: . = SIZEOF_HEADERS; \
# RUN: .foo : { begin = .; *(.foo.*) end = .;} \
# RUN: }" > %t.script
# RUN: ld.lld -o %t1 --script %t.script %t -shared
# RUN: llvm-readobj -S --symbols %t1 | FileCheck %s
# CHECK: Name: .foo
# CHECK-NEXT: Type: SHT_PROGBITS
# CHECK-NEXT: Flags [
# CHECK-NEXT: SHF_ALLOC
# CHECK-NEXT: SHF_MERGE
# CHECK-NEXT: SHF_STRINGS
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x[[ADDR1:.*]]
# CHECK-NEXT: Offset: 0x[[ADDR1]]
# CHECK-NEXT: Size: 8
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 2
# CHECK-NEXT: EntrySize: 0
# CHECK-NEXT: }
# CHECK: Name: begin
# CHECK-NEXT: Value: 0x[[ADDR1]]
# CHECK: Name: end
# CHECK-NEXT: Value: 0x268
# Check that we don't crash with --gc-sections
# RUN: ld.lld --gc-sections -o %t2 --script %t.script %t -shared
# RUN: llvm-readobj -S --symbols %t2 | FileCheck %s --check-prefix=GC
# GC: Name: .foo
# GC-NEXT: Type: SHT_PROGBITS
# GC-NEXT: Flags [
# GC-NEXT: SHF_ALLOC
# GC-NEXT: ]
.section .foo.1a,"aMS",@progbits,1
.asciz "foo"
.section .foo.1b,"aMS",@progbits,1
.asciz "foo"
.section .foo.2a,"aM",@progbits,1
.byte 42
.section .foo.2b,"aM",@progbits,1
.byte 42
.section .foo.3a,"aM",@progbits,2
.align 2
.short 42
.section .foo.3b,"aM",@progbits,2
.align 2
.short 42