authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-25 23:55:42+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-07-30 18:02:36+02:00
log52519f79e0b3659e43eb8e765a9e2b584fc8f0f9
treeffde2f169c18536b401df75677651afec61eaec6
parent2386bfe854826e0726b7002c04cd9fc4c08d68f3
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.os.linux.start_pie: Apply MIPS local GOT relocations.


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

lib/std/os/linux/start_pie.zig+18
......@@ -222,6 +222,24 @@ pub fn relocate(phdrs: []elf.Phdr) void {
222222 }
223223 }
224224
225 // Deal with the GOT relocations that MIPS uses first.
226 if (builtin.cpu.arch.isMIPS()) {
227 const count: elf.Addr = blk: {
228 // This is an architecture-specific tag, so not part of `sorted_dynv`.
229 var i: usize = 0;
230 while (dynv[i].d_tag != elf.DT_NULL) : (i += 1) {
231 if (dynv[i].d_tag == elf.DT_MIPS_LOCAL_GOTNO) break :blk dynv[i].d_val;
232 }
233
234 break :blk 0;
235 };
236
237 const got: [*]usize = @ptrFromInt(base_addr + sorted_dynv[elf.DT_PLTGOT]);
238
239 for (0..count) |i| {
240 got[i] += base_addr;
241 }
242 }
225243
226244 // Apply normal relocations.
227245