diff options
| author | Pete Cooper <peter_cooper@apple.com> | 2016-02-09 20:11:17 +0000 |
|---|---|---|
| committer | Pete Cooper <peter_cooper@apple.com> | 2016-02-09 20:11:17 +0000 |
| commit | e8d9df4ea52a5652a13f080614507d70e9f9ad79 (patch) | |
| tree | 3fb45502872d4df3ddef231d5ed79dae45ba2c6b | |
| parent | a951e8ece71b6393b602fd3d5f3538a264508673 (diff) | |
| download | bcm5719-llvm-e8d9df4ea52a5652a13f080614507d70e9f9ad79.tar.gz bcm5719-llvm-e8d9df4ea52a5652a13f080614507d70e9f9ad79.zip | |
Use __nl_symbol_ptr instead of __got in the stubs pass on x86 archs.
The non lazy atoms generated in the stubs pass use an image cache to
hold all of the pointers. On arm archs, this is the __got section,
but on x86 archs it should be __nl_symbol_ptr.
rdar://problem/24572729
llvm-svn: 260271
| -rw-r--r-- | lld/include/lld/Core/DefinedAtom.h | 1 | ||||
| -rw-r--r-- | lld/lib/Core/DefinedAtom.cpp | 1 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ArchHandler.h | 2 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp | 3 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 2 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/StubsPass.cpp | 13 | ||||
| -rw-r--r-- | lld/test/mach-o/lazy-bind-x86_64.yaml | 4 |
10 files changed, 30 insertions, 5 deletions
diff --git a/lld/include/lld/Core/DefinedAtom.h b/lld/include/lld/Core/DefinedAtom.h index 56e94e78747..8384475c24f 100644 --- a/lld/include/lld/Core/DefinedAtom.h +++ b/lld/include/lld/Core/DefinedAtom.h @@ -129,6 +129,7 @@ public: typeObjC1Class, // ObjC1 class [Darwin] typeLazyPointer, // pointer through which a stub jumps typeLazyDylibPointer, // pointer through which a stub jumps [Darwin] + typeNonLazyPointer, // pointer to external symbol typeCFString, // NS/CFString object [Darwin] typeGOT, // pointer to external symbol typeInitializerPtr, // pointer to initializer function diff --git a/lld/lib/Core/DefinedAtom.cpp b/lld/lib/Core/DefinedAtom.cpp index 35596e6929f..09c52f85ae5 100644 --- a/lld/lib/Core/DefinedAtom.cpp +++ b/lld/lib/Core/DefinedAtom.cpp @@ -54,6 +54,7 @@ DefinedAtom::ContentPermissions DefinedAtom::permissions(ContentType type) { case typeObjC1Class: case typeLazyPointer: case typeLazyDylibPointer: + case typeNonLazyPointer: case typeThunkTLV: case typeRWNote: return permRW_; diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler.h b/lld/lib/ReaderWriter/MachO/ArchHandler.h index ed52fbcdfdd..379228f3b63 100644 --- a/lld/lib/ReaderWriter/MachO/ArchHandler.h +++ b/lld/lib/ReaderWriter/MachO/ArchHandler.h @@ -255,6 +255,8 @@ public: ReferenceInfo stubHelperReferenceToImm; ReferenceInfo stubHelperReferenceToHelperCommon; + DefinedAtom::ContentType stubHelperImageCacheContentType; + uint32_t stubHelperCommonSize; uint8_t stubHelperCommonAlignment; uint8_t stubHelperCommonBytes[36]; diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp b/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp index 700f64a2af9..45c696e62d2 100644 --- a/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp +++ b/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp @@ -260,6 +260,9 @@ const ArchHandler::StubInfo ArchHandler_arm::_sStubInfoArmPIC = { { Reference::KindArch::ARM, lazyImmediateLocation, 8, 0 }, { Reference::KindArch::ARM, arm_b24, 4, 0 }, + // Stub helper image cache content type + DefinedAtom::typeGOT, + // Stub Helper-Common size and code 36, // Stub helper alignment diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp b/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp index 58daa67fddb..af89e6dcf47 100644 --- a/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp +++ b/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp @@ -283,6 +283,9 @@ const ArchHandler::StubInfo ArchHandler_arm64::_sStubInfo = { { Reference::KindArch::AArch64, lazyImmediateLocation, 8, 0 }, { Reference::KindArch::AArch64, branch26, 4, 0 }, + // Stub helper image cache content type + DefinedAtom::typeGOT, + // Stub Helper-Common size and code 24, // Stub helper alignment diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp b/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp index 273c7858ffe..15e1963be23 100644 --- a/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp +++ b/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp @@ -216,6 +216,9 @@ const ArchHandler::StubInfo ArchHandler_x86::_sStubInfo = { { Reference::KindArch::x86, lazyImmediateLocation, 1, 0 }, { Reference::KindArch::x86, branch32, 6, 0 }, + // Stub helper image cache content type + DefinedAtom::typeNonLazyPointer, + // Stub Helper-Common size and code 12, // Stub helper alignment diff --git a/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp b/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp index 9951ff90480..d3dcbd157d3 100644 --- a/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp +++ b/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp @@ -284,6 +284,9 @@ const ArchHandler::StubInfo ArchHandler_x86_64::_sStubInfo = { { Reference::KindArch::x86_64, lazyImmediateLocation, 1, 0 }, { Reference::KindArch::x86_64, branch32, 6, 0 }, + // Stub helper image cache content type + DefinedAtom::typeNonLazyPointer, + // Stub Helper-Common size and code 16, // Stub helper alignment diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index b34f70343cd..b412a6ce7a8 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -283,6 +283,8 @@ const MachOFinalSectionFromAtomType sectsToAtomType[] = { typeTerminatorPtr), ENTRY("__DATA", "__got", S_NON_LAZY_SYMBOL_POINTERS, typeGOT), + ENTRY("__DATA", "__nl_symbol_ptr", S_NON_LAZY_SYMBOL_POINTERS, + typeNonLazyPointer), ENTRY("__DATA", "__thread_vars", S_THREAD_LOCAL_VARIABLES, typeThunkTLV), ENTRY("__DATA", "__thread_data", S_THREAD_LOCAL_REGULAR, diff --git a/lld/lib/ReaderWriter/MachO/StubsPass.cpp b/lld/lib/ReaderWriter/MachO/StubsPass.cpp index 88eaf3023bf..2e78d5e6d75 100644 --- a/lld/lib/ReaderWriter/MachO/StubsPass.cpp +++ b/lld/lib/ReaderWriter/MachO/StubsPass.cpp @@ -68,11 +68,11 @@ private: // class NonLazyPointerAtom : public SimpleDefinedAtom { public: - NonLazyPointerAtom(const File &file, bool is64) - : SimpleDefinedAtom(file), _is64(is64) { } + NonLazyPointerAtom(const File &file, bool is64, ContentType contentType) + : SimpleDefinedAtom(file), _is64(is64), _contentType(contentType) { } ContentType contentType() const override { - return DefinedAtom::typeGOT; + return _contentType; } Alignment alignment() const override { @@ -95,6 +95,7 @@ public: private: const bool _is64; + const ContentType _contentType; }; // @@ -239,9 +240,11 @@ public: SimpleDefinedAtom *helperCommonAtom = new (_file.allocator()) StubHelperCommonAtom(_file, _stubInfo); SimpleDefinedAtom *helperCacheNLPAtom = - new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit()); + new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit(), + _stubInfo.stubHelperImageCacheContentType); SimpleDefinedAtom *helperBinderNLPAtom = - new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit()); + new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit(), + _stubInfo.stubHelperImageCacheContentType); addReference(helperCommonAtom, _stubInfo.stubHelperCommonReferenceToCache, helperCacheNLPAtom); addOptReference( diff --git a/lld/test/mach-o/lazy-bind-x86_64.yaml b/lld/test/mach-o/lazy-bind-x86_64.yaml index 72522051ba5..ee3e2278b15 100644 --- a/lld/test/mach-o/lazy-bind-x86_64.yaml +++ b/lld/test/mach-o/lazy-bind-x86_64.yaml @@ -91,6 +91,10 @@ undefined-symbols: # CHECK-DYLIBS-NEXT: offset # CHECK-DYLIBS-NEXT: align 2^2 (4) +# Make sure the __nl_symbol_ptr section is used instea of __got as this is x86_64 +# CHECK-DYLIBS: sectname __nl_symbol_ptr +# CHECK-DYLIBS-NEXT: segname __DATA + # CHECK-DYLIBS: cmd LC_LOAD_DYLIB # CHECK-DYLIBS: name /usr/lib/libbar.dylib (offset 24) # CHECK-DYLIBS: current version 2.3.0 |

