If segments are defined in a linker script, placing an orphan section before the found closest-rank section can result in adding it in a previous segment and changing flags of that segment. This happens if the orphan section has a lower sort rank than the found section. To avoid that, the patch forces orphan sections to be moved after the found section if segments are explicitly defined. Differential Revision: https://reviews.llvm.org/D111717
25 lines
670 B
Plaintext
25 lines
670 B
Plaintext
# REQUIRES: x86
|
|
|
|
# RUN: echo '.section .text,"ax"; .quad 0' > %t.s
|
|
# RUN: echo '.section .foo,"ax"; .quad 0' >> %t.s
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t.s -o %t.o
|
|
# RUN: ld.lld --hash-style=sysv -o %t1 --script %s %t.o -shared
|
|
# RUN: llvm-readelf -l %t1 | FileCheck %s
|
|
|
|
# CHECK: Segment Sections...
|
|
# CHECK-NEXT: 00 .text
|
|
# CHECK-NEXT: 01 .foo .dynsym .hash .dynstr .dynamic
|
|
# CHECK-NEXT: 02 .foo .dynsym .hash .dynstr .dynamic
|
|
|
|
PHDRS {
|
|
ph_write PT_LOAD FLAGS(2);
|
|
ph_exec PT_LOAD FLAGS(1);
|
|
ph_note PT_NOTE;
|
|
}
|
|
|
|
SECTIONS {
|
|
.text : { *(.text) } : ph_write
|
|
.bar : { *(.bar) } : ph_exec : ph_note
|
|
.foo : { *(.foo) }
|
|
}
|