diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-04 08:11:07 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-04 09:14:05 +0100 |
| commit | bd0416aeb6926225001b2f58a89115cc296708d7 (patch) | |
| tree | d2508fd55805bb5232308a612227c8c7733339c7 /src | |
| parent | 9cf3ebe524dcc3fe6e80174041c8ed6687cbfcaa (diff) | |
| download | zig-bd0416aeb6926225001b2f58a89115cc296708d7.tar.gz zig-bd0416aeb6926225001b2f58a89115cc296708d7.zip | |
elf: flag errors on hitting unimplemented codepaths
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/Elf.zig | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index a16fb83f1a..1667f7fc12 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1384,7 +1384,7 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node if (csu.crtn) |v| try positionals.append(.{ .path = v }); if (self.zigObjectPtr()) |zig_object| try zig_object.flushModule(self); - if (self.isStaticLib()) return self.flushStaticLib(comp); + if (self.isStaticLib()) return self.flushStaticLib(comp, positionals.items); for (positionals.items) |obj| { var parse_ctx: ParseErrorCtx = .{ .detected_cpu_arch = undefined }; @@ -1521,8 +1521,17 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node } } -pub fn flushStaticLib(self: *Elf, comp: *Compilation) link.File.FlushError!void { +pub fn flushStaticLib( + self: *Elf, + comp: *Compilation, + positionals: []const Compilation.LinkObject, +) link.File.FlushError!void { _ = comp; + if (positionals.len > 0) { + var err = try self.addErrorWithNotes(1); + try err.addMsg(self, "fatal linker error: too many input positionals", .{}); + try err.addNote(self, "TODO implement linking objects into an static library", .{}); + } const gpa = self.base.allocator; // First, we flush relocatable object file generated with our backends. @@ -1622,6 +1631,13 @@ pub fn flushStaticLib(self: *Elf, comp: *Compilation) link.File.FlushError!void pub fn flushObject(self: *Elf, comp: *Compilation) link.File.FlushError!void { _ = comp; + + if (self.objects.items.len > 0) { + var err = try self.addErrorWithNotes(1); + try err.addMsg(self, "fatal linker error: too many input positionals", .{}); + try err.addNote(self, "TODO implement '-r' option", .{}); + } + self.claimUnresolvedObject(); try self.initSections(); |
