[lld] r217578 - [mach-o]: support optional "0x" prefix for -image_base
Tim Northover
tnorthover at apple.com
Thu Sep 11 03:31:46 PDT 2014
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
More information about the llvm-commits
mailing list