<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Nov 12, 2014 at 7:25 PM, Shankar Easwaran <span dir="ltr"><<a href="mailto:shankare@codeaurora.org" target="_blank">shankare@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: shankare<br>
Date: Wed Nov 12 21:25:38 2014<br>
New Revision: 221858<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221858&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=221858&view=rev</a><br>
Log:<br>
[ELF] Fix max-page-size option.<br>
<br>
The user can use the max-page-size option and set the maximum page size. Dont<br>
check for maximum allowed values for page size, as its what the kernel is<br>
configured with.<br>
<br>
Fix the test as well.<br>
<br>
Modified:<br>
lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp<br>
lld/trunk/test/elf/X86_64/maxpagesize.test<br>
<br>
Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=221858&r1=221857&r2=221858&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=221858&r1=221857&r2=221858&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)<br>
+++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Wed Nov 12 21:25:38 2014<br>
@@ -61,16 +61,13 @@ public:<br>
<br>
// Page size.<br>
virtual uint64_t getPageSize() const {<br>
- if (_maxPageSizeOptionSet)<br>
- return _maxPageSize;<br>
+ if (_maxPageSize)<br>
+ return *_maxPageSize;<br>
return 0x1000;<br>
}<br>
virtual void setMaxPageSize(uint64_t pagesize) {<br>
_maxPageSize = pagesize;<br>
- _maxPageSizeOptionSet = true;<br>
}<br>
- virtual uint64_t maxPageSize() const { return _maxPageSize; }<br>
-<br>
OutputMagic getOutputMagic() const { return _outputMagic; }<br>
uint16_t getOutputELFType() const { return _outputELFType; }<br>
uint16_t getOutputMachine() const;<br>
@@ -321,8 +318,7 @@ protected:<br>
bool _mergeRODataToTextSegment;<br>
bool _demangle;<br>
bool _alignSegments;<br>
- bool _maxPageSizeOptionSet;<br>
- uint64_t _maxPageSize;<br>
+ llvm::Optional<uint64_t> _maxPageSize;<br>
<br>
OutputMagic _outputMagic;<br>
StringRefVector _inputSearchPaths;<br>
<br>
Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=221858&r1=221857&r2=221858&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=221858&r1=221857&r2=221858&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)<br>
+++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Nov 12 21:25:38 2014<br>
@@ -495,8 +495,7 @@ bool GnuLdDriver::parse(int argc, const<br>
// modulo of the default page size.<br>
if ((!parseZOption(extOpt, maxPageSize)) ||<br>
(maxPageSize < ctx->getPageSize()) ||<br>
- (maxPageSize > ctx->maxPageSize()) ||<br>
- (!maxPageSize % ctx->maxPageSize())) {<br>
+ (!maxPageSize % ctx->getPageSize())) {<br></blockquote><div><br></div><div>This doesn't look correct. You are calculating the remainder of !maxPageSize (= 0 unless maxPageSize is 0) and ctx->getPageSize().</div><div><br></div><div>I guess you wanted to write maxPageSize % ctx->gePageSize() != 0.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
diagnostics << "invalid option: " << extOpt << "\n";<br>
return false;<br>
}<br>
<br>
Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=221858&r1=221857&r2=221858&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=221858&r1=221857&r2=221858&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)<br>
+++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Wed Nov 12 21:25:38 2014<br>
@@ -62,8 +62,7 @@ ELFLinkingContext::ELFLinkingContext(<br>
_mergeCommonStrings(false), _runLayoutPass(true),<br>
_useShlibUndefines(true), _dynamicLinkerArg(false),<br>
_noAllowDynamicLibraries(false), _mergeRODataToTextSegment(true),<br>
- _demangle(true), _alignSegments(true), _maxPageSizeOptionSet(false),<br>
- _maxPageSize(0x10000), _outputMagic(OutputMagic::DEFAULT),<br>
+ _demangle(true), _alignSegments(true), _outputMagic(OutputMagic::DEFAULT),<br>
_sysrootPath("") {}<br>
<br>
void ELFLinkingContext::addPasses(PassManager &pm) {<br>
<br>
Modified: lld/trunk/test/elf/X86_64/maxpagesize.test<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/maxpagesize.test?rev=221858&r1=221857&r2=221858&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/maxpagesize.test?rev=221858&r1=221857&r2=221858&view=diff</a><br>
==============================================================================<br>
--- lld/trunk/test/elf/X86_64/maxpagesize.test (original)<br>
+++ lld/trunk/test/elf/X86_64/maxpagesize.test Wed Nov 12 21:25:38 2014<br>
@@ -8,11 +8,12 @@<br>
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0<br>
# RUN: not lld -flavor gnu -target x86_64 %t.o -o %t.exe -static \<br>
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0xFF<br>
-# RUN: not lld -flavor gnu -target x86_64 %t.o -o %t.exe -static \<br>
+# RUN: lld -flavor gnu -target x86_64 %t.o -o %t1.exe -static \<br>
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0x100000<br>
# RUN: lld -flavor gnu -target x86_64 %t.o -o %t.exe -static \<br>
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0x10000<br>
# RUN: llvm-readobj -program-headers %t.exe | FileCheck %s<br>
+# RUN: llvm-readobj -program-headers %t1.exe | FileCheck %s -check-prefix=CHECKLARGE<br>
#<br>
#CHECK: VirtualAddress: 0x400000<br>
#CHECK: PhysicalAddress: 0x400000<br>
@@ -20,6 +21,12 @@<br>
#CHECK: VirtualAddress: 0x400178<br>
#CHECK: PhysicalAddress: 0x400178<br>
#CHECK: Alignment: 65536<br>
+#CHECKLARGE: VirtualAddress: 0x400000<br>
+#CHECKLARGE: PhysicalAddress: 0x400000<br>
+#CHECKLARGE: Alignment: 1048576<br>
+#CHECKLARGE: VirtualAddress: 0x400178<br>
+#CHECKLARGE: PhysicalAddress: 0x400178<br>
+#CHECKLARGE: Alignment: 1048576<br>
<br>
# object<br>
---<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits<br></a><br>
</blockquote></div></div></div>