| ... | @@ -1516,11 +1516,6 @@ pub const Zld = struct { | ... | @@ -1516,11 +1516,6 @@ pub const Zld = struct { |
| 1516 | } | 1516 | } |
| 1517 | } | 1517 | } |
| 1518 | | 1518 | |
| 1519 | inline fn calcInstallNameLen(cmd_size: u64, name: []const u8, assume_max_path_len: bool) u64 { | | |
| 1520 | const name_len = if (assume_max_path_len) std.os.PATH_MAX else std.mem.len(name) + 1; | | |
| 1521 | return mem.alignForwardGeneric(u64, cmd_size + name_len, @alignOf(u64)); | | |
| 1522 | } | | |
| 1523 | | | |
| 1524 | fn calcLCsSize(self: *Zld, assume_max_path_len: bool) !u32 { | 1519 | fn calcLCsSize(self: *Zld, assume_max_path_len: bool) !u32 { |
| 1525 | const gpa = self.gpa; | 1520 | const gpa = self.gpa; |
| 1526 | | 1521 | |
| ... | @@ -1542,7 +1537,7 @@ pub const Zld = struct { | ... | @@ -1542,7 +1537,7 @@ pub const Zld = struct { |
| 1542 | // LC_DYSYMTAB | 1537 | // LC_DYSYMTAB |
| 1543 | sizeofcmds += @sizeOf(macho.dysymtab_command); | 1538 | sizeofcmds += @sizeOf(macho.dysymtab_command); |
| 1544 | // LC_LOAD_DYLINKER | 1539 | // LC_LOAD_DYLINKER |
| 1545 | sizeofcmds += calcInstallNameLen( | 1540 | sizeofcmds += MachO.calcInstallNameLen( |
| 1546 | @sizeOf(macho.dylinker_command), | 1541 | @sizeOf(macho.dylinker_command), |
| 1547 | mem.sliceTo(MachO.default_dyld_path, 0), | 1542 | mem.sliceTo(MachO.default_dyld_path, 0), |
| 1548 | false, | 1543 | false, |
| ... | @@ -1555,7 +1550,7 @@ pub const Zld = struct { | ... | @@ -1555,7 +1550,7 @@ pub const Zld = struct { |
| 1555 | if (self.options.output_mode == .Lib) { | 1550 | if (self.options.output_mode == .Lib) { |
| 1556 | sizeofcmds += blk: { | 1551 | sizeofcmds += blk: { |
| 1557 | const install_name = self.options.install_name orelse self.options.emit.?.sub_path; | 1552 | const install_name = self.options.install_name orelse self.options.emit.?.sub_path; |
| 1558 | break :blk calcInstallNameLen( | 1553 | break :blk MachO.calcInstallNameLen( |
| 1559 | @sizeOf(macho.dylib_command), | 1554 | @sizeOf(macho.dylib_command), |
| 1560 | install_name, | 1555 | install_name, |
| 1561 | assume_max_path_len, | 1556 | assume_max_path_len, |
| ... | @@ -1567,7 +1562,7 @@ pub const Zld = struct { | ... | @@ -1567,7 +1562,7 @@ pub const Zld = struct { |
| 1567 | var it = RpathIterator.init(gpa, self.options.rpath_list); | 1562 | var it = RpathIterator.init(gpa, self.options.rpath_list); |
| 1568 | defer it.deinit(); | 1563 | defer it.deinit(); |
| 1569 | while (try it.next()) |rpath| { | 1564 | while (try it.next()) |rpath| { |
| 1570 | sizeofcmds += calcInstallNameLen( | 1565 | sizeofcmds += MachO.calcInstallNameLen( |
| 1571 | @sizeOf(macho.rpath_command), | 1566 | @sizeOf(macho.rpath_command), |
| 1572 | rpath, | 1567 | rpath, |
| 1573 | assume_max_path_len, | 1568 | assume_max_path_len, |
| ... | @@ -1584,7 +1579,7 @@ pub const Zld = struct { | ... | @@ -1584,7 +1579,7 @@ pub const Zld = struct { |
| 1584 | for (self.referenced_dylibs.keys()) |id| { | 1579 | for (self.referenced_dylibs.keys()) |id| { |
| 1585 | const dylib = self.dylibs.items[id]; | 1580 | const dylib = self.dylibs.items[id]; |
| 1586 | const dylib_id = dylib.id orelse unreachable; | 1581 | const dylib_id = dylib.id orelse unreachable; |
| 1587 | sizeofcmds += calcInstallNameLen( | 1582 | sizeofcmds += MachO.calcInstallNameLen( |
| 1588 | @sizeOf(macho.dylib_command), | 1583 | @sizeOf(macho.dylib_command), |
| 1589 | dylib_id.name, | 1584 | dylib_id.name, |
| 1590 | assume_max_path_len, | 1585 | assume_max_path_len, |