diff options
| author | Dmitry Mikulin <dmitry.mikulin@sony.com> | 2017-07-24 21:27:02 +0000 |
|---|---|---|
| committer | Dmitry Mikulin <dmitry.mikulin@sony.com> | 2017-07-24 21:27:02 +0000 |
| commit | 97d6a808958995009bbcb66082418293316e2d42 (patch) | |
| tree | aa594f2f8dfd7b0e05d550f80ad07fb4259a0e47 | |
| parent | 132689243e03b4e817aaac82d352a029216e9fee (diff) | |
| download | bcm5719-llvm-97d6a808958995009bbcb66082418293316e2d42.tar.gz bcm5719-llvm-97d6a808958995009bbcb66082418293316e2d42.zip | |
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
| -rw-r--r-- | lld/ELF/Writer.cpp | 2 | ||||
| -rw-r--r-- | lld/test/ELF/linkerscript/align-section-offset.s | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 558ecfbec27..6f75efb482e 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1660,7 +1660,7 @@ template <class ELFT> void Writer<ELFT>::setPhdrs() { P.p_paddr = First->getLMA(); } if (P.p_type == PT_LOAD) - P.p_align = Config->MaxPageSize; + P.p_align = std::max<uint64_t>(P.p_align, Config->MaxPageSize); else if (P.p_type == PT_GNU_RELRO) { P.p_align = 1; // The glibc dynamic loader rounds the size down, so we need to round up diff --git a/lld/test/ELF/linkerscript/align-section-offset.s b/lld/test/ELF/linkerscript/align-section-offset.s index 58831f18dfd..9c1603a1985 100644 --- a/lld/test/ELF/linkerscript/align-section-offset.s +++ b/lld/test/ELF/linkerscript/align-section-offset.s @@ -2,9 +2,10 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: echo "SECTIONS { .foo : ALIGN(2M) { *(.foo) } }" > %t.script # RUN: ld.lld -o %t --script %t.script %t.o -shared -# RUN: llvm-readelf -S %t | FileCheck %s +# RUN: llvm-readelf -S -l %t | FileCheck %s # CHECK: .foo PROGBITS 0000000000200000 200000 000008 00 WA 0 0 2097152 +# CHECK: LOAD 0x200000 0x0000000000200000 0x0000000000200000 {{.*}} RW 0x200000 .section .foo, "aw" .quad 42 |

