Commit 6925ef0f1a

Jakub Konka <kubkon@jakubkonka.com>
2022-12-27 16:11:31
zld: exclude strtab padding from uuid calculation
1 parent 8adcc22
Changed files (2)
src
link
MachO
test
link
macho
src/link/MachO/zld.zig
@@ -2727,7 +2727,8 @@ pub const Zld = struct {
                 conformUuid(&self.uuid_cmd.uuid);
             },
             else => {
-                const max_file_end = self.symtab_cmd.stroff + self.symtab_cmd.strsize;
+                // We set the max file size to the actual strtab buffer length to exclude any strtab padding.
+                const max_file_end = @intCast(u32, self.symtab_cmd.stroff + self.strtab.buffer.items.len);
 
                 const FileSubsection = struct {
                     start: u32,
test/link/macho/uuid/build.zig
@@ -5,9 +5,9 @@ const LibExeObjectStep = std.build.LibExeObjStep;
 pub fn build(b: *Builder) void {
     const test_step = b.step("test", "Test");
     test_step.dependOn(b.getInstallStep());
-    testUuid(b, test_step, .ReleaseSafe, "eb1203019e453d808d4f1e71053af9af");
-    testUuid(b, test_step, .ReleaseFast, "eb1203019e453d808d4f1e71053af9af");
-    testUuid(b, test_step, .ReleaseSmall, "eb1203019e453d808d4f1e71053af9af");
+    testUuid(b, test_step, .ReleaseSafe, "46b333df88f5314686fc0cba3b939ca8");
+    testUuid(b, test_step, .ReleaseFast, "46b333df88f5314686fc0cba3b939ca8");
+    testUuid(b, test_step, .ReleaseSmall, "46b333df88f5314686fc0cba3b939ca8");
 }
 
 fn testUuid(b: *Builder, test_step: *std.build.Step, mode: std.builtin.Mode, comptime exp: []const u8) void {