Commit 3af6a4e887

Jakub Konka <kubkon@jakubkonka.com>
2022-12-15 11:25:54
macho: generate stabs last to aid in deterministic uuid calculation
1 parent 6b99aab
Changed files (1)
src
link
MachO
src/link/MachO/zld.zig
@@ -2556,12 +2556,6 @@ pub const Zld = struct {
             }
         }
 
-        if (!self.options.strip) {
-            for (self.objects.items) |object| {
-                try self.generateSymbolStabs(object, &locals);
-            }
-        }
-
         var exports = std.ArrayList(macho.nlist_64).init(gpa);
         defer exports.deinit();
 
@@ -2592,6 +2586,14 @@ pub const Zld = struct {
             try imports_table.putNoClobber(global, new_index);
         }
 
+        // We generate stabs last in order to ensure that the strtab always has debug info
+        // strings trailing
+        if (!self.options.strip) {
+            for (self.objects.items) |object| {
+                try self.generateSymbolStabs(object, &locals);
+            }
+        }
+
         const nlocals = @intCast(u32, locals.items.len);
         const nexports = @intCast(u32, exports.items.len);
         const nimports = @intCast(u32, imports.items.len);