| ... | @@ -277,4 +277,28 @@ pub fn relocate(phdrs: []elf.Phdr) void { | ... | @@ -277,4 +277,28 @@ pub fn relocate(phdrs: []elf.Phdr) void { |
| 277 | @as(*usize, @ptrFromInt(base_addr + r.r_offset)).* = base_addr + @as(usize, @bitCast(r.r_addend)); | 277 | @as(*usize, @ptrFromInt(base_addr + r.r_offset)).* = base_addr + @as(usize, @bitCast(r.r_addend)); |
| 278 | } | 278 | } |
| 279 | } | 279 | } |
| | 280 | |
| | 281 | const relr = sorted_dynv[elf.DT_RELR]; |
| | 282 | if (relr != 0) { |
| | 283 | const relrs = @call(.always_inline, std.mem.bytesAsSlice, .{ |
| | 284 | elf.Relr, |
| | 285 | @as([*]u8, @ptrFromInt(base_addr + relr))[0..sorted_dynv[elf.DT_RELRSZ]], |
| | 286 | }); |
| | 287 | var current: [*]usize = undefined; |
| | 288 | for (relrs) |r| { |
| | 289 | if ((r & 1) == 0) { |
| | 290 | current = @ptrFromInt(base_addr + r); |
| | 291 | current[0] += base_addr; |
| | 292 | current += 1; |
| | 293 | } else { |
| | 294 | // Skip the first bit; there are 63 locations in the bitmap. |
| | 295 | var i: if (@sizeOf(usize) == 8) u6 else u5 = 1; |
| | 296 | while (i < @bitSizeOf(elf.Relr)) : (i += 1) { |
| | 297 | if (((r >> i) & 1) != 0) current[i] += base_addr; |
| | 298 | } |
| | 299 | |
| | 300 | current += @bitSizeOf(elf.Relr) - 1; |
| | 301 | } |
| | 302 | } |
| | 303 | } |
| 280 | } | 304 | } |