| ... | @@ -3,6 +3,7 @@ const builtin = @import("builtin"); | ... | @@ -3,6 +3,7 @@ const builtin = @import("builtin"); |
| 3 | const elf = std.elf; | 3 | const elf = std.elf; |
| 4 | const assert = std.debug.assert; | 4 | const assert = std.debug.assert; |
| 5 | | 5 | |
| | 6 | const R_ALPHA_RELATIVE = 27; |
| 6 | const R_AMD64_RELATIVE = 8; | 7 | const R_AMD64_RELATIVE = 8; |
| 7 | const R_386_RELATIVE = 8; | 8 | const R_386_RELATIVE = 8; |
| 8 | const R_ARC_RELATIVE = 56; | 9 | const R_ARC_RELATIVE = 56; |
| ... | @@ -25,6 +26,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) { | ... | @@ -25,6 +26,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) { |
| 25 | .arc, .arceb => R_ARC_RELATIVE, | 26 | .arc, .arceb => R_ARC_RELATIVE, |
| 26 | .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE, | 27 | .arm, .armeb, .thumb, .thumbeb => R_ARM_RELATIVE, |
| 27 | .aarch64, .aarch64_be => R_AARCH64_RELATIVE, | 28 | .aarch64, .aarch64_be => R_AARCH64_RELATIVE, |
| | 29 | .alpha => R_ALPHA_RELATIVE, |
| 28 | .csky => R_CSKY_RELATIVE, | 30 | .csky => R_CSKY_RELATIVE, |
| 29 | .hexagon => R_HEXAGON_RELATIVE, | 31 | .hexagon => R_HEXAGON_RELATIVE, |
| 30 | .loongarch32, .loongarch64 => R_LARCH_RELATIVE, | 32 | .loongarch32, .loongarch64 => R_LARCH_RELATIVE, |
| ... | @@ -83,6 +85,15 @@ inline fn getDynamicSymbol() [*]const elf.Dyn { | ... | @@ -83,6 +85,15 @@ inline fn getDynamicSymbol() [*]const elf.Dyn { |
| 83 | \\ add %[ret], %[ret], #:lo12:_DYNAMIC | 85 | \\ add %[ret], %[ret], #:lo12:_DYNAMIC |
| 84 | : [ret] "=r" (-> [*]const elf.Dyn), | 86 | : [ret] "=r" (-> [*]const elf.Dyn), |
| 85 | ), | 87 | ), |
| | 88 | // The compiler is not required to load the GP register, so do it ourselves. |
| | 89 | .alpha => asm volatile ( |
| | 90 | \\ br $29, 1f |
| | 91 | \\1: |
| | 92 | \\ ldgp $29, 0($29) |
| | 93 | \\ ldq %[ret], -0x8000($29) |
| | 94 | : [ret] "=r" (-> [*]const elf.Dyn), |
| | 95 | : |
| | 96 | : .{ .r26 = true }), |
| 86 | // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first | 97 | // The CSKY ABI requires the gb register to point to the GOT. Additionally, the first |
| 87 | // entry in the GOT is defined to hold the address of _DYNAMIC. | 98 | // entry in the GOT is defined to hold the address of _DYNAMIC. |
| 88 | .csky => asm volatile ( | 99 | .csky => asm volatile ( |