[lld] r221858 - [ELF] Fix max-page-size option.

Rui Ueyama ruiu at google.com
Wed Nov 12 19:45:46 PST 2014


On Wed, Nov 12, 2014 at 7:25 PM, Shankar Easwaran <shankare at codeaurora.org>
wrote:

> Author: shankare
> Date: Wed Nov 12 21:25:38 2014
> New Revision: 221858
>
> URL: http://llvm.org/viewvc/llvm-project?rev=221858&view=rev
> Log:
> [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.
>
> Modified:
>     lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
>     lld/trunk/lib/Driver/GnuLdDriver.cpp
>     lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
>     lld/trunk/test/elf/X86_64/maxpagesize.test
>
> Modified: lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h?rev=221858&r1=221857&r2=221858&view=diff
>
> ==============================================================================
> --- lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h (original)
> +++ lld/trunk/include/lld/ReaderWriter/ELFLinkingContext.h Wed Nov 12
> 21:25:38 2014
> @@ -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;
>
> Modified: lld/trunk/lib/Driver/GnuLdDriver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/GnuLdDriver.cpp?rev=221858&r1=221857&r2=221858&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/Driver/GnuLdDriver.cpp (original)
> +++ lld/trunk/lib/Driver/GnuLdDriver.cpp Wed Nov 12 21:25:38 2014
> @@ -495,8 +495,7 @@ bool GnuLdDriver::parse(int argc, const
>          // modulo of the default page size.
>          if ((!parseZOption(extOpt, maxPageSize)) ||
>              (maxPageSize < ctx->getPageSize()) ||
> -            (maxPageSize > ctx->maxPageSize()) ||
> -            (!maxPageSize % ctx->maxPageSize())) {
> +            (!maxPageSize % ctx->getPageSize())) {
>

This doesn't look correct. You are calculating the remainder of
!maxPageSize (= 0 unless maxPageSize is 0) and ctx->getPageSize().

I guess you wanted to write maxPageSize % ctx->gePageSize() != 0.

           diagnostics << "invalid option: " << extOpt << "\n";
>            return false;
>          }
>
> Modified: lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp?rev=221858&r1=221857&r2=221858&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp (original)
> +++ lld/trunk/lib/ReaderWriter/ELF/ELFLinkingContext.cpp Wed Nov 12
> 21:25:38 2014
> @@ -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) {
>
> Modified: lld/trunk/test/elf/X86_64/maxpagesize.test
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/maxpagesize.test?rev=221858&r1=221857&r2=221858&view=diff
>
> ==============================================================================
> --- lld/trunk/test/elf/X86_64/maxpagesize.test (original)
> +++ lld/trunk/test/elf/X86_64/maxpagesize.test Wed Nov 12 21:25:38 2014
> @@ -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
>  ---
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141112/711bed90/attachment.html>


More information about the llvm-commits mailing list