summaryrefslogtreecommitdiffstats
path: root/lld/lib
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2016-01-16 00:07:22 +0000
committerPete Cooper <peter_cooper@apple.com>2016-01-16 00:07:22 +0000
commita014ffef87a537524811b041ea6b88bec14eee50 (patch)
treeaf97f4b4f89a3b0dab63529c801257e963a671e5 /lld/lib
parent628bc3ec00e487daefb7399e48d6364e7449a09e (diff)
downloadbcm5719-llvm-a014ffef87a537524811b041ea6b88bec14eee50.tar.gz
bcm5719-llvm-a014ffef87a537524811b041ea6b88bec14eee50.zip
Add checking of differing swift versions in input files.
Swift versions are part of the objc image info section, and must match for all files linked which actually have an image info section llvm-svn: 257964
Diffstat (limited to 'lld/lib')
-rw-r--r--lld/lib/ReaderWriter/MachO/File.h4
-rw-r--r--lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp11
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp3
3 files changed, 18 insertions, 0 deletions
diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h
index 24e042ed3b5..c95b2da989a 100644
--- a/lld/lib/ReaderWriter/MachO/File.h
+++ b/lld/lib/ReaderWriter/MachO/File.h
@@ -194,6 +194,9 @@ public:
MachOLinkingContext::OS OS() const { return _os; }
void setOS(MachOLinkingContext::OS os) { _os = os; }
+ uint32_t swiftVersion() const { return _swiftVersion; }
+ void setSwiftVersion(uint32_t v) { _swiftVersion = v; }
+
/// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const File *F) {
return F->kind() == File::kindMachObject;
@@ -234,6 +237,7 @@ private:
NameToAtom _undefAtoms;
MachOLinkingContext::Arch _arch = MachOLinkingContext::arch_unknown;
MachOLinkingContext::OS _os = MachOLinkingContext::OS::unknown;
+ uint32_t _swiftVersion = 0;
};
class MachODylibFile : public SharedLibraryFile {
diff --git a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
index c129e9e529c..6987f7afb06 100644
--- a/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachOLinkingContext.cpp
@@ -145,6 +145,7 @@ 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),
@@ -1015,6 +1016,16 @@ std::error_code MachOLinkingContext::handleLoadedFile(File &file) {
return make_dynamic_error_code(file.path() +
Twine(" cannot be linked due to incompatible operating systems"));
}
+
+ // Check that the swift version of the context matches that of the file.
+ // Also set the swift version of the context if it didn't have one.
+ if (!_swiftVersion) {
+ _swiftVersion = machoFile->swiftVersion();
+ } else if (machoFile->swiftVersion() &&
+ machoFile->swiftVersion() != _swiftVersion) {
+ // Swift versions are different.
+ return make_dynamic_error_code("different swift versions");
+ }
return std::error_code();
}
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
index 770b58b2270..78c930bac0f 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp
@@ -911,6 +911,9 @@ std::error_code parseObjCImageInfo(const NormalizedFile &normalizedFile,
" in file " + file.path() +
" should have version=0");
+ uint32_t flags = read32(content.data() + 4, isBig);
+ file.setSwiftVersion((flags >> 8) & 0xFF);
+
return std::error_code();
}
OpenPOWER on IntegriCloud