diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-02-21 19:06:10 +0100 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-02-21 19:06:10 +0100 |
| commit | 60bc2e7616b0fd42c98ba8b9e0b212439b6ea1a0 (patch) | |
| tree | a7b067cbb12e047718cc324aa912ca613a22700a /src/link/Elf.zig | |
| parent | 1ca004176f8f76b1d54d878e002ebcc4362f9b92 (diff) | |
| download | zig-60bc2e7616b0fd42c98ba8b9e0b212439b6ea1a0.tar.gz zig-60bc2e7616b0fd42c98ba8b9e0b212439b6ea1a0.zip | |
elf: simplify logic for handling scanning relocs on different arches
Diffstat (limited to 'src/link/Elf.zig')
| -rw-r--r-- | src/link/Elf.zig | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 597b118807..be86b84018 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -2049,18 +2049,22 @@ fn scanRelocs(self: *Elf) !void { if (self.zigObjectPtr()) |zo| objects.appendAssumeCapacity(zo.index); objects.appendSliceAssumeCapacity(self.objects.items); + var has_reloc_errors = false; for (objects.items) |index| { self.file(index).?.scanRelocs(self, &undefs) catch |err| switch (err) { error.UnsupportedCpuArch => { try self.reportUnsupportedCpuArch(); return error.FlushFailure; }, + error.RelocFailure => has_reloc_errors = true, else => |e| return e, }; } try self.reportUndefinedSymbols(&undefs); + if (has_reloc_errors) return error.FlushFailure; + for (self.symbols.items, 0..) |*sym, i| { const index = @as(u32, @intCast(i)); if (!sym.isLocal(self) and !sym.flags.has_dynamic) { @@ -4449,6 +4453,8 @@ fn writeAtoms(self: *Elf) !void { undefs.deinit(); } + var has_reloc_errors = false; + // TODO iterate over `output_sections` directly for (self.shdrs.items, 0..) |shdr, shndx| { if (shdr.sh_type == elf.SHT_NULL) continue; @@ -4519,6 +4525,7 @@ fn writeAtoms(self: *Elf) !void { try self.reportUnsupportedCpuArch(); return error.FlushFailure; }, + error.RelocFailure => has_reloc_errors = true, else => |e| return e, }; } @@ -4527,6 +4534,8 @@ fn writeAtoms(self: *Elf) !void { } try self.reportUndefinedSymbols(&undefs); + + if (has_reloc_errors) return error.FlushFailure; } pub fn updateSymtabSize(self: *Elf) !void { |
