llvm-project/lld/test/ELF/linkerscript/merge-header-load.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

23 lines
822 B
ArmAsm

# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: echo "SECTIONS { \
# RUN: . = 0xffffffff80000200; \
# RUN: .text : AT (0x4200) { *(.text) } \
# RUN: }" > %t.script
# RUN: ld.lld %t.o --script %t.script -o %t
# RUN: llvm-readelf -program-headers %t | FileCheck %s
# Test that we put the header in the first PT_LOAD. We used to create a PT_LOAD
# just for it and it would have a different virtual to physical address delta.
# CHECK: Program Headers:
# CHECK: Type Offset VirtAddr PhysAddr
# CHECK-NEXT: PHDR 0x000040 0xffffffff80000040 0xffffffff80000040
# CHECK-NEXT: LOAD 0x000000 0xffffffff80000000 0xffffffff80000000
# CHECK-NEXT: LOAD 0x000200 0xffffffff80000200 0x0000000000004200
# CHECK-NOT: LOAD
.global _start
_start:
nop