From 1d7d427c39ccfcbe693d787d0ea3aadae077ad20 Mon Sep 17 00:00:00 2001 From: Robert Pengelly Date: Thu, 6 Nov 2025 04:13:36 +0000 Subject: [PATCH] pad function starts to multiple of 8 so that the symbol table is also aligned --- macho.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/macho.c b/macho.c index beb5b30..f6d6a47 100644 --- 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); } -- 2.34.1