[ELF] Fix max-page-size option.

The user can use the max-page-size option and set the maximum page size. Dont
check for maximum allowed values for page size, as its what the kernel is
configured with.

Fix the test as well.

llvm-svn: 221858
This commit is contained in:
Shankar Easwaran 2014-11-13 03:25:38 +00:00
parent 611e585f28
commit b43804b6f4
4 changed files with 13 additions and 12 deletions

View File

@ -61,16 +61,13 @@ public:
// Page size.
virtual uint64_t getPageSize() const {
if (_maxPageSizeOptionSet)
return _maxPageSize;
if (_maxPageSize)
return *_maxPageSize;
return 0x1000;
}
virtual void setMaxPageSize(uint64_t pagesize) {
_maxPageSize = pagesize;
_maxPageSizeOptionSet = true;
}
virtual uint64_t maxPageSize() const { return _maxPageSize; }
OutputMagic getOutputMagic() const { return _outputMagic; }
uint16_t getOutputELFType() const { return _outputELFType; }
uint16_t getOutputMachine() const;
@ -321,8 +318,7 @@ protected:
bool _mergeRODataToTextSegment;
bool _demangle;
bool _alignSegments;
bool _maxPageSizeOptionSet;
uint64_t _maxPageSize;
llvm::Optional<uint64_t> _maxPageSize;
OutputMagic _outputMagic;
StringRefVector _inputSearchPaths;

View File

@ -495,8 +495,7 @@ bool GnuLdDriver::parse(int argc, const char *argv[],
// modulo of the default page size.
if ((!parseZOption(extOpt, maxPageSize)) ||
(maxPageSize < ctx->getPageSize()) ||
(maxPageSize > ctx->maxPageSize()) ||
(!maxPageSize % ctx->maxPageSize())) {
(!maxPageSize % ctx->getPageSize())) {
diagnostics << "invalid option: " << extOpt << "\n";
return false;
}

View File

@ -62,8 +62,7 @@ ELFLinkingContext::ELFLinkingContext(
_mergeCommonStrings(false), _runLayoutPass(true),
_useShlibUndefines(true), _dynamicLinkerArg(false),
_noAllowDynamicLibraries(false), _mergeRODataToTextSegment(true),
_demangle(true), _alignSegments(true), _maxPageSizeOptionSet(false),
_maxPageSize(0x10000), _outputMagic(OutputMagic::DEFAULT),
_demangle(true), _alignSegments(true), _outputMagic(OutputMagic::DEFAULT),
_sysrootPath("") {}
void ELFLinkingContext::addPasses(PassManager &pm) {

View File

@ -8,11 +8,12 @@
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0
# RUN: not lld -flavor gnu -target x86_64 %t.o -o %t.exe -static \
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0xFF
# RUN: not lld -flavor gnu -target x86_64 %t.o -o %t.exe -static \
# RUN: lld -flavor gnu -target x86_64 %t.o -o %t1.exe -static \
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0x100000
# RUN: lld -flavor gnu -target x86_64 %t.o -o %t.exe -static \
# RUN: --no-align-segments --noinhibit-exec -z max-page-size=0x10000
# RUN: llvm-readobj -program-headers %t.exe | FileCheck %s
# RUN: llvm-readobj -program-headers %t1.exe | FileCheck %s -check-prefix=CHECKLARGE
#
#CHECK: VirtualAddress: 0x400000
#CHECK: PhysicalAddress: 0x400000
@ -20,6 +21,12 @@
#CHECK: VirtualAddress: 0x400178
#CHECK: PhysicalAddress: 0x400178
#CHECK: Alignment: 65536
#CHECKLARGE: VirtualAddress: 0x400000
#CHECKLARGE: PhysicalAddress: 0x400000
#CHECKLARGE: Alignment: 1048576
#CHECKLARGE: VirtualAddress: 0x400178
#CHECKLARGE: PhysicalAddress: 0x400178
#CHECKLARGE: Alignment: 1048576
# object
---