pad function starts to multiple of 8 so that the symbol table is also aligned
authorRobert Pengelly <robertapengelly@hotmail.com>
Thu, 6 Nov 2025 04:13:36 +0000 (04:13 +0000)
committerRobert Pengelly <robertapengelly@hotmail.com>
Thu, 6 Nov 2025 04:13:36 +0000 (04:13 +0000)
macho.c

diff --git a/macho.c b/macho.c
index beb5b304b561139093ddff78e3fc6e015cd2d6b2..f6d6a4788ef93ff35e5e2de973b4cb5ad4630bd5 100644 (file)
--- a/macho.c
+++ b/macho.c
@@ -1253,7 +1253,7 @@ void macho_write (const char *filename) {
             symbols_for_each_global (&function_starts_symbol_callback2);
             
             qsort (addresses, num_function_starts_symbols, sizeof (*addresses), &function_starts_address_compare);
-            function_starts = xmalloc (num_function_starts_symbols * (sizeof (uint64_t) * CHAR_BIT / 7 + 1));
+            function_starts = xmalloc (num_function_starts_symbols * (sizeof (uint64_t) * CHAR_BIT / 7 + 1) + 7);
             
             prev_rva = 0;
             p = function_starts;
@@ -1278,7 +1278,11 @@ void macho_write (const char *filename) {
             
             }
             
+            memset (p, 0, 7);
+            
+            p = function_starts + ALIGN (p - function_starts, 8);
             data_size += function_starts_size = p - function_starts;
+            
             free (addresses);
         
         }