| ... | @@ -93,9 +93,6 @@ source_version_cmd_index: ?u16 = null, | ... | @@ -93,9 +93,6 @@ source_version_cmd_index: ?u16 = null, |
| 93 | build_version_cmd_index: ?u16 = null, | 93 | build_version_cmd_index: ?u16 = null, |
| 94 | uuid_cmd_index: ?u16 = null, | 94 | uuid_cmd_index: ?u16 = null, |
| 95 | code_signature_cmd_index: ?u16 = null, | 95 | code_signature_cmd_index: ?u16 = null, |
| 96 | /// Path to libSystem | | |
| 97 | /// TODO this is obsolete, remove it. | | |
| 98 | libsystem_cmd_index: ?u16 = null, | | |
| 99 | | 96 | |
| 100 | // __TEXT segment sections | 97 | // __TEXT segment sections |
| 101 | text_section_index: ?u16 = null, | 98 | text_section_index: ?u16 = null, |
| ... | @@ -281,15 +278,6 @@ const ideal_factor = 2; | ... | @@ -281,15 +278,6 @@ const ideal_factor = 2; |
| 281 | /// instead but this will do for now. | 278 | /// instead but this will do for now. |
| 282 | const DEFAULT_DYLD_PATH: [*:0]const u8 = "/usr/lib/dyld"; | 279 | const DEFAULT_DYLD_PATH: [*:0]const u8 = "/usr/lib/dyld"; |
| 283 | | 280 | |
| 284 | /// Default lib search path | | |
| 285 | /// TODO instead of hardcoding it, we should probably look through some env vars and search paths | | |
| 286 | /// instead but this will do for now. | | |
| 287 | const DEFAULT_LIB_SEARCH_PATH: []const u8 = "/usr/lib"; | | |
| 288 | | | |
| 289 | const LIB_SYSTEM_NAME: [*:0]const u8 = "System"; | | |
| 290 | /// TODO we should search for libSystem and fail if it doesn't exist, instead of hardcoding it | | |
| 291 | const LIB_SYSTEM_PATH: [*:0]const u8 = DEFAULT_LIB_SEARCH_PATH ++ "/libSystem.B.dylib"; | | |
| 292 | | | |
| 293 | /// In order for a slice of bytes to be considered eligible to keep metadata pointing at | 281 | /// In order for a slice of bytes to be considered eligible to keep metadata pointing at |
| 294 | /// it as a possible place to put new symbols, it must have enough room for this many bytes | 282 | /// it as a possible place to put new symbols, it must have enough room for this many bytes |
| 295 | /// (plus extra for reserved capacity). | 283 | /// (plus extra for reserved capacity). |
| ... | @@ -793,17 +781,17 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -793,17 +781,17 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 793 | Compilation.dump_argv(argv.items); | 781 | Compilation.dump_argv(argv.items); |
| 794 | } | 782 | } |
| 795 | | 783 | |
| | 784 | try self.parseInputFiles(positionals.items, self.base.options.sysroot); |
| | 785 | try self.parseLibs(libs.items, self.base.options.sysroot); |
| | 786 | try self.resolveSymbols(); |
| | 787 | try self.resolveDyldStubBinder(); |
| | 788 | try self.parseTextBlocks(); |
| 796 | try self.addRpathLCs(rpath_table.keys()); | 789 | try self.addRpathLCs(rpath_table.keys()); |
| | 790 | try self.addLoadDylibLCs(); |
| | 791 | try self.addDataInCodeLC(); |
| | 792 | try self.addCodeSignatureLC(); |
| 797 | | 793 | |
| 798 | if (use_stage1) { | 794 | if (use_stage1) { |
| 799 | try self.parseInputFiles(positionals.items, self.base.options.sysroot); | | |
| 800 | try self.parseLibs(libs.items, self.base.options.sysroot); | | |
| 801 | try self.resolveSymbols(); | | |
| 802 | try self.resolveDyldStubBinder(); | | |
| 803 | try self.parseTextBlocks(); | | |
| 804 | try self.addLoadDylibLCs(); | | |
| 805 | try self.addDataInCodeLC(); | | |
| 806 | try self.addCodeSignatureLC(); | | |
| 807 | try self.sortSections(); | 795 | try self.sortSections(); |
| 808 | try self.allocateTextSegment(); | 796 | try self.allocateTextSegment(); |
| 809 | try self.allocateDataConstSegment(); | 797 | try self.allocateDataConstSegment(); |
| ... | @@ -812,17 +800,6 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -812,17 +800,6 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 812 | try self.allocateTextBlocks(); | 800 | try self.allocateTextBlocks(); |
| 813 | try self.flushZld(); | 801 | try self.flushZld(); |
| 814 | } else { | 802 | } else { |
| 815 | // TODO this is just a temp; libsystem load command will be autoresolved when parsing libSystem from | | |
| 816 | // the linker line and actually referencing symbols. | | |
| 817 | if (self.libsystem_cmd_index == null) { | | |
| 818 | self.libsystem_cmd_index = @intCast(u16, self.load_commands.items.len); | | |
| 819 | var dylib_cmd = try commands.createLoadDylibCommand(self.base.allocator, mem.spanZ(LIB_SYSTEM_PATH), 2, 0, 0); | | |
| 820 | errdefer dylib_cmd.deinit(self.base.allocator); | | |
| 821 | try self.load_commands.append(self.base.allocator, .{ .Dylib = dylib_cmd }); | | |
| 822 | self.load_commands_dirty = true; | | |
| 823 | } | | |
| 824 | try self.addDataInCodeLC(); | | |
| 825 | try self.addCodeSignatureLC(); | | |
| 826 | try self.flushModule(comp); | 803 | try self.flushModule(comp); |
| 827 | } | 804 | } |
| 828 | } | 805 | } |