| ... | ... | @@ -779,10 +779,10 @@ const GotReloc = struct { |
| 779 | 779 | }; |
| 780 | 780 | |
| 781 | 781 | const Type = enum(u8) { |
| 782 | | offset64, |
| 783 | 782 | offset32, |
| 784 | | rel64, |
| 783 | offset64, |
| 785 | 784 | rel32, |
| 785 | rel64, |
| 786 | 786 | |
| 787 | 787 | larch_rel32_hi20, |
| 788 | 788 | larch_rel64_lo20, |
| ... | ... | @@ -791,6 +791,12 @@ const GotReloc = struct { |
| 791 | 791 | larch_abs32_hi20, |
| 792 | 792 | larch_abs64_lo20, |
| 793 | 793 | larch_abs64_hi12, |
| 794 | |
| 795 | sparc_10, |
| 796 | sparc_13, |
| 797 | sparc_22, |
| 798 | sparc_op_hix22, |
| 799 | sparc_op_lox10, |
| 794 | 800 | }; |
| 795 | 801 | |
| 796 | 802 | const Index = enum(u32) { |
| ... | ... | @@ -895,6 +901,37 @@ const GotReloc = struct { |
| 895 | 901 | const target_value = got_vaddr +% got_offset +% addend; |
| 896 | 902 | link.loongarch.writeK12(dest_slice[0..4], @truncate(target_value >> 52)); |
| 897 | 903 | }, |
| 904 | |
| 905 | .sparc_10 => { |
| 906 | const dest_ptr: *link.sparc.reloc.Simm13 = @ptrCast(@alignCast(dest_slice)); |
| 907 | var result = elf.targetLoad(dest_ptr); |
| 908 | result.simm13 = @as(u10, @truncate(got_offset)); |
| 909 | elf.targetStore(dest_ptr, result); |
| 910 | }, |
| 911 | .sparc_13 => { |
| 912 | const dest_ptr: *link.sparc.reloc.Simm13 = @ptrCast(@alignCast(dest_slice)); |
| 913 | var result = elf.targetLoad(dest_ptr); |
| 914 | result.simm13 = @truncate(got_offset); |
| 915 | elf.targetStore(dest_ptr, result); |
| 916 | }, |
| 917 | .sparc_22 => { |
| 918 | const dest_ptr: *link.sparc.reloc.Simm22 = @ptrCast(@alignCast(dest_slice)); |
| 919 | var result = elf.targetLoad(dest_ptr); |
| 920 | result.simm22 = @truncate(got_offset >> 10); |
| 921 | elf.targetStore(dest_ptr, result); |
| 922 | }, |
| 923 | .sparc_op_hix22 => { |
| 924 | const dest_ptr: *link.sparc.reloc.Imm22 = @ptrCast(@alignCast(dest_slice)); |
| 925 | var result = elf.targetLoad(dest_ptr); |
| 926 | result.imm22 = @truncate(got_offset >> 10); |
| 927 | elf.targetStore(dest_ptr, result); |
| 928 | }, |
| 929 | .sparc_op_lox10 => { |
| 930 | const dest_ptr: *link.sparc.reloc.Imm13 = @ptrCast(@alignCast(dest_slice)); |
| 931 | var result = elf.targetLoad(dest_ptr); |
| 932 | result.imm13 = @as(u10, @truncate(got_offset)); |
| 933 | elf.targetStore(dest_ptr, result); |
| 934 | }, |
| 898 | 935 | } |
| 899 | 936 | } |
| 900 | 937 | }; |
| ... | ... | @@ -6067,6 +6104,29 @@ fn addRelocAssumeCapacity( |
| 6067 | 6104 | .GOT64_LO20 => elf.addGotRelocAssumeCapacity(node, offset, .{ .symbol = target }, addend, .larch_abs64_lo20), |
| 6068 | 6105 | .GOT64_HI12 => elf.addGotRelocAssumeCapacity(node, offset, .{ .symbol = target }, addend, .larch_abs64_hi12), |
| 6069 | 6106 | }, |
| 6107 | .SPARCV9 => switch (@"type".SPARC) { |
| 6108 | else => std.debug.panic("TODO: unsupported input relocation, {t}", .{@"type".SPARC}), |
| 6109 | |
| 6110 | _, |
| 6111 | .NONE, |
| 6112 | .COPY, |
| 6113 | .JMP_SLOT, |
| 6114 | .RELATIVE, |
| 6115 | .IRELATIVE, |
| 6116 | => std.debug.panic("TODO: error for illegal or unsupported input relocation, {t}", .{@"type".SPARC}), |
| 6117 | |
| 6118 | // Relocations targeting a GOT entry |
| 6119 | .GOT10 => elf.addGotRelocAssumeCapacity(node, offset, .{ .symbol = target }, addend, .sparc_10), |
| 6120 | .GOT13 => elf.addGotRelocAssumeCapacity(node, offset, .{ .symbol = target }, addend, .sparc_13), |
| 6121 | .GOT22 => elf.addGotRelocAssumeCapacity(node, offset, .{ .symbol = target }, addend, .sparc_22), |
| 6122 | // These need similar handling to `R_X86_64_GOTOFF64`. No compiler seems to emit them though. |
| 6123 | .GOTDATA_HIX22 => @panic("TODO: R_SPARC_GOTDATA_HIX22"), |
| 6124 | .GOTDATA_LOX10 => @panic("TODO: R_SPARC_GOTDATA_LOX10"), |
| 6125 | .GOTDATA_OP_HIX22 => elf.addGotRelocAssumeCapacity(node, offset, .{ .symbol = target }, addend, .sparc_op_hix22), |
| 6126 | .GOTDATA_OP_LOX10 => elf.addGotRelocAssumeCapacity(node, offset, .{ .symbol = target }, addend, .sparc_op_lox10), |
| 6127 | // We currently do no relaxation, so nothing to do for this one. |
| 6128 | .GOTDATA_OP => {}, |
| 6129 | }, |
| 6070 | 6130 | }, |
| 6071 | 6131 | } |
| 6072 | 6132 | } |