[lld] r258160 - Cache the objc image info constraints in file.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 19 10:46:43 PST 2016
Author: pete
Date: Tue Jan 19 12:46:40 2016
New Revision: 258160
URL: http://llvm.org/viewvc/llvm-project?rev=258160&view=rev
Log:
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.
Modified:
lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
lld/trunk/lib/ReaderWriter/MachO/File.h
lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
Modified: lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=258160&r1=258159&r2=258160&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h Tue Jan 19 12:46:40 2016
@@ -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;
Modified: lld/trunk/lib/ReaderWriter/MachO/File.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/File.h?rev=258160&r1=258159&r2=258160&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/File.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/File.h Tue Jan 19 12:46:40 2016
@@ -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;
};
Modified: lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp?rev=258160&r1=258159&r2=258160&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachOLinkingContext.cpp Tue Jan 19 12:46:40 2016
@@ -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) {}
Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp?rev=258160&r1=258159&r2=258160&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp Tue Jan 19 12:46:40 2016
@@ -892,11 +892,6 @@ std::error_code parseObjCImageInfo(const
// 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
" 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();
More information about the llvm-commits
mailing list