diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2024-08-26 15:38:35 -0400 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-08-27 03:55:56 -0400 |
| commit | f289b82d0efda77b72ccf9c826023e904f9ffcab (patch) | |
| tree | eb0bbade490e385b46942628016d34dd32515c86 /src/link/Elf/relocation.zig | |
| parent | 26d4fd5276eaaa939cf21a516265101c551b62f2 (diff) | |
| download | zig-f289b82d0efda77b72ccf9c826023e904f9ffcab.tar.gz zig-f289b82d0efda77b72ccf9c826023e904f9ffcab.zip | |
Dwarf: implement .eh_frame
Diffstat (limited to 'src/link/Elf/relocation.zig')
| -rw-r--r-- | src/link/Elf/relocation.zig | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/link/Elf/relocation.zig b/src/link/Elf/relocation.zig index d6f8dc5d10..047312cd68 100644 --- a/src/link/Elf/relocation.zig +++ b/src/link/Elf/relocation.zig @@ -108,20 +108,27 @@ pub const dwarf = struct { pub fn externalRelocType( target: Symbol, + source_section: Dwarf.Section.Index, address_size: Dwarf.AddressSize, cpu_arch: std.Target.Cpu.Arch, ) u32 { return switch (cpu_arch) { - .x86_64 => @intFromEnum(switch (address_size) { - .@"32" => if (target.flags.is_tls) elf.R_X86_64.DTPOFF32 else .@"32", - .@"64" => if (target.flags.is_tls) elf.R_X86_64.DTPOFF64 else .@"64", - else => unreachable, - }), - .riscv64 => @intFromEnum(switch (address_size) { - .@"32" => elf.R_RISCV.@"32", - .@"64" => elf.R_RISCV.@"64", - else => unreachable, - }), + .x86_64 => @intFromEnum(@as(elf.R_X86_64, switch (source_section) { + else => switch (address_size) { + .@"32" => if (target.flags.is_tls) .DTPOFF32 else .@"32", + .@"64" => if (target.flags.is_tls) .DTPOFF64 else .@"64", + else => unreachable, + }, + .debug_frame => .PC32, + })), + .riscv64 => @intFromEnum(@as(elf.R_RISCV, switch (source_section) { + else => switch (address_size) { + .@"32" => .@"32", + .@"64" => .@"64", + else => unreachable, + }, + .debug_frame => unreachable, + })), else => @panic("TODO unhandled cpu arch"), }; } |
