| ... | @@ -222,6 +222,24 @@ pub fn relocate(phdrs: []elf.Phdr) void { | ... | @@ -222,6 +222,24 @@ pub fn relocate(phdrs: []elf.Phdr) void { |
| 222 | } | 222 | } |
| 223 | } | 223 | } |
| 224 | | 224 | |
| | 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 | } |
| 225 | | 243 | |
| 226 | // Apply normal relocations. | 244 | // Apply normal relocations. |
| 227 | | 245 | |