[lld] r308812 - Handle a section being more aligned than a page size.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 21 17:17:57 PDT 2017
Author: rafael
Date: Fri Jul 21 17:17:57 2017
New Revision: 308812
URL: http://llvm.org/viewvc/llvm-project?rev=308812&view=rev
Log:
Handle a section being more aligned than a page size.
Added:
lld/trunk/test/ELF/linkerscript/align-section-offset.s
Modified:
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=308812&r1=308811&r2=308812&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Fri Jul 21 17:17:57 2017
@@ -1600,7 +1600,8 @@ static uint64_t getFileAlignment(uint64_
// The first section in a PT_LOAD has to have congruent offset and address
// module the page size.
if (Sec == First)
- return alignTo(Off, Config->MaxPageSize, Sec->Addr);
+ return alignTo(Off, std::max<uint64_t>(Sec->Alignment, Config->MaxPageSize),
+ Sec->Addr);
// If two sections share the same PT_LOAD the file offset is calculated
// using this formula: Off2 = Off1 + (VA2 - VA1).
Added: lld/trunk/test/ELF/linkerscript/align-section-offset.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/align-section-offset.s?rev=308812&view=auto
==============================================================================
--- lld/trunk/test/ELF/linkerscript/align-section-offset.s (added)
+++ lld/trunk/test/ELF/linkerscript/align-section-offset.s Fri Jul 21 17:17:57 2017
@@ -0,0 +1,10 @@
+# REQUIRES: x86
+# 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
+
+# CHECK: .foo PROGBITS 0000000000200000 200000 000008 00 WA 0 0 2097152
+
+ .section .foo, "aw"
+ .quad 42
More information about the llvm-commits
mailing list