[lld] r260248 - Aligned __stub_helper section to 4-bytes.
Pete Cooper via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 9 10:56:38 PST 2016
Author: pete
Date: Tue Feb 9 12:56:37 2016
New Revision: 260248
URL: http://llvm.org/viewvc/llvm-project?rev=260248&view=rev
Log:
Aligned __stub_helper section to 4-bytes.
ld64 aligns most of the stub's to 2 byte alignment, expect for
the stub helper common atoms which are 4 byte aligned.
This adds a new field to StubInfo which tracks this alignment
and ensures that this is the alignment we get in the final image.
rdar://problem/24570220
Modified:
lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
lld/trunk/test/mach-o/lazy-bind-x86_64.yaml
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h?rev=260248&r1=260247&r2=260248&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler.h Tue Feb 9 12:56:37 2016
@@ -256,6 +256,7 @@ public:
ReferenceInfo stubHelperReferenceToHelperCommon;
uint32_t stubHelperCommonSize;
+ uint8_t stubHelperCommonAlignment;
uint8_t stubHelperCommonBytes[36];
ReferenceInfo stubHelperCommonReferenceToCache;
OptionalRefInfo optStubHelperCommonReferenceToCache;
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp?rev=260248&r1=260247&r2=260248&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm.cpp Tue Feb 9 12:56:37 2016
@@ -262,6 +262,8 @@ const ArchHandler::StubInfo ArchHandler_
// Stub Helper-Common size and code
36,
+ // Stub helper alignment
+ 2,
{ // push lazy-info-offset
0x04, 0xC0, 0x2D, 0xE5, // str ip, [sp, #-4]!
// push address of dyld_mageLoaderCache
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp?rev=260248&r1=260247&r2=260248&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp Tue Feb 9 12:56:37 2016
@@ -285,6 +285,8 @@ const ArchHandler::StubInfo ArchHandler_
// Stub Helper-Common size and code
24,
+ // Stub helper alignment
+ 2,
{ 0x11, 0x00, 0x00, 0x90, // ADRP X17, dyld_ImageLoaderCache at page
0x31, 0x02, 0x00, 0x91, // ADD X17, X17, dyld_ImageLoaderCache at pageoff
0xF0, 0x47, 0xBF, 0xA9, // STP X16/X17, [SP, #-16]!
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp?rev=260248&r1=260247&r2=260248&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86.cpp Tue Feb 9 12:56:37 2016
@@ -218,6 +218,8 @@ const ArchHandler::StubInfo ArchHandler_
// Stub Helper-Common size and code
12,
+ // Stub helper alignment
+ 2,
{ 0x68, 0x00, 0x00, 0x00, 0x00, // pushl $dyld_ImageLoaderCache
0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *_fast_lazy_bind
0x90 }, // nop
Modified: lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp?rev=260248&r1=260247&r2=260248&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp Tue Feb 9 12:56:37 2016
@@ -286,6 +286,8 @@ const ArchHandler::StubInfo ArchHandler_
// Stub Helper-Common size and code
16,
+ // Stub helper alignment
+ 2,
{ 0x4C, 0x8D, 0x1D, 0x00, 0x00, 0x00, 0x00, // leaq cache(%rip),%r11
0x41, 0x53, // push %r11
0xFF, 0x25, 0x00, 0x00, 0x00, 0x00, // jmp *binder(%rip)
Modified: lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp?rev=260248&r1=260247&r2=260248&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/StubsPass.cpp Tue Feb 9 12:56:37 2016
@@ -175,7 +175,7 @@ public:
}
Alignment alignment() const override {
- return 1 << _stubInfo.codeAlignment;
+ return 1 << _stubInfo.stubHelperCommonAlignment;
}
uint64_t size() const override {
Modified: lld/trunk/test/mach-o/lazy-bind-x86_64.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/mach-o/lazy-bind-x86_64.yaml?rev=260248&r1=260247&r2=260248&view=diff
==============================================================================
--- lld/trunk/test/mach-o/lazy-bind-x86_64.yaml (original)
+++ lld/trunk/test/mach-o/lazy-bind-x86_64.yaml Tue Feb 9 12:56:37 2016
@@ -83,6 +83,13 @@ undefined-symbols:
# CHECK-HELPERS: 68 10 00 00 00 pushq $16
# CHECK-HELPERS: 68 20 00 00 00 pushq $32
+# Make sure the stub helper is correctly aligned
+# CHECK-DYLIBS: sectname __stub_helper
+# CHECK-DYLIBS-NEXT: segname __TEXT
+# CHECK-DYLIBS-NEXT: addr
+# CHECK-DYLIBS-NEXT: size
+# CHECK-DYLIBS-NEXT: offset
+# CHECK-DYLIBS-NEXT: align 2^2 (4)
# CHECK-DYLIBS: cmd LC_LOAD_DYLIB
# CHECK-DYLIBS: name /usr/lib/libbar.dylib (offset 24)
More information about the llvm-commits
mailing list