[lld] r217577 - [mach-o]: tighten up diagnostics for -image_base option

Tim Northover tnorthover at apple.com
Thu Sep 11 03:31:42 PDT 2014


Author: tnorthover
Date: Thu Sep 11 05:31:42 2014
New Revision: 217577

URL: http://llvm.org/viewvc/llvm-project?rev=217577&view=rev
Log:
[mach-o]: tighten up diagnostics for -image_base option

The provided base must also be a multiple of the system's page size, which is a
reasonable enough demand.

Also check the other diagnostics more thoroughly.

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=217577&r1=217576&r2=217577&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Thu Sep 11 05:31:42 2014
@@ -320,6 +320,10 @@ bool DarwinLdDriver::parse(int argc, con
     } else if (baseAddress < ctx.pageZeroSize()) {
       diagnostics << "error: image_base overlaps with __PAGEZERO\n";
       return false;
+    } else if (baseAddress % ctx.pageSize()) {
+      diagnostics << "error: image_base must be a multiple of page size ("
+                  << llvm::format("0x%" PRIx64, ctx.pageSize()) << ")\n";
+      return false;
     }
 
     ctx.setBaseAddress(baseAddress);

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=217577&r1=217576&r2=217577&view=diff
==============================================================================
--- lld/trunk/test/mach-o/image-base.yaml (original)
+++ lld/trunk/test/mach-o/image-base.yaml Thu Sep 11 05:31:42 2014
@@ -1,5 +1,11 @@
-# RUN: lld -flavor darwin -arch x86_64 -macosx_version_min 10.9 %s -o %t -image_base 31415926530 %p/Inputs/libSystem.yaml
+# 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: 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
+# RUN: not lld -flavor darwin -arch x86_64 -image_base hithere %s >/dev/null 2> %t
+# RUN: FileCheck < %t %s --check-prefix=CHECK-ERROR-NOTHEX
 
 --- !native
 defined-atoms:
@@ -11,4 +17,11 @@ defined-atoms:
   # us easy access to the MachO segment model, so we have to check the uglier
   # macho-dump output.
 # CHECK: 'segment_name', '__TEXT
-# CHECK-NEXT: 'vm_addr', 3384796144944
+# CHECK-NEXT: 'vm_addr', 3384796143616
+
+
+# CHECK-ERROR-MISPAGED: error: image_base must be a multiple of page size (0x1000)
+
+# CHECK-ERROR-OVERLAP: error: image_base overlaps with __PAGEZERO
+
+# CHECK-ERROR-NOTHEX: error: image_base expects a hex number





More information about the llvm-commits mailing list