| author | |
| committer | |
| log | 9908b10d928a12731a288bd59068151d386efdac |
| tree | f654d726c7fcb7eeed74772b922a7482d446fcfc |
| parent | 64dfaa568db04aedb72ac9070484a7e3bd987e24 |
| signature |
When no headerpad_size parameter is passed, Zig
doesn't reserve enough space for a codesign
signature. Signing the binary corrupts the first
bytes of __text, causing it to crash. The crash
only affects x86_64 since aarch64 binaries are
signed by the linker by default, so a new
signature just replaces the existing one. This
is a regression introduced by 7588eeccea on
2024-01-10.
The fix restores the behavior prior to the
regression by applying the default value.
Fixes #31428.1 files changed, 2 insertions(+), 1 deletions(-)
src/link/MachO/load_commands.zig+2-1| ... | ... | @@ -164,7 +164,8 @@ pub fn calcLoadCommandsSizeObject(macho_file: *MachO) u32 { |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | pub fn calcMinHeaderPadSize(macho_file: *MachO) !u32 { |
| 167 | var padding: u32 = (try calcLoadCommandsSize(macho_file, false)) + (macho_file.headerpad_size orelse 0); | |
| 167 | var padding: u32 = (try calcLoadCommandsSize(macho_file, false)) + | |
| 168 | (macho_file.headerpad_size orelse MachO.default_headerpad_size); | |
| 168 | 169 | log.debug("minimum requested headerpad size 0x{x}", .{padding + @sizeOf(macho.mach_header_64)}); |
| 169 | 170 | |
| 170 | 171 | if (macho_file.headerpad_max_install_names) { |