| ... | ... | @@ -1709,26 +1709,14 @@ fn resolveSymbolsInObject(self: *MachO, object_id: u32) !void { |
| 1709 | 1709 | while (sym_index < in_symtab.len) : (sym_index += 1) { |
| 1710 | 1710 | const sym = &object.symtab[sym_index]; |
| 1711 | 1711 | const sym_name = object.getSymbolName(sym_index); |
| 1712 | const sym_with_loc = SymbolWithLoc{ |
| 1713 | .sym_index = sym_index, |
| 1714 | .file = object_id + 1, |
| 1715 | }; |
| 1712 | 1716 | |
| 1713 | | if (sym.stab()) { |
| 1714 | | log.err("unhandled symbol type: stab", .{}); |
| 1715 | | log.err(" symbol '{s}'", .{sym_name}); |
| 1716 | | log.err(" first definition in '{s}'", .{object.name}); |
| 1717 | | return error.UnhandledSymbolType; |
| 1718 | | } |
| 1719 | | |
| 1720 | | if (sym.indr()) { |
| 1721 | | log.err("unhandled symbol type: indirect", .{}); |
| 1722 | | log.err(" symbol '{s}'", .{sym_name}); |
| 1723 | | log.err(" first definition in '{s}'", .{object.name}); |
| 1724 | | return error.UnhandledSymbolType; |
| 1725 | | } |
| 1726 | | |
| 1727 | | if (sym.abs()) { |
| 1728 | | log.err("unhandled symbol type: absolute", .{}); |
| 1729 | | log.err(" symbol '{s}'", .{sym_name}); |
| 1730 | | log.err(" first definition in '{s}'", .{object.name}); |
| 1731 | | return error.UnhandledSymbolType; |
| 1717 | if (sym.stab() or sym.indr() or sym.abs()) { |
| 1718 | try self.reportUnhandledSymbolType(sym_with_loc); |
| 1719 | continue; |
| 1732 | 1720 | } |
| 1733 | 1721 | |
| 1734 | 1722 | if (sym.sect() and !sym.ext()) { |
| ... | ... | @@ -4892,7 +4880,7 @@ pub fn handleAndReportParseError( |
| 4892 | 4880 | path: []const u8, |
| 4893 | 4881 | err: ParseError, |
| 4894 | 4882 | ctx: *const ParseErrorCtx, |
| 4895 | | ) !void { |
| 4883 | ) error{OutOfMemory}!void { |
| 4896 | 4884 | const cpu_arch = self.base.options.target.cpu.arch; |
| 4897 | 4885 | switch (err) { |
| 4898 | 4886 | error.DylibAlreadyExists => {}, |
| ... | ... | @@ -4943,7 +4931,7 @@ fn reportDependencyError( |
| 4943 | 4931 | path: ?[]const u8, |
| 4944 | 4932 | comptime format: []const u8, |
| 4945 | 4933 | args: anytype, |
| 4946 | | ) !void { |
| 4934 | ) error{OutOfMemory}!void { |
| 4947 | 4935 | const gpa = self.base.allocator; |
| 4948 | 4936 | try self.misc_errors.ensureUnusedCapacity(gpa, 1); |
| 4949 | 4937 | var notes = try std.ArrayList(File.ErrorMsg).initCapacity(gpa, 2); |
| ... | ... | @@ -4958,7 +4946,12 @@ fn reportDependencyError( |
| 4958 | 4946 | }); |
| 4959 | 4947 | } |
| 4960 | 4948 | |
| 4961 | | fn reportParseError(self: *MachO, path: []const u8, comptime format: []const u8, args: anytype) !void { |
| 4949 | fn reportParseError( |
| 4950 | self: *MachO, |
| 4951 | path: []const u8, |
| 4952 | comptime format: []const u8, |
| 4953 | args: anytype, |
| 4954 | ) error{OutOfMemory}!void { |
| 4962 | 4955 | const gpa = self.base.allocator; |
| 4963 | 4956 | try self.misc_errors.ensureUnusedCapacity(gpa, 1); |
| 4964 | 4957 | var notes = try gpa.alloc(File.ErrorMsg, 1); |
| ... | ... | @@ -5030,6 +5023,35 @@ fn reportSymbolCollision( |
| 5030 | 5023 | self.misc_errors.appendAssumeCapacity(err_msg); |
| 5031 | 5024 | } |
| 5032 | 5025 | |
| 5026 | fn reportUnhandledSymbolType(self: *MachO, sym_with_loc: SymbolWithLoc) error{OutOfMemory}!void { |
| 5027 | const gpa = self.base.allocator; |
| 5028 | try self.misc_errors.ensureUnusedCapacity(gpa, 1); |
| 5029 | |
| 5030 | const notes = try gpa.alloc(File.ErrorMsg, 1); |
| 5031 | errdefer gpa.free(notes); |
| 5032 | |
| 5033 | const file = sym_with_loc.getFile().?; |
| 5034 | notes[0] = .{ .msg = try std.fmt.allocPrint(gpa, "defined in {s}", .{self.objects.items[file].name}) }; |
| 5035 | |
| 5036 | const sym = self.getSymbol(sym_with_loc); |
| 5037 | const sym_type = if (sym.stab()) |
| 5038 | "stab" |
| 5039 | else if (sym.indr()) |
| 5040 | "indirect" |
| 5041 | else if (sym.abs()) |
| 5042 | "absolute" |
| 5043 | else |
| 5044 | unreachable; |
| 5045 | |
| 5046 | self.misc_errors.appendAssumeCapacity(.{ |
| 5047 | .msg = try std.fmt.allocPrint(gpa, "unhandled symbol type: '{s}' has type {s}", .{ |
| 5048 | self.getSymbolName(sym_with_loc), |
| 5049 | sym_type, |
| 5050 | }), |
| 5051 | .notes = notes, |
| 5052 | }); |
| 5053 | } |
| 5054 | |
| 5033 | 5055 | /// Binary search |
| 5034 | 5056 | pub fn bsearch(comptime T: type, haystack: []align(1) const T, predicate: anytype) usize { |
| 5035 | 5057 | if (!@hasDecl(@TypeOf(predicate), "predicate")) |