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