[lld] r257953 - Check that the objc image info version is exactly 0

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 15 15:25:37 PST 2016


Author: pete
Date: Fri Jan 15 17:25:37 2016
New Revision: 257953

URL: http://llvm.org/viewvc/llvm-project?rev=257953&view=rev
Log:
Check that the objc image info version is exactly 0

Added:
    lld/trunk/test/mach-o/objc-image-info-invalid-version.yaml
Modified:
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=257953&r1=257952&r2=257953&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp Fri Jan 15 17:25:37 2016
@@ -903,6 +903,14 @@ std::error_code parseObjCImageInfo(const
                                    " in file " + file.path() +
                                    " should be 8 bytes in size");
 
+  const bool isBig = MachOLinkingContext::isBigEndian(normalizedFile.arch);
+  uint32_t version = read32(content.data(), isBig);
+  if (version)
+    return make_dynamic_error_code(imageInfoSection->segmentName + "/" +
+                                   imageInfoSection->sectionName +
+                                   " in file " + file.path() +
+                                   " should have version=0");
+
   return std::error_code();
 }
 

Added: lld/trunk/test/mach-o/objc-image-info-invalid-version.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/objc-image-info-invalid-version.yaml?rev=257953&view=auto
==============================================================================
--- lld/trunk/test/mach-o/objc-image-info-invalid-version.yaml (added)
+++ lld/trunk/test/mach-o/objc-image-info-invalid-version.yaml Fri Jan 15 17:25:37 2016
@@ -0,0 +1,20 @@
+# RUN: not lld -flavor darwin -arch x86_64 -r %s 2>&1 | FileCheck %s
+
+--- !mach-o
+arch:            x86_64
+file-type:       MH_OBJECT
+flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
+compat-version:  0.0
+current-version: 0.0
+has-UUID:        false
+OS:              unknown
+sections:
+  - segment:         __DATA
+    section:         __objc_imageinfo
+    type:            S_REGULAR
+    attributes:      [ S_ATTR_NO_DEAD_STRIP ]
+    address:         0x0000000000000100
+    content:         [ 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 ]
+...
+
+# CHECK: error: __DATA/__objc_imageinfo in file {{.*}} should have version=0
\ No newline at end of file




More information about the llvm-commits mailing list