[lld] r217578 - [mach-o]: support optional "0x" prefix for -image_base

Rui Ueyama ruiu at google.com
Thu Sep 11 16:20:02 PDT 2014


In most languages that I know, if one accepts "0x" as a hex digit prefix,
it also accepts "0X". So I'm wondering if it has to compare the prefix case
insensitive way. I did not test it though. I'm sorry if it missed the point.

On Thu, Sep 11, 2014 at 3:31 AM, Tim Northover <tnorthover at apple.com> wrote:

> Author: tnorthover
> Date: Thu Sep 11 05:31:46 2014
> New Revision: 217578
>
> URL: http://llvm.org/viewvc/llvm-project?rev=217578&view=rev
> Log:
> [mach-o]: support optional "0x" prefix for -image_base
>
> Modified:
>     lld/trunk/lib/Driver/DarwinLdDriver.cpp
>     lld/trunk/test/mach-o/image-base.yaml
>
> Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=217578&r1=217577&r2=217578&view=diff
>
> ==============================================================================
> --- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
> +++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Thu Sep 11 05:31:46 2014
> @@ -313,8 +313,12 @@ bool DarwinLdDriver::parse(int argc, con
>      ctx.setOutputPath("a.out");
>
>    if (llvm::opt::Arg *imageBase = parsedArgs->getLastArg(OPT_image_base))
> {
> +    StringRef baseString = imageBase->getValue();
> +    if (baseString.startswith("0x"))
> +      baseString = baseString.drop_front(2);
> +
>      uint64_t baseAddress;
> -    if (StringRef(imageBase->getValue()).getAsInteger(16, baseAddress)) {
> +    if (baseString.getAsInteger(16, baseAddress)) {
>        diagnostics << "error: image_base expects a hex number\n";
>        return false;
>      } else if (baseAddress < ctx.pageZeroSize()) {
>
> Modified: lld/trunk/test/mach-o/image-base.yaml
> URL:
> http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/image-base.yaml?rev=217578&r1=217577&r2=217578&view=diff
>
> ==============================================================================
> --- lld/trunk/test/mach-o/image-base.yaml (original)
> +++ lld/trunk/test/mach-o/image-base.yaml Thu Sep 11 05:31:46 2014
> @@ -1,6 +1,6 @@
>  # RUN: lld -flavor darwin -arch x86_64 -macosx_version_min 10.9 %s -o %t
> -image_base 31415926000 %p/Inputs/libSystem.yaml
>  # RUN: macho-dump %t | FileCheck %s
> -# RUN: not lld -flavor darwin -arch x86_64 -image_base 31415926530 %s
> >/dev/null 2> %t
> +# RUN: not lld -flavor darwin -arch x86_64 -image_base 0x31415926530 %s
> >/dev/null 2> %t
>  # RUN: FileCheck < %t %s --check-prefix=CHECK-ERROR-MISPAGED
>  # RUN: not lld -flavor darwin -arch x86_64 -image_base 1000 %s >/dev/null
> 2> %t
>  # RUN: FileCheck < %t %s --check-prefix=CHECK-ERROR-OVERLAP
>
>
> _______________________________________________
> 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/20140911/32fec9cd/attachment.html>


More information about the llvm-commits mailing list