authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-25 01:04:20+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-30 01:24:55+02:00
logadfbd8a98b2525dbd5fa9891968794f7ace31cd6
tree2935491aee161be9d03b7a2be04ce2a2afe21beb
parent38e0f049c531e83ec2eec80d50b624e6c3b8c486
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux.start_pie: Add mips and mips64 support.


1 files changed, 27 insertions(+), 0 deletions(-)

lib/std/os/linux/start_pie.zig+27
...@@ -12,6 +12,7 @@ const R_CSKY_RELATIVE = 9;...@@ -12,6 +12,7 @@ const R_CSKY_RELATIVE = 9;
12const R_HEXAGON_RELATIVE = 35;12const R_HEXAGON_RELATIVE = 35;
13const R_LARCH_RELATIVE = 3;13const R_LARCH_RELATIVE = 3;
14const R_68K_RELATIVE = 22;14const R_68K_RELATIVE = 22;
15const R_MIPS_RELATIVE = 128;
15const R_RISCV_RELATIVE = 3;16const R_RISCV_RELATIVE = 3;
16const R_390_RELATIVE = 12;17const R_390_RELATIVE = 12;
17const R_SPARC_RELATIVE = 22;18const R_SPARC_RELATIVE = 22;
...@@ -26,6 +27,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {...@@ -26,6 +27,7 @@ const R_RELATIVE = switch (builtin.cpu.arch) {
26 .hexagon => R_HEXAGON_RELATIVE,27 .hexagon => R_HEXAGON_RELATIVE,
27 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,28 .loongarch32, .loongarch64 => R_LARCH_RELATIVE,
28 .m68k => R_68K_RELATIVE,29 .m68k => R_68K_RELATIVE,
30 .mips, .mipsel, .mips64, .mips64el => R_MIPS_RELATIVE,
29 .riscv32, .riscv64 => R_RISCV_RELATIVE,31 .riscv32, .riscv64 => R_RISCV_RELATIVE,
30 .s390x => R_390_RELATIVE,32 .s390x => R_390_RELATIVE,
31 else => @compileError("Missing R_RELATIVE definition for this target"),33 else => @compileError("Missing R_RELATIVE definition for this target"),
...@@ -111,6 +113,31 @@ fn getDynamicSymbol() [*]elf.Dyn {...@@ -111,6 +113,31 @@ fn getDynamicSymbol() [*]elf.Dyn {
111 \\ lea (%[ret], %%pc), %[ret]113 \\ lea (%[ret], %%pc), %[ret]
112 : [ret] "=r" (-> [*]elf.Dyn),114 : [ret] "=r" (-> [*]elf.Dyn),
113 ),115 ),
116 .mips, .mipsel => asm volatile (
117 \\ .weak _DYNAMIC
118 \\ .hidden _DYNAMIC
119 \\ bal 1f
120 \\ .gpword _DYNAMIC
121 \\ 1:
122 \\ lw %[ret], 0($ra)
123 \\ addu %[ret], %[ret], $gp
124 : [ret] "=r" (-> [*]elf.Dyn),
125 :
126 : "lr"
127 ),
128 .mips64, .mips64el => asm volatile (
129 \\ .weak _DYNAMIC
130 \\ .hidden _DYNAMIC
131 \\ .balign 8
132 \\ bal 1f
133 \\ .gpdword _DYNAMIC
134 \\ 1:
135 \\ ld %[ret], 0($ra)
136 \\ daddu %[ret], %[ret], $gp
137 : [ret] "=r" (-> [*]elf.Dyn),
138 :
139 : "lr"
140 ),
114 .riscv32, .riscv64 => asm volatile (141 .riscv32, .riscv64 => asm volatile (
115 \\ .weak _DYNAMIC142 \\ .weak _DYNAMIC
116 \\ .hidden _DYNAMIC143 \\ .hidden _DYNAMIC