| ... | @@ -1760,6 +1760,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { | ... | @@ -1760,6 +1760,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { |
| 1760 | } | 1760 | } |
| 1761 | | 1761 | |
| 1762 | const ParseError = error{ | 1762 | const ParseError = error{ |
| | 1763 | LinkFail, |
| 1763 | UnknownFileType, | 1764 | UnknownFileType, |
| 1764 | InvalidCpuArch, | 1765 | InvalidCpuArch, |
| 1765 | OutOfMemory, | 1766 | OutOfMemory, |
| ... | @@ -1769,6 +1770,7 @@ const ParseError = error{ | ... | @@ -1769,6 +1770,7 @@ const ParseError = error{ |
| 1769 | FileSystem, | 1770 | FileSystem, |
| 1770 | NotSupported, | 1771 | NotSupported, |
| 1771 | InvalidCharacter, | 1772 | InvalidCharacter, |
| | 1773 | MalformedObject, |
| 1772 | } || LdScript.Error || std.os.AccessError || std.os.SeekError || std.fs.File.OpenError || std.fs.File.ReadError; | 1774 | } || LdScript.Error || std.os.AccessError || std.os.SeekError || std.fs.File.OpenError || std.fs.File.ReadError; |
| 1773 | | 1775 | |
| 1774 | fn parsePositional(self: *Elf, path: []const u8, must_link: bool, ctx: *ParseErrorCtx) ParseError!void { | 1776 | fn parsePositional(self: *Elf, path: []const u8, must_link: bool, ctx: *ParseErrorCtx) ParseError!void { |
| ... | @@ -6057,6 +6059,7 @@ fn handleAndReportParseError( | ... | @@ -6057,6 +6059,7 @@ fn handleAndReportParseError( |
| 6057 | ) error{OutOfMemory}!void { | 6059 | ) error{OutOfMemory}!void { |
| 6058 | const cpu_arch = self.base.options.target.cpu.arch; | 6060 | const cpu_arch = self.base.options.target.cpu.arch; |
| 6059 | switch (err) { | 6061 | switch (err) { |
| | 6062 | error.LinkFail => {}, // already reported |
| 6060 | error.UnknownFileType => try self.reportParseError(path, "unknown file type", .{}), | 6063 | error.UnknownFileType => try self.reportParseError(path, "unknown file type", .{}), |
| 6061 | error.InvalidCpuArch => try self.reportParseError( | 6064 | error.InvalidCpuArch => try self.reportParseError( |
| 6062 | path, | 6065 | path, |
| ... | @@ -6082,6 +6085,17 @@ fn reportParseError( | ... | @@ -6082,6 +6085,17 @@ fn reportParseError( |
| 6082 | try err.addNote(self, "while parsing {s}", .{path}); | 6085 | try err.addNote(self, "while parsing {s}", .{path}); |
| 6083 | } | 6086 | } |
| 6084 | | 6087 | |
| | 6088 | pub fn reportParseError2( |
| | 6089 | self: *Elf, |
| | 6090 | file_index: File.Index, |
| | 6091 | comptime format: []const u8, |
| | 6092 | args: anytype, |
| | 6093 | ) error{OutOfMemory}!void { |
| | 6094 | var err = try self.addErrorWithNotes(1); |
| | 6095 | try err.addMsg(self, format, args); |
| | 6096 | try err.addNote(self, "while parsing {}", .{self.file(file_index).?.fmtPath()}); |
| | 6097 | } |
| | 6098 | |
| 6085 | const FormatShdrCtx = struct { | 6099 | const FormatShdrCtx = struct { |
| 6086 | elf_file: *Elf, | 6100 | elf_file: *Elf, |
| 6087 | shdr: elf.Elf64_Shdr, | 6101 | shdr: elf.Elf64_Shdr, |