<div dir="ltr">Maybe we should rename Target->MaxPageSize Target->DefaultMaxPageSize to prevent future programmers' errors?</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 7, 2016 at 12:29 PM, Rafael Espindola via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rafael<br>
Date: Wed Dec 7 14:29:46 2016<br>
New Revision: 288974<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=288974&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=288974&view=rev</a><br>
Log:<br>
Use the correct MaxPageSize.<br>
<br>
Now Target->MaxPageSize is only used as the default value of<br>
Config->MaxPageSize.<br>
<br>
Modified:<br>
lld/trunk/ELF/Driver.cpp<br>
lld/trunk/test/ELF/image-base.<wbr>s<br>
<br>
Modified: lld/trunk/ELF/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=288974&r1=288973&r2=288974&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/ELF/Driver.<wbr>cpp?rev=288974&r1=288973&r2=<wbr>288974&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/ELF/Driver.cpp (original)<br>
+++ lld/trunk/ELF/Driver.cpp Wed Dec 7 14:29:46 2016<br>
@@ -738,7 +738,7 @@ static uint64_t getImageBase(opt::InputA<br>
error("-image-base: number expected, but got " + S);<br>
return 0;<br>
}<br>
- if ((V % Target->MaxPageSize) != 0)<br>
+ if ((V % Config->MaxPageSize) != 0)<br>
warn("-image-base: address isn't multiple of page size: " + S);<br>
return V;<br>
}<br>
@@ -758,6 +758,14 @@ template <class ELFT> void LinkerDriver:<br>
ELFT::Is64Bits || Config->EMachine == EM_X86_64 || Config->MipsN32Abi;<br>
Config->Mips64EL =<br>
(Config->EMachine == EM_MIPS && Config->EKind == ELF64LEKind);<br>
+<br>
+ // Initialize Config->MaxPageSize. The default value is defined by<br>
+ // each target.<br>
+ Config->MaxPageSize =<br>
+ getZOptionValue(Args, "max-page-size", Target->MaxPageSize);<br>
+ if (!isPowerOf2_64(Config-><wbr>MaxPageSize))<br>
+ error("max-page-size: value isn't a power of 2");<br>
+<br>
Config->ImageBase = getImageBase(Args);<br>
<br>
// Default output filename is "a.out" by the Unix tradition.<br>
@@ -775,13 +783,6 @@ template <class ELFT> void LinkerDriver:<br>
for (auto *Arg : Args.filtered(OPT_trace_<wbr>symbol))<br>
Symtab.trace(Arg->getValue());<br>
<br>
- // Initialize Config->MaxPageSize. The default value is defined by<br>
- // each target.<br>
- Config->MaxPageSize =<br>
- getZOptionValue(Args, "max-page-size", Target->MaxPageSize);<br>
- if (!isPowerOf2_64(Config-><wbr>MaxPageSize))<br>
- error("max-page-size: value isn't a power of 2");<br>
-<br>
// Add all files to the symbol table. This will add almost all<br>
// symbols that we need to the symbol table.<br>
for (InputFile *F : Files)<br>
<br>
Modified: lld/trunk/test/ELF/image-base.<wbr>s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/image-base.s?rev=288974&r1=288973&r2=288974&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/lld/trunk/test/ELF/<wbr>image-base.s?rev=288974&r1=<wbr>288973&r2=288974&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- lld/trunk/test/ELF/image-base.<wbr>s (original)<br>
+++ lld/trunk/test/ELF/image-base.<wbr>s Wed Dec 7 14:29:46 2016<br>
@@ -3,6 +3,10 @@<br>
# RUN: ld.lld -image-base=0x1000000 %t -o %t1<br>
# RUN: llvm-readobj -program-headers %t1 | FileCheck %s<br>
<br>
+# RUN: ld.lld -image-base=0x1000 -z max-page-size=0x2000 %t -o %t1 2>&1 | FileCheck --check-prefix=WARN %s<br>
+# WARN: warning: -image-base: address isn't multiple of page size: 0x1000<br>
+<br>
+<br>
.global _start<br>
_start:<br>
nop<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>