authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-16 11:26:24+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-16 11:26:24+01:00
loga402fdc813595b7c7ae51b27c96ad7443ebb33f8
treea61060187c5a3a7c019f50a8c3680d86a974ebb6
parent77f7d01a69db8b75b5cbe40b61decc34d616595c
signaturelock-open Commit is signed but in an unrecognized format.

Elf2: fix 32-bit build


1 files changed, 11 insertions(+), 11 deletions(-)

src/link/Elf2.zig+11-11
...@@ -1831,8 +1831,8 @@ fn ensureDynsymHashCapacity(elf: *Elf, max_dynsym_count: u32) Error!void {...@@ -1831,8 +1831,8 @@ fn ensureDynsymHashCapacity(elf: *Elf, max_dynsym_count: u32) Error!void {
1831 if (elf.targetEndian() != std.lang.Endian.native) {1831 if (elf.targetEndian() != std.lang.Endian.native) {
1832 std.mem.byteSwapAllFields(info.Header(), header);1832 std.mem.byteSwapAllFields(info.Header(), header);
1833 }1833 }
1834 const buckets: []info.Int() = trailing[0..elf.targetLoad(&header.nbucket)];1834 const buckets: []info.Int() = trailing[0..@intCast(elf.targetLoad(&header.nbucket))];
1835 const chains: []info.Int() = trailing[elf.targetLoad(&header.nbucket)..][0..elf.targetLoad(&header.nchain)];1835 const chains: []info.Int() = trailing[@intCast(elf.targetLoad(&header.nbucket))..][0..@intCast(elf.targetLoad(&header.nchain))];
18361836
1837 @memset(buckets, 0);1837 @memset(buckets, 0);
1838 chains[0] = 0;1838 chains[0] = 0;
...@@ -1878,8 +1878,8 @@ fn populateDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {...@@ -1878,8 +1878,8 @@ fn populateDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {
1878 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);1878 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
1879 const trailing: []info.Int() = @ptrCast(section_slice[@sizeOf(info.Header())..]);1879 const trailing: []info.Int() = @ptrCast(section_slice[@sizeOf(info.Header())..]);
18801880
1881 const buckets: []info.Int() = trailing[0..elf.targetLoad(&header.nbucket)];1881 const buckets: []info.Int() = trailing[0..@intCast(elf.targetLoad(&header.nbucket))];
1882 const chains: []info.Int() = trailing[elf.targetLoad(&header.nbucket)..][0..elf.targetLoad(&header.nchain)];1882 const chains: []info.Int() = trailing[@intCast(elf.targetLoad(&header.nbucket))..][0..@intCast(elf.targetLoad(&header.nchain))];
18831883
1884 const sym_name: String(.dynstr) = switch (elf.dynsymPtr(dynsym_index)) {1884 const sym_name: String(.dynstr) = switch (elf.dynsymPtr(dynsym_index)) {
1885 inline else => |sym| @fromBackingInt(elf.targetLoad(&sym.name)),1885 inline else => |sym| @fromBackingInt(elf.targetLoad(&sym.name)),
...@@ -1919,8 +1919,8 @@ fn clearDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {...@@ -1919,8 +1919,8 @@ fn clearDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {
1919 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);1919 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
1920 const trailing: []info.Int() = @ptrCast(section_slice[@sizeOf(info.Header())..]);1920 const trailing: []info.Int() = @ptrCast(section_slice[@sizeOf(info.Header())..]);
19211921
1922 const buckets: []info.Int() = trailing[0..elf.targetLoad(&header.nbucket)];1922 const buckets: []info.Int() = trailing[0..@intCast(elf.targetLoad(&header.nbucket))];
1923 const chains: []info.Int() = trailing[elf.targetLoad(&header.nbucket)..][0..elf.targetLoad(&header.nchain)];1923 const chains: []info.Int() = trailing[@intCast(elf.targetLoad(&header.nbucket))..][0..@intCast(elf.targetLoad(&header.nchain))];
19241924
1925 const sym_name: String(.dynstr) = switch (elf.dynsymPtr(dynsym_index)) {1925 const sym_name: String(.dynstr) = switch (elf.dynsymPtr(dynsym_index)) {
1926 inline else => |sym| @fromBackingInt(elf.targetLoad(&sym.name)),1926 inline else => |sym| @fromBackingInt(elf.targetLoad(&sym.name)),
...@@ -1935,11 +1935,11 @@ fn clearDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {...@@ -1935,11 +1935,11 @@ fn clearDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {
1935 if (elf.targetLoad(&buckets[b]) == dynsym_index) {1935 if (elf.targetLoad(&buckets[b]) == dynsym_index) {
1936 elf.targetStore(&buckets[b], next_dynsym_index);1936 elf.targetStore(&buckets[b], next_dynsym_index);
1937 } else {1937 } else {
1938 var cur = elf.targetLoad(&buckets[b]);1938 var cur: usize = @intCast(elf.targetLoad(&buckets[b]));
1939 while (true) {1939 while (true) {
1940 assert(cur != 0); // `dynsym_index` is definitely somewhere in the chain1940 assert(cur != 0); // `dynsym_index` is definitely somewhere in the chain
1941 if (elf.targetLoad(&chains[cur]) == dynsym_index) break;1941 if (elf.targetLoad(&chains[cur]) == dynsym_index) break;
1942 cur = elf.targetLoad(&chains[cur]);1942 cur = @intCast(elf.targetLoad(&chains[cur]));
1943 }1943 }
1944 // We found `dynsym_index`; replace it with `next_dynsym_index`.1944 // We found `dynsym_index`; replace it with `next_dynsym_index`.
1945 elf.targetStore(&chains[cur], next_dynsym_index);1945 elf.targetStore(&chains[cur], next_dynsym_index);
...@@ -7545,7 +7545,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {...@@ -7545,7 +7545,7 @@ pub fn idle(elf: *Elf, tid: Zcu.PerThread.Id) link.Error!bool {
7545 // introduced if we only did one per `idle` call. Also, there is no risk of this work7545 // introduced if we only did one per `idle` call. Also, there is no risk of this work
7546 // being invalidated. So let's just flush the entire queue at once.7546 // being invalidated. So let's just flush the entire queue at once.
7547 for (elf.one_shot_fixups.items) |isw| {7547 for (elf.one_shot_fixups.items) |isw| {
7548 const dest_slice = isw.node.slice(&elf.mf)[isw.offset..][0..4];7548 const dest_slice = isw.node.slice(&elf.mf)[@intCast(isw.offset)..][0..4];
7549 const old: u32 = std.mem.readInt(u32, dest_slice, elf.targetEndian());7549 const old: u32 = std.mem.readInt(u32, dest_slice, elf.targetEndian());
7550 const new: u32 = switch (isw.action) {7550 const new: u32 = switch (isw.action) {
7551 // zig fmt: off7551 // zig fmt: off
...@@ -8155,7 +8155,7 @@ fn allocateSegmentLoadAddress(elf: *Elf, orig_phndx: u32) std.mem.Allocator.Erro...@@ -8155,7 +8155,7 @@ fn allocateSegmentLoadAddress(elf: *Elf, orig_phndx: u32) std.mem.Allocator.Erro
8155 const next_size = elf.targetLoad(&next_ph.memsz);8155 const next_size = elf.targetLoad(&next_ph.memsz);
8156 // Instead of putting ourselves right after `next_ph`, we'll go a bit later in the8156 // Instead of putting ourselves right after `next_ph`, we'll go a bit later in the
8157 // address space so that `next_ph` has address space to grow into (like above).8157 // address space so that `next_ph` has address space to grow into (like above).
8158 vaddr = ph_align.forward(next_vaddr + next_size * 4) + offset % ph_align.toByteUnits();8158 vaddr = ph_align.forward(@intCast(next_vaddr + next_size * 4)) + offset % ph_align.toByteUnits();
81598159
8160 // Now just swap the phdrs and update our `phndx`.8160 // Now just swap the phdrs and update our `phndx`.
8161 std.mem.swap(@TypeOf(next_ph.*), &phdr[phndx], next_ph);8161 std.mem.swap(@TypeOf(next_ph.*), &phdr[phndx], next_ph);
...@@ -8934,7 +8934,7 @@ fn ensureSegmentAligned(elf: *Elf, start_phndx: u32, min_align: std.mem.Alignmen...@@ -8934,7 +8934,7 @@ fn ensureSegmentAligned(elf: *Elf, start_phndx: u32, min_align: std.mem.Alignmen
8934 // just above, but it is possible that it was not moved *but* still has an8934 // just above, but it is possible that it was not moved *but* still has an
8935 // unaligned virtual address. In that case, we need to ensure the segment's8935 // unaligned virtual address. In that case, we need to ensure the segment's
8936 // virtual address range will be recomputed.8936 // virtual address range will be recomputed.
8937 if (!min_align.check(elf.targetLoad(&phdr[phndx].vaddr))) {8937 if (!min_align.check(@intCast(elf.targetLoad(&phdr[phndx].vaddr)))) {
8938 try seg_ni.moved(gpa, &elf.mf);8938 try seg_ni.moved(gpa, &elf.mf);
8939 }8939 }
8940 },8940 },