aboutsummaryrefslogtreecommitdiff
path: root/src/link/Elf/relocation.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2024-02-17 12:35:12 +0100
committerJakub Konka <kubkon@jakubkonka.com>2024-02-17 12:35:16 +0100
commit509c7149b9f30e3271f2f8ba7669b95d2d240b9b (patch)
treeaa434782cf9b3d02dcaf8b7e7e712f1a615f713f /src/link/Elf/relocation.zig
parent5fb54736dffc6c991312e4e57ae00688bbf8e801 (diff)
downloadzig-509c7149b9f30e3271f2f8ba7669b95d2d240b9b.tar.gz
zig-509c7149b9f30e3271f2f8ba7669b95d2d240b9b.zip
elf: fix formatting of relocs when reloc can be Zig specific
Diffstat (limited to 'src/link/Elf/relocation.zig')
-rw-r--r--src/link/Elf/relocation.zig16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/link/Elf/relocation.zig b/src/link/Elf/relocation.zig
index b6803f9166..60ae54a6e9 100644
--- a/src/link/Elf/relocation.zig
+++ b/src/link/Elf/relocation.zig
@@ -106,11 +106,15 @@ fn formatRelocType(
_ = unused_fmt_string;
_ = options;
const r_type = ctx.r_type;
- const str = switch (ctx.cpu_arch) {
- .x86_64 => @tagName(@as(elf.R_X86_64, @enumFromInt(r_type))),
- .aarch64 => @tagName(@as(elf.R_AARCH64, @enumFromInt(r_type))),
- .riscv64 => @tagName(@as(elf.R_RISCV, @enumFromInt(r_type))),
- else => unreachable,
+ const str = switch (r_type) {
+ Elf.R_ZIG_GOT32 => "R_ZIG_GOT32",
+ Elf.R_ZIG_GOTPCREL => "R_ZIG_GOTPCREL",
+ else => switch (ctx.cpu_arch) {
+ .x86_64 => @tagName(@as(elf.R_X86_64, @enumFromInt(r_type))),
+ .aarch64 => @tagName(@as(elf.R_AARCH64, @enumFromInt(r_type))),
+ .riscv64 => @tagName(@as(elf.R_RISCV, @enumFromInt(r_type))),
+ else => unreachable,
+ },
};
try writer.print("{s}", .{str});
}
@@ -118,3 +122,5 @@ fn formatRelocType(
const assert = std.debug.assert;
const elf = std.elf;
const std = @import("std");
+
+const Elf = @import("../Elf.zig");