diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2021-06-15 14:55:12 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-15 14:55:12 +0200 |
| commit | 0f4173c5d834dca2710005ffc1e040a4b307df00 (patch) | |
| tree | d0826553e15baa9a52c8ba4c1e89f204334401f4 /src | |
| parent | 7f9076c77124d9fdc10863e96f17b4ad36626ddb (diff) | |
| parent | 82047633281252aed14b44831e8920950f8c7dd6 (diff) | |
| download | zig-0f4173c5d834dca2710005ffc1e040a4b307df00.tar.gz zig-0f4173c5d834dca2710005ffc1e040a4b307df00.zip | |
Merge pull request #9122 from ziglang/zld-proxies
zld: clean up stubs resolution, error messages and use ld64 defaults for system libs resolution
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/MachO.zig | 7 | ||||
| -rw-r--r-- | src/link/MachO/Zld.zig | 20 |
2 files changed, 11 insertions, 16 deletions
diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 4de1708ff8..8c1d092f12 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -758,10 +758,11 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { } } - // Search for static libraries first, then dynamic libraries. - // TODO Respect flags such as -search_paths_first to the linker. + // Assume ld64 default: -search_paths_first + // Look in each directory for a dylib (tbd), and then for archive + // TODO implement alternative: -search_dylibs_first // TODO text-based API, or .tbd files. - const exts = &[_][]const u8{ "a", "dylib" }; + const exts = &[_][]const u8{ "dylib", "a" }; for (search_lib_names.items) |l_name| { var found = false; diff --git a/src/link/MachO/Zld.zig b/src/link/MachO/Zld.zig index c0b5f03c58..dcaf86ed67 100644 --- a/src/link/MachO/Zld.zig +++ b/src/link/MachO/Zld.zig @@ -1891,7 +1891,6 @@ fn resolveStubsAndGotEntries(self: *Zld) !void { const relocs = sect.relocs orelse continue; for (relocs) |rel| { switch (rel.@"type") { - .unsigned => continue, .got_page, .got_page_off, .got_load, .got, .pointer_to_got => { const sym = rel.target.symbol.getTopmostAlias(); if (sym.got_index != null) continue; @@ -2025,12 +2024,9 @@ fn resolveRelocsAndWriteSections(self: *Zld) !void { const got = dc_seg.sections.items[self.got_section_index.?]; const final = rel.target.symbol.getTopmostAlias(); const got_index = final.got_index orelse { - // TODO remove this when we can link against TAPI files. - log.err("undefined reference to symbol '{s}'", .{final.name}); - log.err(" | referenced in {s}", .{ - rel.target.symbol.cast(Symbol.Unresolved).?.file.name.?, - }); - return error.UndefinedSymbolReference; + log.err("expected GOT index relocating symbol '{s}'", .{final.name}); + log.err("this is an internal linker error", .{}); + return error.FailedToResolveRelocationTarget; }; args.target_addr = got.addr + got_index * @sizeOf(u64); }, @@ -2099,16 +2095,14 @@ fn relocTargetAddr(self: *Zld, object: *const Object, target: reloc.Relocation.T const segment = self.load_commands.items[self.text_segment_cmd_index.?].Segment; const stubs = segment.sections.items[self.stubs_section_index.?]; const stubs_index = proxy.base.stubs_index orelse { - // TODO remove this when we can link against TAPI files. - log.err("undefined reference to symbol '{s}'", .{final.name}); - log.err(" | referenced in {s}", .{ - sym.cast(Symbol.Unresolved).?.file.name.?, - }); - return error.UndefinedSymbolReference; + log.err("expected stubs index when relocating symbol '{s}'", .{final.name}); + log.err("this is an internal linker error", .{}); + return error.FailedToResolveRelocationTarget; }; break :blk stubs.addr + stubs_index * stubs.reserved2; } else { log.err("failed to resolve symbol '{s}' as a relocation target", .{sym.name}); + log.err("this is an internal linker error", .{}); return error.FailedToResolveRelocationTarget; } }, |
