Files
clang-p2996/lld/test/ELF/linkerscript/implicit-program-header.test
Georgii Rymar 3f5dc57fd1 [LLD][ELF] - Don't keep empty output sections which have explicit program headers.
This reverts a side effect introduced in the code cleanup patch D43571:
LLD started to emit empty output sections that are explicitly assigned to a segment.

This patch fixes the issue by removing the !sec.phdrs.empty() special case from
isDiscardable. As compensation, we add an early phdrs propagation step (see the inline comment).
This is similar to one that we do in adjustSectionsAfterSorting.

Differential revision: https://reviews.llvm.org/D92301
2020-12-02 11:19:21 +03:00

25 lines
644 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 .dynsym .hash .dynstr .foo .text .dynamic
# CHECK-NEXT: 01 .foo
# CHECK-NEXT: 02 .foo
PHDRS {
ph_write PT_LOAD FLAGS(2);
ph_exec PT_LOAD FLAGS(1);
ph_note PT_NOTE;
}
SECTIONS {
.bar : { *(.bar) } : ph_exec : ph_note
.foo : { *(.foo) }
.text : { *(.text) } : ph_write
}