Skip to content

Commit 97d6a80

Browse files
committed
If user requested section alignment is greater than MaxPageSize, propagate it to segment headers correctly.
Differential Revision: https://reviews.llvm.org/D35813 llvm-svn: 308930
1 parent 1326892 commit 97d6a80

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

lld/ELF/Writer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ template <class ELFT> void Writer<ELFT>::setPhdrs() {
16601660
P.p_paddr = First->getLMA();
16611661
}
16621662
if (P.p_type == PT_LOAD)
1663-
P.p_align = Config->MaxPageSize;
1663+
P.p_align = std::max<uint64_t>(P.p_align, Config->MaxPageSize);
16641664
else if (P.p_type == PT_GNU_RELRO) {
16651665
P.p_align = 1;
16661666
// The glibc dynamic loader rounds the size down, so we need to round up

lld/test/ELF/linkerscript/align-section-offset.s

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
33
# RUN: echo "SECTIONS { .foo : ALIGN(2M) { *(.foo) } }" > %t.script
44
# RUN: ld.lld -o %t --script %t.script %t.o -shared
5-
# RUN: llvm-readelf -S %t | FileCheck %s
5+
# RUN: llvm-readelf -S -l %t | FileCheck %s
66

77
# CHECK: .foo PROGBITS 0000000000200000 200000 000008 00 WA 0 0 2097152
8+
# CHECK: LOAD 0x200000 0x0000000000200000 0x0000000000200000 {{.*}} RW 0x200000
89

910
.section .foo, "aw"
1011
.quad 42

0 commit comments

Comments
 (0)