From a86a9c6fad09c22b82adafac3d87d27510f7f9b1 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 7 Dec 2016 20:10:43 +0000 Subject: [PATCH] Use the correct MaxPageSize. Found by inspection. llvm-svn: 288970 --- lld/ELF/Writer.cpp | 2 +- lld/test/ELF/linkerscript/page-size-align.s | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 lld/test/ELF/linkerscript/page-size-align.s diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index 6330d70..686228d 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -1325,7 +1325,7 @@ static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase *Sec) { // If two sections share the same PT_LOAD the file offset is calculated using // this formula: Off2 = Off1 + (VA2 - VA1). if (Sec == First) - return alignTo(Off, Target->MaxPageSize, Sec->Addr); + return alignTo(Off, Config->MaxPageSize, Sec->Addr); return First->Offset + Sec->Addr - First->Addr; } diff --git a/lld/test/ELF/linkerscript/page-size-align.s b/lld/test/ELF/linkerscript/page-size-align.s new file mode 100644 index 0000000..771bb13 --- /dev/null +++ b/lld/test/ELF/linkerscript/page-size-align.s @@ -0,0 +1,22 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o + +# RUN: echo "SECTIONS { \ +# RUN: . = SIZEOF_HEADERS; \ +# RUN: .text : { *(.text) } \ +# RUN: . = ALIGN(CONSTANT(MAXPAGESIZE)); \ +# RUN: . = . + 0x3000; \ +# RUN: .dynamic : { *(.dynamic) } \ +# RUN: }" > %t.script + +# RUN: ld.lld -T %t.script -z max-page-size=0x4000 %t.o -o %t.so -shared +# RUN: llvm-readobj -s %t.so | FileCheck %s + +# CHECK: Name: .dynamic +# CHECK-NEXT: Type: SHT_DYNAMIC +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x7000 +# CHECK-NEXT: Offset: 0x3000 -- 2.7.4