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

llvm-svn: 260248
This commit is contained in:
Pete Cooper 2016-02-09 18:56:37 +00:00
parent cc3a4595f7
commit 35c3318edc
7 changed files with 17 additions and 1 deletions

View File

@ -256,6 +256,7 @@ public:
ReferenceInfo stubHelperReferenceToHelperCommon;
uint32_t stubHelperCommonSize;
uint8_t stubHelperCommonAlignment;
uint8_t stubHelperCommonBytes[36];
ReferenceInfo stubHelperCommonReferenceToCache;
OptionalRefInfo optStubHelperCommonReferenceToCache;

View File

@ -262,6 +262,8 @@ const ArchHandler::StubInfo ArchHandler_arm::_sStubInfoArmPIC = {
// 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

View File

@ -285,6 +285,8 @@ const ArchHandler::StubInfo ArchHandler_arm64::_sStubInfo = {
// Stub Helper-Common size and code
24,
// Stub helper alignment
2,
{ 0x11, 0x00, 0x00, 0x90, // ADRP X17, dyld_ImageLoaderCache@page
0x31, 0x02, 0x00, 0x91, // ADD X17, X17, dyld_ImageLoaderCache@pageoff
0xF0, 0x47, 0xBF, 0xA9, // STP X16/X17, [SP, #-16]!

View File

@ -218,6 +218,8 @@ const ArchHandler::StubInfo ArchHandler_x86::_sStubInfo = {
// 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

View File

@ -286,6 +286,8 @@ const ArchHandler::StubInfo ArchHandler_x86_64::_sStubInfo = {
// 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)

View File

@ -175,7 +175,7 @@ public:
}
Alignment alignment() const override {
return 1 << _stubInfo.codeAlignment;
return 1 << _stubInfo.stubHelperCommonAlignment;
}
uint64_t size() const override {

View File

@ -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)