From 5c4693d8d20ad5fb354f247907376cd9d07d514f Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Thu, 6 Nov 2014 01:09:13 +0000 Subject: [PATCH] [mach-o] Add support for interposing tuples section Darwin uses two-level-namespace lookup for symbols which means the static linker records where each symbol must be found at runtime. Thus defining a symbol in a dylib loaded earlier will not effect where symbols needed by later dylibs will be found. Instead overriding is done through a section of type S_INTERPOSING which contains tuples of . llvm-svn: 221421 --- lld/include/lld/Core/DefinedAtom.h | 1 + lld/lib/Core/DefinedAtom.cpp | 1 + lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 1 + lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp | 2 ++ lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp | 2 ++ 5 files changed, 7 insertions(+) diff --git a/lld/include/lld/Core/DefinedAtom.h b/lld/include/lld/Core/DefinedAtom.h index 65c0481..38e58382 100644 --- a/lld/include/lld/Core/DefinedAtom.h +++ b/lld/include/lld/Core/DefinedAtom.h @@ -135,6 +135,7 @@ public: typeObjCClassPtr, // pointer to ObjC class [Darwin] typeObjC2CategoryList, // pointers to ObjC category [Darwin] typeDTraceDOF, // runtime data for Dtrace [Darwin] + typeInterposingTuples, // tuples of interposing info for dyld [Darwin] typeTempLTO, // temporary atom for bitcode reader typeCompactUnwindInfo, // runtime data for unwinder [Darwin] typeProcessedUnwindInfo,// compressed compact unwind info [Darwin] diff --git a/lld/lib/Core/DefinedAtom.cpp b/lld/lib/Core/DefinedAtom.cpp index 6b9a08a..fa2fa45 100644 --- a/lld/lib/Core/DefinedAtom.cpp +++ b/lld/lib/Core/DefinedAtom.cpp @@ -64,6 +64,7 @@ DefinedAtom::ContentPermissions DefinedAtom::permissions(ContentType type) { case typeCStringPtr: case typeObjCClassPtr: case typeObjC2CategoryList: + case typeInterposingTuples: case typeTLVInitialData: case typeTLVInitialZeroFill: case typeTLVInitializerPtr: diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index dc015c5..abde41a 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -231,6 +231,7 @@ const MachOFinalSectionFromAtomType sectsToAtomType[] = { ENTRY("__DATA", "___got", S_NON_LAZY_SYMBOL_POINTERS, typeGOT), ENTRY("__DATA", "___bss", S_ZEROFILL, typeZeroFill), + ENTRY("__DATA", "__interposing", S_INTERPOSING, typeInterposingTuples), }; #undef ENTRY diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp index 54899b0..ec66d48 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp @@ -77,6 +77,8 @@ const MachORelocatableSectionToAtomType sectsToAtomType[] = { ENTRY("__DATA", "___bss", S_ZEROFILL, typeZeroFill), ENTRY("", "", S_NON_LAZY_SYMBOL_POINTERS, typeGOT), + ENTRY("__DATA", "__interposing", S_INTERPOSING, typeInterposingTuples), + ENTRY("", "", S_INTERPOSING, typeInterposingTuples), ENTRY("__LD", "__compact_unwind", S_REGULAR, typeCompactUnwindInfo), ENTRY("", "", S_REGULAR, typeUnknown) diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp index 31fd4db..72537b9 100644 --- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -437,6 +437,8 @@ template <> struct ScalarEnumerationTraits { DefinedAtom::typeObjC2CategoryList); io.enumCase(value, "objc-class1", DefinedAtom::typeObjC1Class); io.enumCase(value, "dtraceDOF", DefinedAtom::typeDTraceDOF); + io.enumCase(value, "interposing-tuples", + DefinedAtom::typeInterposingTuples); io.enumCase(value, "lto-temp", DefinedAtom::typeTempLTO); io.enumCase(value, "compact-unwind", DefinedAtom::typeCompactUnwindInfo); io.enumCase(value, "unwind-info", DefinedAtom::typeProcessedUnwindInfo); -- 2.7.4