]> git.saurik.com Git - apple/dyld.git/blobdiff - src/dyldNew.cpp
dyld-851.27.tar.gz
[apple/dyld.git] / src / dyldNew.cpp
index 06cc6be5b06a1017f3ed7516a14fdae59af07274..2bdafba21da777798b99a917f906e6d5e87d7811 100644 (file)
@@ -51,7 +51,10 @@ struct dyld_static_pool {
        dyld_static_pool*       previousPool;
        uint8_t*                        current;
        uint8_t*                        end;
-       uint8_t                         pool[1]; 
+
+    // libunwind, and probably others, need the pool to be 16-byte aligned as malloc guarantees that
+    __attribute__((__aligned__(16)))
+    uint8_t                            pool[1];
 };
 
 // allocate initial pool independently of pool header to take less space on disk
@@ -68,6 +71,9 @@ void* malloc(size_t size)
                return p;
        }
        else {
+        // keep allocations 16-byte aligned
+        size = ((size + 15) & -16);
+
                if ( size > DYLD_POOL_CHUNK_SIZE ) {
                        dyld::log("dyld malloc overflow: size=%lu\n", size);
                        dyld::halt("dyld malloc overflow\n");