[PATCH] D35813: Propagate section alignment to segment headers

Dmitry Mikulin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 24 14:28:57 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL308930: If user requested section alignment is greater than MaxPageSize, propagate it… (authored by dmikulin).

Changed prior to commit:
  https://reviews.llvm.org/D35813?vs=107949&id=107965#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35813

Files:
  lld/trunk/ELF/Writer.cpp
  lld/trunk/test/ELF/linkerscript/align-section-offset.s


Index: lld/trunk/test/ELF/linkerscript/align-section-offset.s
===================================================================
--- lld/trunk/test/ELF/linkerscript/align-section-offset.s
+++ lld/trunk/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
Index: lld/trunk/ELF/Writer.cpp
===================================================================
--- lld/trunk/ELF/Writer.cpp
+++ lld/trunk/ELF/Writer.cpp
@@ -1660,7 +1660,7 @@
         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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35813.107965.patch
Type: text/x-patch
Size: 1271 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170724/ed91170c/attachment.bin>


More information about the llvm-commits mailing list