aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAlex Rønne Petersen <alex@alexrp.com>2024-07-25 23:55:42 +0200
committerAlex Rønne Petersen <alex@alexrp.com>2024-07-30 18:02:36 +0200
commit52519f79e0b3659e43eb8e765a9e2b584fc8f0f9 (patch)
treeffde2f169c18536b401df75677651afec61eaec6 /lib/std
parent2386bfe854826e0726b7002c04cd9fc4c08d68f3 (diff)
downloadzig-52519f79e0b3659e43eb8e765a9e2b584fc8f0f9.tar.gz
zig-52519f79e0b3659e43eb8e765a9e2b584fc8f0f9.zip
std.os.linux.start_pie: Apply MIPS local GOT relocations.
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/os/linux/start_pie.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/std/os/linux/start_pie.zig b/lib/std/os/linux/start_pie.zig
index b5cc06f429..ab4e2f4fe9 100644
--- a/lib/std/os/linux/start_pie.zig
+++ b/lib/std/os/linux/start_pie.zig
@@ -222,6 +222,24 @@ pub fn relocate(phdrs: []elf.Phdr) void {
}
}
+ // Deal with the GOT relocations that MIPS uses first.
+ if (builtin.cpu.arch.isMIPS()) {
+ const count: elf.Addr = blk: {
+ // This is an architecture-specific tag, so not part of `sorted_dynv`.
+ var i: usize = 0;
+ while (dynv[i].d_tag != elf.DT_NULL) : (i += 1) {
+ if (dynv[i].d_tag == elf.DT_MIPS_LOCAL_GOTNO) break :blk dynv[i].d_val;
+ }
+
+ break :blk 0;
+ };
+
+ const got: [*]usize = @ptrFromInt(base_addr + sorted_dynv[elf.DT_PLTGOT]);
+
+ for (0..count) |i| {
+ got[i] += base_addr;
+ }
+ }
// Apply normal relocations.