diff options
| author | Pete Cooper <peter_cooper@apple.com> | 2016-01-19 18:46:40 +0000 |
|---|---|---|
| committer | Pete Cooper <peter_cooper@apple.com> | 2016-01-19 18:46:40 +0000 |
| commit | feaa967ee813be3fa34ebc2b7a4751f2ec821df5 (patch) | |
| tree | 7733266fc2ad3af0bce659664619424f33233362 | |
| parent | 1a196f7dafb324ee9cd1d8e77aef500910053fea (diff) | |
| download | bcm5719-llvm-feaa967ee813be3fa34ebc2b7a4751f2ec821df5.tar.gz bcm5719-llvm-feaa967ee813be3fa34ebc2b7a4751f2ec821df5.zip | |
Cache the objc image info constraints in file.
Image info flags describe the objc constraint which is GC/retain/release/etc.
These need to be parsed and stored in the file so that we can do error checking.
That will come in a later commit.
llvm-svn: 258160
| -rw-r--r-- | lld/include/lld/ReaderWriter/MachOLinkingContext.h | 14 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/File.h | 9 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp | 9 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp | 13 |
4 files changed, 34 insertions, 11 deletions
diff --git a/lld/include/lld/ReaderWriter/MachOLinkingContext.h b/lld/include/lld/ReaderWriter/MachOLinkingContext.h index 671f4515e77..32a03fb790c 100644 --- a/lld/include/lld/ReaderWriter/MachOLinkingContext.h +++ b/lld/include/lld/ReaderWriter/MachOLinkingContext.h @@ -71,6 +71,16 @@ public: dynamicLookup }; + enum ObjCConstraint { + objc_unknown = 0, + objc_supports_gc = 2, + objc_gc_only = 4, + // Image optimized by dyld = 8 + // GC compaction = 16 + objc_retainReleaseForSimulator = 32, + objc_retainRelease + }; + /// Initializes the context to sane default values given the specified output /// file type, arch, os, and minimum os version. This should be called before /// other setXXX() methods. @@ -143,6 +153,9 @@ public: uint64_t baseAddress() const { return _baseAddress; } void setBaseAddress(uint64_t baseAddress) { _baseAddress = baseAddress; } + ObjCConstraint objcConstraint() const { return _objcConstraint; } + void setObjcConstraint(ObjCConstraint v) { _objcConstraint = v; } + /// \brief Checks whether a given path on the filesystem exists. /// /// When running in -test_file_usage mode, this method consults an @@ -398,6 +411,7 @@ private: uint64_t _stackSize; uint32_t _compatibilityVersion; uint32_t _currentVersion; + ObjCConstraint _objcConstraint; uint32_t _swiftVersion; StringRef _installName; StringRefVector _rpaths; diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h index 7b28590d3ca..1ba71dc67dc 100644 --- a/lld/lib/ReaderWriter/MachO/File.h +++ b/lld/lib/ReaderWriter/MachO/File.h @@ -194,6 +194,13 @@ public: MachOLinkingContext::OS OS() const { return _os; } void setOS(MachOLinkingContext::OS os) { _os = os; } + MachOLinkingContext::ObjCConstraint objcConstraint() const { + return _objcConstraint; + } + void setObjcConstraint(MachOLinkingContext::ObjCConstraint v) { + _objcConstraint = v; + } + uint32_t swiftVersion() const { return _swiftVersion; } void setSwiftVersion(uint32_t v) { _swiftVersion = v; } @@ -242,6 +249,8 @@ private: NameToAtom _undefAtoms; MachOLinkingContext::Arch _arch = MachOLinkingContext::arch_unknown; MachOLinkingContext::OS _os = MachOLinkingContext::OS::unknown; + MachOLinkingContext::ObjCConstraint _objcConstraint = + MachOLinkingContext::objc_unknown; uint32_t _swiftVersion = 0; normalized::FileFlags _flags; }; diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp index 6987f7afb06..5fcc259a498 100644 --- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp +++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp @@ -145,11 +145,10 @@ MachOLinkingContext::MachOLinkingContext() _doNothing(false), _pie(false), _arch(arch_unknown), _os(OS::macOSX), _osMinVersion(0), _pageZeroSize(0), _pageSize(4096), _baseAddress(0), _stackSize(0), _compatibilityVersion(0), _currentVersion(0), - _swiftVersion(0), - _flatNamespace(false), _undefinedMode(UndefinedMode::error), - _deadStrippableDylib(false), _printAtoms(false), _testingFileUsage(false), - _keepPrivateExterns(false), _demangle(false), _archHandler(nullptr), - _exportMode(ExportMode::globals), + _objcConstraint(objc_unknown), _swiftVersion(0), _flatNamespace(false), + _undefinedMode(UndefinedMode::error), _deadStrippableDylib(false), + _printAtoms(false), _testingFileUsage(false), _keepPrivateExterns(false), + _demangle(false), _archHandler(nullptr), _exportMode(ExportMode::globals), _debugInfoMode(DebugInfoMode::addDebugMap), _orderFileEntries(0), _flatNamespaceFile(nullptr) {} diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp index 342cce4cbcf..44e22ab6491 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp @@ -892,11 +892,6 @@ std::error_code parseObjCImageInfo(const NormalizedFile &normalizedFile, // uint32_t version; // initially 0 // uint32_t flags; // }; - enum { - OBJC_IMAGE_SUPPORTS_GC=2, - OBJC_IMAGE_GC_ONLY=4, - OBJC_IMAGE_IS_SIMULATED=32, - }; ArrayRef<uint8_t> content = imageInfoSection->content; if (content.size() != 8) @@ -914,12 +909,18 @@ std::error_code parseObjCImageInfo(const NormalizedFile &normalizedFile, " should have version=0"); uint32_t flags = read32(content.data() + 4, isBig); - if (flags & (OBJC_IMAGE_SUPPORTS_GC|OBJC_IMAGE_GC_ONLY)) + if (flags & (MachOLinkingContext::objc_supports_gc | + MachOLinkingContext::objc_gc_only)) return make_dynamic_error_code(imageInfoSection->segmentName + "/" + imageInfoSection->sectionName + " in file " + file.path() + " uses GC. This is not supported"); + if (flags & MachOLinkingContext::objc_retainReleaseForSimulator) + file.setObjcConstraint(MachOLinkingContext::objc_retainReleaseForSimulator); + else + file.setObjcConstraint(MachOLinkingContext::objc_retainRelease); + file.setSwiftVersion((flags >> 8) & 0xFF); return std::error_code(); |

