authorgravatar for abbix@riseup.netlg <abbix@riseup.net> 2026-08-31 14:29:03-04:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-10-16 12:41:28+01:00
logc39b73d375353f4e32fd4eb962c06a42e6ca929e
tree632fa9dddadebd536b79a4b320c22cdb62a36379
parent56eb5323106cccfea7a5212dd6ab2e66d35f3f64
signature Commit is signed but in an unrecognized format.

Elf2: make section nodes optional


1 files changed, 95 insertions(+), 88 deletions(-)

src/link/Elf2.zig+95-88
......@@ -492,7 +492,7 @@ const Archive = struct {
492492
493493const Section = struct {
494494 /// The node corresponding to this section.
495 ni: MappedFile.Node.Index,
495 ni: MappedFile.Node.Index.Optional,
496496 /// A symbol which is exactly at the start of this section.
497497 ///
498498 /// When not emitting a relocatable, or for special section types, this is `.null`.
......@@ -596,6 +596,13 @@ const Section = struct {
596596 return &elf.shdrs.items[@backingInt(shndx) - 1]; // overflow means you tried to get the `.UNDEF` section
597597 }
598598
599 /// Convenience function for accessing a section's `MappedFile` node.
600 ///
601 /// Asserts that the section's `ni` is not `.none` (so, the section type is not `SHT_NOBITS`).
602 fn node(shndx: Index, elf: *Elf) MappedFile.Node.Index {
603 return shndx.get(elf).ni.unwrap().?;
604 }
605
599606 fn name(shndx: Index, elf: *Elf) String(.shstrtab) {
600607 return switch (elf.shdrPtr(shndx)) {
601608 inline else => |shdr| @fromBackingInt(elf.targetLoad(&shdr.name)),
......@@ -648,7 +655,7 @@ const Section = struct {
648655 elf.targetStore(&shdr.addralign, @intCast(min_align.toByteUnits()));
649656 },
650657 }
651 const ni = shndx.get(elf).ni;
658 const ni = shndx.node(elf);
652659 if (min_align.compare(.gt, ni.alignment(&elf.mf))) {
653660 try ni.realign(elf.base.comp.gpa, &elf.mf, min_align);
654661 }
......@@ -662,7 +669,7 @@ const Section = struct {
662669 /// Asserts that `rela_shndx` is a `SHT_RELA` section and ensures that its node has enough
663670 /// unused space to hold `n` additional `ElfN.Rela` entries.
664671 fn relaEnsureAdditionalCapacity(rela_shndx: Index, elf: *Elf, n: usize) Error!void {
665 const node = rela_shndx.get(elf).ni;
672 const ni = rela_shndx.node(elf);
666673 const need_size: u64 = switch (elf.shdrPtr(rela_shndx)) {
667674 inline else => |shdr, class| need_size: {
668675 assert(elf.targetLoad(&shdr.type) == .RELA);
......@@ -673,7 +680,7 @@ const Section = struct {
673680 const opt_free_head = rela_shndx.get(elf).rela.free_head;
674681 const free_head = opt_free_head.unwrap() orelse break :free_len 0;
675682 const relas: []const class.ElfN().Rela = @ptrCast(@alignCast(
676 node.slice(&elf.mf)[0..@intCast(cur_size)],
683 ni.slice(&elf.mf)[0..@intCast(cur_size)],
677684 ));
678685 const free_len = elf.targetLoad(&relas[@backingInt(free_head)].addend);
679686 assert(free_len > 0);
......@@ -683,7 +690,7 @@ const Section = struct {
683690 break :need_size cur_size + need_additional * ent_size;
684691 },
685692 };
686 try node.ensureMinimumSize(elf.base.comp.gpa, &elf.mf, need_size);
693 try ni.ensureMinimumSize(elf.base.comp.gpa, &elf.mf, need_size);
687694 }
688695
689696 /// Asserts that `rela_shndx` is a `SHT_RELA` section and deletes the `ElfN.Rela` entry at
......@@ -695,7 +702,7 @@ const Section = struct {
695702 assert(elf.targetLoad(&shdr.type) == .RELA);
696703 assert(elf.targetLoad(&shdr.entsize) == @sizeOf(class.ElfN().Rela));
697704 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
698 rela_shndx.get(elf).ni.slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
705 rela_shndx.node(elf).slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
699706 ));
700707 const opt_free_head = rela_shndx.get(elf).rela.free_head;
701708 const old_free_len: u32 = free_len: {
......@@ -743,7 +750,7 @@ const Section = struct {
743750 assert(elf.targetLoad(&shdr.entsize) == ent_size);
744751 const new_index: RelaIndex = if (rela_shndx.get(elf).rela.free_head.unwrap()) |free_head| new_index: {
745752 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
746 rela_shndx.get(elf).ni.slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
753 rela_shndx.node(elf).slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
747754 ));
748755 const next: RelaIndex.Optional = @fromBackingInt(@intCast(elf.targetLoad(
749756 &relas[@backingInt(free_head)].offset,
......@@ -766,7 +773,7 @@ const Section = struct {
766773 break :new_index @fromBackingInt(@intCast(@divExact(old_size, ent_size)));
767774 };
768775 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
769 rela_shndx.get(elf).ni.slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
776 rela_shndx.node(elf).slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
770777 ));
771778 relas[@backingInt(new_index)] = .{
772779 .offset = @intCast(opts.offset),
......@@ -794,7 +801,7 @@ const Section = struct {
794801 assert(elf.targetLoad(&shdr.type) == .RELA);
795802 assert(elf.targetLoad(&shdr.entsize) == @sizeOf(class.ElfN().Rela));
796803 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
797 rela_shndx.get(elf).ni.slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
804 rela_shndx.node(elf).slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
798805 ));
799806 const rela_info = elf.targetLoad(&relas[@backingInt(index)].info);
800807 {
......@@ -818,7 +825,7 @@ const Section = struct {
818825 assert(elf.targetLoad(&shdr.type) == .RELA);
819826 assert(elf.targetLoad(&shdr.entsize) == @sizeOf(class.ElfN().Rela));
820827 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
821 rela_shndx.get(elf).ni.slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
828 rela_shndx.node(elf).slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
822829 ));
823830 {
824831 const rela_info = elf.targetLoad(&relas[@backingInt(index)].info);
......@@ -839,7 +846,7 @@ const Section = struct {
839846 assert(elf.targetLoad(&shdr.type) == .RELA);
840847 assert(elf.targetLoad(&shdr.entsize) == @sizeOf(class.ElfN().Rela));
841848 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
842 rela_shndx.get(elf).ni.slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
849 rela_shndx.node(elf).slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
843850 ));
844851 {
845852 const rela_info = elf.targetLoad(&relas[@backingInt(index)].info);
......@@ -863,7 +870,7 @@ const Section = struct {
863870 assert(elf.targetLoad(&shdr.type) == .RELA);
864871 assert(elf.targetLoad(&shdr.entsize) == @sizeOf(class.ElfN().Rela));
865872 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
866 rela_shndx.get(elf).ni.slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
873 rela_shndx.node(elf).slice(&elf.mf)[0..@intCast(elf.targetLoad(&shdr.size))],
867874 ));
868875 {
869876 const rela_info = elf.targetLoad(&relas[@backingInt(index)].info);
......@@ -2220,7 +2227,7 @@ const GotReloc = struct {
22202227 fn apply(reloc: *GotReloc, elf: *Elf) void {
22212228 assert(elf.ehdrType() != .REL);
22222229 const node = reloc.node.unwrap() orelse return; // deleted
2223 if (node.hasMoved(&elf.mf) or elf.shndx.got.get(elf).ni.hasMoved(&elf.mf)) {
2230 if (node.hasMoved(&elf.mf) or elf.shndx.got.node(elf).hasMoved(&elf.mf)) {
22242231 // There's no point applying the relocation now, because it will be re-applied by
22252232 // `flushMoved` at some point anyway.
22262233 return;
......@@ -2452,7 +2459,7 @@ fn ensureDynsymHashCapacity(elf: *Elf, max_dynsym_count: u32) Error!void {
24522459 switch (elf.targetDynsymHashInfo()) {
24532460 inline else => |info| {
24542461 {
2455 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.get(elf).ni.slice(&elf.mf));
2462 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.node(elf).slice(&elf.mf));
24562463 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
24572464 assert(elf.targetLoad(&header.nchain) == cur_dynsym_count);
24582465 const nbucket = elf.targetLoad(&header.nbucket);
......@@ -2460,7 +2467,7 @@ fn ensureDynsymHashCapacity(elf: *Elf, max_dynsym_count: u32) Error!void {
24602467 // We don't need to add any buckets, but we still need to make sure the section is large
24612468 // enough to fit `max_dynsym_count` chains.
24622469 const need_size = @sizeOf(info.Header()) + (nbucket + max_dynsym_count) * 4;
2463 try elf.shndx.hash.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, need_size);
2470 try elf.shndx.hash.node(elf).ensureMinimumSize(gpa, &elf.mf, need_size);
24642471 return;
24652472 }
24662473 // We need more buckets, so we'll have to rebuild the hash table.
......@@ -2472,13 +2479,13 @@ fn ensureDynsymHashCapacity(elf: *Elf, max_dynsym_count: u32) Error!void {
24722479
24732480 {
24742481 const need_size = @sizeOf(info.Header()) + (new_nbucket + max_dynsym_count) * 4;
2475 try elf.shndx.hash.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, need_size);
2482 try elf.shndx.hash.node(elf).ensureMinimumSize(gpa, &elf.mf, need_size);
24762483 }
24772484
24782485 elf.mf.nodes_lock.lock();
24792486 defer elf.mf.nodes_lock.unlock();
24802487
2481 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.get(elf).ni.slice(&elf.mf));
2488 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.node(elf).slice(&elf.mf));
24822489 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
24832490 const trailing: []info.Int() = @ptrCast(section_slice[@sizeOf(info.Header())..]);
24842491
......@@ -2508,7 +2515,7 @@ fn ensureDynsymHashCapacity(elf: *Elf, max_dynsym_count: u32) Error!void {
25082515fn appendDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {
25092516 switch (elf.targetDynsymHashInfo()) {
25102517 inline else => |info| {
2511 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.get(elf).ni.slice(&elf.mf));
2518 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.node(elf).slice(&elf.mf));
25122519 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
25132520 assert(elf.targetLoad(&header.nchain) == dynsym_index);
25142521 elf.targetStore(&header.nchain, dynsym_index + 1);
......@@ -2529,7 +2536,7 @@ fn populateDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {
25292536
25302537 switch (elf.targetDynsymHashInfo()) {
25312538 inline else => |info| {
2532 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.get(elf).ni.slice(&elf.mf));
2539 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.node(elf).slice(&elf.mf));
25332540 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
25342541 const trailing: []info.Int() = @ptrCast(section_slice[@sizeOf(info.Header())..]);
25352542
......@@ -2551,7 +2558,7 @@ fn popDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {
25512558
25522559 switch (elf.targetDynsymHashInfo()) {
25532560 inline else => |info| {
2554 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.get(elf).ni.slice(&elf.mf));
2561 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.node(elf).slice(&elf.mf));
25552562 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
25562563 assert(elf.targetLoad(&header.nchain) == dynsym_index + 1);
25572564 elf.targetStore(&header.nchain, dynsym_index);
......@@ -2570,7 +2577,7 @@ fn clearDynsymHashEntry(elf: *Elf, dynsym_index: u32) void {
25702577
25712578 switch (elf.targetDynsymHashInfo()) {
25722579 inline else => |info| {
2573 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.get(elf).ni.slice(&elf.mf));
2580 const section_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.node(elf).slice(&elf.mf));
25742581 const header: *info.Header() = @ptrCast(section_slice[0..@sizeOf(info.Header())]);
25752582 const trailing: []info.Int() = @ptrCast(section_slice[@sizeOf(info.Header())..]);
25762583
......@@ -2615,7 +2622,7 @@ fn pltEntryIsDead(elf: *Elf, plt_index: usize) bool {
26152622 inline else => |rela_shdr, class| {
26162623 const size = elf.targetLoad(&rela_shdr.size);
26172624 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
2618 elf.shndx.rela_plt.get(elf).ni.slice(&elf.mf)[0..@intCast(size)],
2625 elf.shndx.rela_plt.node(elf).slice(&elf.mf)[0..@intCast(size)],
26192626 ));
26202627 const rel_type = elf.targetLoad(&relas[plt_index].info).type;
26212628 return rel_type == MachineRelocType.none(elf).unwrap(elf);
......@@ -2636,7 +2643,7 @@ fn addLocalSymbol(elf: *Elf, opts: AddLocalSymbolOptions) Error!Symbol.LocalInde
26362643
26372644 try elf.symtab.ensureUnusedCapacity(gpa, 1);
26382645 try elf.changed_symtab_index.ensureUnusedCapacity(gpa, 1);
2639 try Section.Index.symtab.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, switch (elf.shdrPtr(.symtab)) {
2646 try Section.Index.symtab.node(elf).ensureMinimumSize(gpa, &elf.mf, switch (elf.shdrPtr(.symtab)) {
26402647 inline else => |shdr, class| elf.targetLoad(&shdr.size) + @sizeOf(class.ElfN().Sym),
26412648 });
26422649
......@@ -2715,7 +2722,7 @@ fn addGlobalSymbol(elf: *Elf, opts: Symbol.Global.AddOptions) (error{
27152722 try elf.globals_by_name.ensureUnusedCapacity(gpa, 1);
27162723 try elf.node_global_symbols.ensureUnusedCapacity(gpa, 1);
27172724
2718 try Section.Index.symtab.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, switch (elf.shdrPtr(.symtab)) {
2725 try Section.Index.symtab.node(elf).ensureMinimumSize(gpa, &elf.mf, switch (elf.shdrPtr(.symtab)) {
27192726 inline else => |shdr, class| elf.targetLoad(&shdr.size) + @sizeOf(class.ElfN().Sym),
27202727 });
27212728
......@@ -3059,8 +3066,8 @@ fn updateGlobalDynamic(elf: *Elf, orig_gsi: Symbol.Global.Index, force_apply_rel
30593066 };
30603067 const need_dynsym_len: u32 = @intCast(@divExact(dynsym_size, dynsym_ent_size) + 1);
30613068
3062 try elf.shndx.dynsym.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, need_dynsym_len * dynsym_ent_size);
3063 try elf.shndx.gnu_version.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, need_dynsym_len * 2);
3069 try elf.shndx.dynsym.node(elf).ensureMinimumSize(gpa, &elf.mf, need_dynsym_len * dynsym_ent_size);
3070 try elf.shndx.gnu_version.node(elf).ensureMinimumSize(gpa, &elf.mf, need_dynsym_len * 2);
30643071 try elf.ensureDynsymHashCapacity(need_dynsym_len);
30653072
30663073 const dynstr_name: String(.dynstr) = name: {
......@@ -3246,7 +3253,7 @@ fn updateGlobalDynamic(elf: *Elf, orig_gsi: Symbol.Global.Index, force_apply_rel
32463253 errdefer assert(elf.copied_globals.pop().?.key == gsi);
32473254 try elf.nodes.ensureUnusedCapacity(gpa, 1);
32483255 const node = elf.addNodeAssumeCapacity(
3249 try shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
3256 try shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
32503257 .size = dso_global.alignment.forward(dso_global.size),
32513258 .alignment = dso_global.alignment,
32523259 }),
......@@ -4295,7 +4302,7 @@ fn lazySymbolInner(elf: *Elf, lazy: link.File.LazySymbol) Error!link.File.Symbol
42954302 .const_data => .{ .rodata, .OBJECT },
42964303 };
42974304 const node = elf.addNodeAssumeCapacity(
4298 try shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
4305 try shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{}),
42994306 switch (lazy.kind) {
43004307 .code => .{ .lazy_code = @fromBackingInt(@intCast(gop.index)) },
43014308 .const_data => .{ .lazy_const_data = @fromBackingInt(@intCast(gop.index)) },
......@@ -4472,7 +4479,7 @@ fn String(section: StringSection) type {
44724479 _,
44734480
44744481 fn slice(str: @This(), elf: *Elf) [:0]const u8 {
4475 const section_node = section.shndx(elf).get(elf).ni;
4482 const section_node = section.shndx(elf).node(elf);
44764483 const overlong = section_node.sliceConst(&elf.mf)[@backingInt(str)..];
44774484 return overlong[0..std.mem.findScalar(u8, overlong, 0).? :0];
44784485 }
......@@ -4532,14 +4539,14 @@ const StringTable = struct {
45324539
45334540 fn getExisting(st: *StringTable, elf: *Elf, shndx: Section.Index, key: []const u8) u32 {
45344541 if (key.len == 0) return 0;
4535 const slice_const = shndx.get(elf).ni.sliceConst(&elf.mf);
4542 const slice_const = shndx.node(elf).sliceConst(&elf.mf);
45364543 const adapter: StringTable.Adapter = .{ .slice = slice_const };
45374544 return st.map.getKeyAdapted(key, adapter).?;
45384545 }
45394546
45404547 fn ensureAdditionalCapacity(st: *StringTable, elf: *Elf, shndx: Section.Index, string_len: usize) Error!void {
45414548 const gpa = elf.base.comp.gpa;
4542 const ni = shndx.get(elf).ni;
4549 const ni = shndx.node(elf);
45434550 const slice_const = ni.sliceConst(&elf.mf);
45444551 try st.map.ensureUnusedCapacityContext(gpa, 1, .{ .slice = slice_const });
45454552 const size: u64 = switch (elf.shdrPtr(shndx)) {
......@@ -4553,7 +4560,7 @@ const StringTable = struct {
45534560 // case the empty string.
45544561 if (key.len == 0) return 0;
45554562
4556 const ni = shndx.get(elf).ni;
4563 const ni = shndx.node(elf);
45574564 const slice_const = ni.sliceConst(&elf.mf);
45584565 const gop = st.map.getOrPutAssumeCapacityAdapted(
45594566 key,
......@@ -5476,7 +5483,7 @@ fn initHeaders(
54765483 .node_align = node_block_align,
54775484 .manual_size = true,
54785485 }));
5479 Section.Index.get(.shstrtab, elf).ni.slice(&elf.mf)[0] = 0;
5486 Section.Index.shstrtab.node(elf).slice(&elf.mf)[0] = 0;
54805487
54815488 try Section.Index.symtab.rename(elf, ".symtab");
54825489 try Section.Index.shstrtab.rename(elf, ".shstrtab");
......@@ -5489,7 +5496,7 @@ fn initHeaders(
54895496 .node_align = node_block_align,
54905497 .manual_size = true,
54915498 }));
5492 Section.Index.get(.strtab, elf).ni.slice(&elf.mf)[0] = 0;
5499 Section.Index.strtab.node(elf).slice(&elf.mf)[0] = 0;
54935500 switch (elf.shdrPtr(.symtab)) {
54945501 inline else => |shdr| elf.targetStore(&shdr.link, @backingInt(Section.Index.strtab)),
54955502 }
......@@ -5595,7 +5602,7 @@ fn initHeaders(
55955602 .flags = .{ .ALLOC = true },
55965603 .size = @intCast(interp.len + 1),
55975604 });
5598 const sec_interp = sec_interp_shndx.get(elf).ni.slice(&elf.mf);
5605 const sec_interp = sec_interp_shndx.node(elf).slice(&elf.mf);
55995606 @memcpy(sec_interp[0..interp.len], interp);
56005607 sec_interp[interp.len] = 0;
56015608 }
......@@ -5620,7 +5627,7 @@ fn initHeaders(
56205627 .node_align = node_block_align,
56215628 .manual_size = true,
56225629 });
5623 dynstr_shndx.get(elf).ni.slice(&elf.mf)[0] = 0;
5630 dynstr_shndx.node(elf).slice(&elf.mf)[0] = 0;
56245631 elf.shndx.dynstr = dynstr_shndx;
56255632
56265633 switch (class) {
......@@ -5765,7 +5772,7 @@ fn initHeaders(
57655772 .size = @sizeOf(info.Header()) + @sizeOf(info.Int()) * (8 + 1),
57665773 .manual_size = true,
57675774 });
5768 const hash_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.get(elf).ni.slice(&elf.mf));
5775 const hash_slice: []align(@sizeOf(info.Int())) u8 = @alignCast(elf.shndx.hash.node(elf).slice(&elf.mf));
57695776 const header: *info.Header() = @ptrCast(hash_slice[0..@sizeOf(info.Header())]);
57705777 header.* = .{ .nbucket = 8, .nchain = 1 };
57715778 if (elf.targetEndian() != std.lang.Endian.native) {
......@@ -5779,7 +5786,7 @@ fn initHeaders(
57795786 switch (machine) {
57805787 .AARCH64, .PPC64, .RISCV => @panic(@tagName(machine)),
57815788 .X86_64 => {
5782 const plt_ni = elf.shndx.plt.get(elf).ni;
5789 const plt_ni = elf.shndx.plt.node(elf);
57835790 const got_plt_sym: Symbol.Id = .local(elf.shndx.got_plt.get(elf).lsi);
57845791 @memcpy(plt_ni.slice(&elf.mf)[0..16], &[16]u8{
57855792 0xff, 0x35, 0x00, 0x00, 0x00, 0x00, // push 0x0(%rip)
......@@ -5804,7 +5811,7 @@ fn initHeaders(
58045811 );
58055812 },
58065813 .LOONGARCH => {
5807 const plt_ni = elf.shndx.plt.get(elf).ni;
5814 const plt_ni = elf.shndx.plt.node(elf);
58085815 const got_plt_sym: Symbol.Id = .local(elf.shndx.got_plt.get(elf).lsi);
58095816 @memcpy(plt_ni.slice(&elf.mf)[0..32], switch (class) {
58105817 .NONE, _ => unreachable,
......@@ -5881,7 +5888,7 @@ fn initHeaders(
58815888 .manual_size = true,
58825889 });
58835890
5884 const eh_frame_hdr_ni = elf.shndx.eh_frame_hdr.get(elf).ni;
5891 const eh_frame_hdr_ni = elf.shndx.eh_frame_hdr.node(elf);
58855892 elf.eh_frame_hdr_first_symbol_reloc =
58865893 @fromBackingInt(@intCast(elf.symbol_relocs.items.len));
58875894 try elf.dwarf.genEhFrameHdr(
......@@ -5890,7 +5897,7 @@ fn initHeaders(
58905897 Symbol.Id.local(elf.shndx.eh_frame.get(elf).lsi).toTypeErased(),
58915898 );
58925899 _ = elf.addNodeAssumeCapacity(
5893 try elf.shndx.eh_frame.get(elf).ni.addOnlyFooterChild(gpa, &elf.mf, .{
5900 try elf.shndx.eh_frame.node(elf).addOnlyFooterChild(gpa, &elf.mf, .{
58945901 .size = addr_align.forward(4),
58955902 .alignment = addr_align,
58965903 }),
......@@ -5937,7 +5944,7 @@ fn initHeaders(
59375944
59385945 // Despite the name, `__dso_handle` is necessary even in static binaries.
59395946 _ = elf.addGlobalSymbol(.{
5940 .node = .wrap(Section.Index.text.get(elf).ni),
5947 .node = .wrap(Section.Index.text.node(elf)),
59415948 .name = "__dso_handle",
59425949 .value = Section.Index.text.vaddr(elf),
59435950 .size = 0,
......@@ -5952,7 +5959,7 @@ fn initHeaders(
59525959 else => |e| return e,
59535960 };
59545961 _ = elf.addGlobalSymbol(.{
5955 .node = .wrap(elf.shndx.plt.get(elf).ni),
5962 .node = .wrap(elf.shndx.plt.node(elf)),
59565963 .name = "_PROCEDURE_LINKAGE_TABLE_",
59575964 .value = elf.shndx.plt.vaddr(elf),
59585965 .size = 0,
......@@ -5967,7 +5974,7 @@ fn initHeaders(
59675974 else => |e| return e,
59685975 };
59695976 _ = elf.addGlobalSymbol(.{
5970 .node = .wrap(elf.shndx.got.get(elf).ni),
5977 .node = .wrap(elf.shndx.got.node(elf)),
59715978 .name = "_GLOBAL_OFFSET_TABLE_",
59725979 .value = switch (machine) {
59735980 .AARCH64,
......@@ -6085,7 +6092,7 @@ fn initHeaders(
60856092 };
60866093 if (have_dynamic) {
60876094 _ = elf.addGlobalSymbol(.{
6088 .node = .wrap(elf.shndx.dynamic.get(elf).ni),
6095 .node = .wrap(elf.shndx.dynamic.node(elf)),
60896096 .name = "_DYNAMIC",
60906097 .value = elf.shndx.dynamic.vaddr(elf),
60916098 .size = 0,
......@@ -6868,7 +6875,7 @@ const SymPtr = union(std.elf.CLASS) {
68686875 @"64": *std.elf.Elf64.Sym,
68696876};
68706877fn symPtr(elf: *Elf, index: Symbol.Index) SymPtr {
6871 const raw_slice = Section.Index.symtab.get(elf).ni.slice(&elf.mf);
6878 const raw_slice = Section.Index.symtab.node(elf).slice(&elf.mf);
68726879 switch (elf.shdrPtr(.symtab)) {
68736880 inline else => |shdr, class| {
68746881 const size = elf.targetLoad(&shdr.size);
......@@ -6878,7 +6885,7 @@ fn symPtr(elf: *Elf, index: Symbol.Index) SymPtr {
68786885 }
68796886}
68806887fn dynsymPtr(elf: *Elf, index: u32) SymPtr {
6881 const raw_slice = elf.shndx.dynsym.get(elf).ni.slice(&elf.mf);
6888 const raw_slice = elf.shndx.dynsym.node(elf).slice(&elf.mf);
68826889 switch (elf.shdrPtr(elf.shndx.dynsym)) {
68836890 inline else => |shdr, class| {
68846891 const size = elf.targetLoad(&shdr.size);
......@@ -6889,7 +6896,7 @@ fn dynsymPtr(elf: *Elf, index: u32) SymPtr {
68896896}
68906897
68916898fn versymSlice(elf: *Elf) []std.elf.Versym {
6892 const raw_slice = elf.shndx.gnu_version.get(elf).ni.slice(&elf.mf);
6899 const raw_slice = elf.shndx.gnu_version.node(elf).slice(&elf.mf);
68936900 const size = elf.shndx.gnu_version.size(elf);
68946901 return @ptrCast(@alignCast(raw_slice[0..@intCast(size)]));
68956902}
......@@ -6903,7 +6910,7 @@ const VerdefEntry = extern struct {
69036910 aux: std.elf.Verdaux,
69046911};
69056912fn verdefSlice(elf: *Elf) []VerdefEntry {
6906 const raw_slice = elf.shndx.gnu_version_d.get(elf).ni.slice(&elf.mf);
6913 const raw_slice = elf.shndx.gnu_version_d.node(elf).slice(&elf.mf);
69076914 const size = elf.shndx.gnu_version_d.size(elf);
69086915 return @ptrCast(@alignCast(raw_slice[0..@intCast(size)]));
69096916}
......@@ -6916,7 +6923,7 @@ const VerneedEntry = extern union {
69166923 }
69176924};
69186925fn verneedSlice(elf: *Elf) []VerneedEntry {
6919 const raw_slice = elf.shndx.gnu_version_r.get(elf).ni.slice(&elf.mf);
6926 const raw_slice = elf.shndx.gnu_version_r.node(elf).slice(&elf.mf);
69206927 const size = elf.shndx.gnu_version_r.size(elf);
69216928 return @ptrCast(@alignCast(raw_slice[0..@intCast(size)]));
69226929}
......@@ -7101,7 +7108,7 @@ fn navMapIndex(elf: *Elf, zcu: *Zcu, nav_index: InternPool.Nav.Index) Error!Node
71017108 },
71027109 };
71037110 try shndx.ensureAligned(elf, alignment);
7104 const node = elf.addNodeAssumeCapacity(try shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
7111 const node = elf.addNodeAssumeCapacity(try shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
71057112 .alignment = alignment,
71067113 }), .{ .nav = nmi });
71077114 nav_gop.value_ptr.* = .{
......@@ -7143,7 +7150,7 @@ fn uavMapIndex(
71437150 if (!uav_gop.found_existing) {
71447151 const shndx: Section.Index = .data_rel_ro; // TODO: it would be better to use `.rodata` if the UAV value doesn't have relocs
71457152 try shndx.ensureAligned(elf, resolved_align);
7146 const node = elf.addNodeAssumeCapacity(try shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
7153 const node = elf.addNodeAssumeCapacity(try shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
71477154 .moved = true, // see assert at end of `genUav`
71487155 .alignment = resolved_align,
71497156 }), .{ .uav = umi });
......@@ -7603,7 +7610,7 @@ fn loadObject(
76037610 };
76047611 const ni = elf.addNodeAssumeCapacity(
76057612 if (opts.node_fixed) ni: {
7606 const shndx_ni = opts.shndx.get(elf).ni;
7613 const shndx_ni = opts.shndx.node(elf);
76077614 const after_oni: MappedFile.Node.Index.Optional = after: {
76087615 const last_ni = shndx_ni.last(&elf.mf).unwrap() orelse break :after .none;
76097616 break :after switch (last_ni.position(&elf.mf)) {
......@@ -7612,7 +7619,7 @@ fn loadObject(
76127619 };
76137620 };
76147621 break :ni try shndx_ni.addHeaderChildAfter(gpa, &elf.mf, after_oni, add_node_opts);
7615 } else try opts.shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, add_node_opts),
7622 } else try opts.shndx.node(elf).addFloatingChild(gpa, &elf.mf, add_node_opts),
76167623 .{ .input_section = @fromBackingInt(@intCast(elf.input_sections.items.len)) },
76177624 );
76187625 section.isi = @fromBackingInt(@intCast(elf.input_sections.items.len));
......@@ -8327,7 +8334,7 @@ fn createInitFiniArraySection(
83278334 .version = null,
83288335 }).?;
83298336 try elf.setGlobalSymbolValue(start_gsi, .{
8330 .node = .wrap(shndx.get(elf).ni),
8337 .node = .wrap(shndx.node(elf)),
83318338 .value = shndx.vaddr(elf),
83328339 .size = 0,
83338340 .type = .NOTYPE,
......@@ -8335,7 +8342,7 @@ fn createInitFiniArraySection(
83358342 });
83368343 try elf.updateGlobalDynamic(start_gsi, true);
83378344 try elf.setGlobalSymbolValue(end_gsi, .{
8338 .node = .wrap(shndx.get(elf).ni),
8345 .node = .wrap(shndx.node(elf)),
83398346 .value = shndx.vaddr(elf),
83408347 .size = 0,
83418348 .type = .NOTYPE,
......@@ -8388,7 +8395,7 @@ fn prelinkInner(elf: *Elf) Error!void {
83888395 elf.shndx.debug_str_offsets,
83898396 }) |debug_shndx| {
83908397 if (debug_shndx == .UNDEF) continue;
8391 const debug_ni = debug_shndx.get(elf).ni;
8398 const debug_ni = debug_shndx.node(elf);
83928399 const frame_format = debug_shndx.debugFrameFormat(elf);
83938400 const unit_padding_ni = elf.addNodeAssumeCapacity(
83948401 try debug_ni.addHeaderChildAfter(gpa, &elf.mf, last_header_oni: {
......@@ -8444,7 +8451,7 @@ fn prelinkInner(elf: *Elf) Error!void {
84448451 .UNDEF => {},
84458452 else => |debug_addr_shndx| {
84468453 const debug_addr_ni = elf.addNodeAssumeCapacity(
8447 try debug_addr_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
8454 try debug_addr_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
84488455 .alignment = addr_align,
84498456 .next_moved = true,
84508457 .enable_next_moved = true,
......@@ -8465,7 +8472,7 @@ fn prelinkInner(elf: *Elf) Error!void {
84658472 switch (elf.shndx.debug_abbrev) {
84668473 .UNDEF => {},
84678474 else => |debug_abbrev_shndx| elf.dwarf.debug_abbrev.ni = .wrap(elf.addNodeAssumeCapacity(
8468 try debug_abbrev_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
8475 try debug_abbrev_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{}),
84698476 .{ .debug_shared = .debug_abbrev },
84708477 )),
84718478 }
......@@ -8473,14 +8480,14 @@ fn prelinkInner(elf: *Elf) Error!void {
84738480 .UNDEF => {},
84748481 else => |debug_line_str_shndx| elf.dwarf.debug_line_str.ni =
84758482 .wrap(elf.addNodeAssumeCapacity(
8476 try debug_line_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
8483 try debug_line_str_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{}),
84778484 .{ .debug_shared = .debug_line_str },
84788485 )),
84798486 }
84808487 switch (elf.shndx.debug_str) {
84818488 .UNDEF => {},
84828489 else => |debug_str_shndx| elf.dwarf.debug_str.ni = .wrap(elf.addNodeAssumeCapacity(
8483 try debug_str_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{}),
8490 try debug_str_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{}),
84848491 .{ .debug_shared = .debug_str },
84858492 )),
84868493 }
......@@ -8488,7 +8495,7 @@ fn prelinkInner(elf: *Elf) Error!void {
84888495 .UNDEF => {},
84898496 else => |debug_str_offsets_shndx| {
84908497 const debug_str_offsets_ni = elf.addNodeAssumeCapacity(
8491 try debug_str_offsets_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
8498 try debug_str_offsets_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
84928499 .alignment = switch (elf.dwarf.format) {
84938500 .@"32" => .@"4",
84948501 .@"64" => .@"8",
......@@ -8549,7 +8556,7 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void {
85498556 else => |debug_info_shndx| {
85508557 const debug_info_ni = unit.debug_info_ni.unwrap() orelse debug_info_ni: {
85518558 const debug_info_ni = elf.addNodeAssumeCapacity(
8552 try debug_info_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
8559 try debug_info_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
85538560 .alignment = elf.mf.flags.block_size,
85548561 .enable_next_moved = true,
85558562 }),
......@@ -8576,7 +8583,7 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void {
85768583 else => |debug_line_shndx| {
85778584 const debug_line_ni = unit.debug_line_ni.unwrap() orelse debug_line_ni: {
85788585 const debug_line_ni = elf.addNodeAssumeCapacity(
8579 try debug_line_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
8586 try debug_line_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
85808587 .alignment = elf.mf.flags.block_size,
85818588 .enable_next_moved = true,
85828589 }),
......@@ -8600,7 +8607,7 @@ fn zcuFilesReadyInner(elf: *Elf, zcu: *Zcu) Error!void {
86008607 else => |debug_rnglists_shndx| {
86018608 const debug_rnglists_ni = unit.debug_rnglists_ni.unwrap() orelse debug_rnglists_ni: {
86028609 const debug_rnglists_ni = elf.addNodeAssumeCapacity(
8603 try debug_rnglists_shndx.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
8610 try debug_rnglists_shndx.node(elf).addFloatingChild(gpa, &elf.mf, .{
86048611 .next_moved = true,
86058612 .enable_next_moved = true,
86068613 }),
......@@ -8680,7 +8687,7 @@ fn prepareDynamic(elf: *Elf) Error!void {
86808687
86818688 const dynamic_size = dynamic_len * 2 * elf.targetPtrSize();
86828689
8683 try elf.shndx.dynamic.get(elf).ni.resizeLeaf(comp.gpa, &elf.mf, dynamic_size);
8690 try elf.shndx.dynamic.node(elf).resizeLeaf(comp.gpa, &elf.mf, dynamic_size);
86848691 switch (elf.shdrPtr(elf.shndx.dynamic)) {
86858692 inline else => |shdr| elf.targetStore(&shdr.size, @intCast(dynamic_size)),
86868693 }
......@@ -8702,7 +8709,7 @@ fn flushDynamic(elf: *Elf) void {
87028709 comp.config.pie);
87038710
87048711 const dynamic_size = elf.targetLoad(&@field(elf.shdrPtr(elf.shndx.dynamic), @tagName(class)).size);
8705 const dynamic_slice = elf.shndx.dynamic.get(elf).ni.slice(&elf.mf)[0..@intCast(dynamic_size)];
8712 const dynamic_slice = elf.shndx.dynamic.node(elf).slice(&elf.mf)[0..@intCast(dynamic_size)];
87068713 const dynamic_entries: [][2]ElfN.Addr = @ptrCast(@alignCast(dynamic_slice));
87078714
87088715 var dynamic_index: usize = 0;
......@@ -8896,7 +8903,7 @@ fn addSection(elf: *Elf, segment_ni: MappedFile.Node.Index, opts: struct {
88968903 .type = .SECTION,
88978904 .shndx = shndx,
88988905 }) else .null,
8899 .ni = ni,
8906 .ni = .wrap(ni),
89008907 .rela = switch (opts.type) {
89018908 .REL => unreachable,
89028909 .RELA => .{ .free_head = .none },
......@@ -8973,7 +8980,7 @@ fn ensureUnusedRelocCapacity(elf: *Elf, node: MappedFile.Node.Index, len: usize)
89738980 .NONE, _ => unreachable,
89748981 inline else => |ct_class| (elf.got.count() + new_got_entries) * @sizeOf(ct_class.ElfN().Addr),
89758982 };
8976 try elf.shndx.got.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, need_got_size);
8983 try elf.shndx.got.node(elf).ensureMinimumSize(gpa, &elf.mf, need_got_size);
89778984
89788985 if (elf.shndx.dynamic != .UNDEF) {
89798986 try elf.shndx.rela_dyn.relaEnsureAdditionalCapacity(elf, new_got_entries);
......@@ -9816,7 +9823,7 @@ fn updateGotEntry(elf: *Elf, got_index: usize) void {
98169823 const addr_size = @sizeOf(class.ElfN().Addr);
98179824 const offset = got_index * addr_size;
98189825 const entry_ptr: *class.ElfN().Addr = @ptrCast(@alignCast(
9819 elf.shndx.got.get(elf).ni.slice(&elf.mf)[offset..][0..addr_size],
9826 elf.shndx.got.node(elf).slice(&elf.mf)[offset..][0..addr_size],
98209827 ));
98219828 elf.targetStore(entry_ptr, switch (entry_value) {
98229829 .unsigned => |x| @intCast(x),
......@@ -10179,7 +10186,7 @@ fn updateFuncInner(
1017910186 const frame_ni = elf.addNodeAssumeCapacity(try switch (wip_func.frame_format) {
1018010187 .debug_frame => elf.shndx.debug_frame,
1018110188 .eh_frame => elf.shndx.eh_frame,
10182 }.get(elf).ni.addFloatingChild(gpa, &elf.mf, .{
10189 }.node(elf).addFloatingChild(gpa, &elf.mf, .{
1018310190 .alignment = frame_align.max(elf.mf.flags.block_size),
1018410191 .enable_next_moved = true,
1018510192 }), .{ .unit_frame = wip_func.unit });
......@@ -11904,17 +11911,17 @@ fn ensurePltEntry(elf: *Elf, gsi: Symbol.Global.Index) Error!bool {
1190411911 const gpa = elf.base.comp.gpa;
1190511912 try elf.shndx.rela_plt.relaEnsureAdditionalCapacity(elf, 1);
1190611913 try elf.plt.ensureUnusedCapacity(gpa, 1);
11907 try elf.shndx.plt.get(elf).ni.ensureMinimumSize(
11914 try elf.shndx.plt.node(elf).ensureMinimumSize(
1190811915 gpa,
1190911916 &elf.mf,
1191011917 plt.entry_size * (plt.header_entries + elf.plt.count() + 1),
1191111918 );
11912 if (plt.got_plt) |got_plt| try elf.shndx.got_plt.get(elf).ni.ensureMinimumSize(
11919 if (plt.got_plt) |got_plt| try elf.shndx.got_plt.node(elf).ensureMinimumSize(
1191311920 gpa,
1191411921 &elf.mf,
1191511922 elf.targetPtrSize() * (got_plt.header_entries + elf.plt.count() + 1),
1191611923 );
11917 if (plt.plt_sec) |plt_sec| try elf.shndx.plt_sec.get(elf).ni.ensureMinimumSize(
11924 if (plt.plt_sec) |plt_sec| try elf.shndx.plt_sec.node(elf).ensureMinimumSize(
1191811925 gpa,
1191911926 &elf.mf,
1192011927 plt_sec.entry_size * (elf.plt.count() + 1),
......@@ -11962,7 +11969,7 @@ fn ensurePltEntry(elf: *Elf, gsi: Symbol.Global.Index) Error!bool {
1196211969 switch (elf.ehdrMachine()) {
1196311970 .AARCH64, .PPC64, .RISCV => |machine| @panic(@tagName(machine)),
1196411971 .X86_64 => {
11965 const plt_ni = elf.shndx.plt.get(elf).ni;
11972 const plt_ni = elf.shndx.plt.node(elf);
1196611973 const plt_addr = plt_addr: switch (elf.shdrPtr(elf.shndx.plt)) {
1196711974 inline else => |shdr| {
1196811975 const old_size = 16 * (1 + plt_index);
......@@ -11986,7 +11993,7 @@ fn ensurePltEntry(elf: *Elf, gsi: Symbol.Global.Index) Error!bool {
1198611993 },
1198711994 };
1198811995
11989 const got_plt_ni = elf.shndx.got_plt.get(elf).ni;
11996 const got_plt_ni = elf.shndx.got_plt.node(elf);
1199011997 switch (elf.shdrPtr(elf.shndx.got_plt)) {
1199111998 inline else => |shdr, class| {
1199211999 assert(elf.targetLoad(&shdr.size) == got_plt_offset);
......@@ -12000,7 +12007,7 @@ fn ensurePltEntry(elf: *Elf, gsi: Symbol.Global.Index) Error!bool {
1200012007 },
1200112008 }
1200212009
12003 const plt_sec_ni = elf.shndx.plt_sec.get(elf).ni;
12010 const plt_sec_ni = elf.shndx.plt_sec.node(elf);
1200412011 switch (elf.shdrPtr(elf.shndx.plt_sec)) {
1200512012 inline else => |shdr| {
1200612013 const old_size = 16 * plt_index;
......@@ -12024,7 +12031,7 @@ fn ensurePltEntry(elf: *Elf, gsi: Symbol.Global.Index) Error!bool {
1202412031 },
1202512032 .LOONGARCH => {
1202612033 // add a .PLT entry, writing the template
12027 const plt_ni = elf.shndx.plt.get(elf).ni;
12034 const plt_ni = elf.shndx.plt.node(elf);
1202812035 const plt_addr, const plt_slice = plt_entry: switch (elf.shdrPtr(elf.shndx.plt)) {
1202912036 inline else => |shdr| {
1203012037 const old_size = 16 * (1 + plt_index);
......@@ -12048,7 +12055,7 @@ fn ensurePltEntry(elf: *Elf, gsi: Symbol.Global.Index) Error!bool {
1204812055 };
1204912056
1205012057 // add a .GOT.PLT entry, writing the address of the corresponding .PLT entry
12051 const got_plt_ni = elf.shndx.got_plt.get(elf).ni;
12058 const got_plt_ni = elf.shndx.got_plt.node(elf);
1205212059 switch (elf.shdrPtr(elf.shndx.got_plt)) {
1205312060 inline else => |shdr, class| {
1205412061 assert(elf.targetLoad(&shdr.size) == got_plt_offset);
......@@ -12080,7 +12087,7 @@ fn ensurePltEntry(elf: *Elf, gsi: Symbol.Global.Index) Error!bool {
1208012087 },
1208112088 .SPARCV9 => {
1208212089 // add a .PLT entry, writing the template
12083 const plt_ni = elf.shndx.plt.get(elf).ni;
12090 const plt_ni = elf.shndx.plt.node(elf);
1208412091 switch (elf.shdrPtr(elf.shndx.plt)) {
1208512092 inline else => |shdr| {
1208612093 assert(elf.targetLoad(&shdr.size) == got_plt_offset);
......@@ -12137,7 +12144,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad
1213712144 // We also need to update all of the references from `.plt.sec` to `.got.plt`.
1213812145 // However, if there's also a flush pending for `.got.plt`, don't bother doing
1213912146 // this now, because we'll do it when `.got.plt` is flushed anyway.
12140 if (elf.shndx.got_plt.get(elf).ni.hasMoved(&elf.mf)) {
12147 if (elf.shndx.got_plt.node(elf).hasMoved(&elf.mf)) {
1214112148 return;
1214212149 }
1214312150 // Exit this `switch` to update those references.
......@@ -12152,7 +12159,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad
1215212159 // We also need to update all of the references from `.plt.sec` to `.got.plt`.
1215312160 // However, if there's also a flush pending for `.plt.sec`, don't bother doing
1215412161 // this now, because we'll do it when `.plt.sec` is flushed anyway.
12155 if (elf.shndx.plt_sec.get(elf).ni.hasMoved(&elf.mf)) {
12162 if (elf.shndx.plt_sec.node(elf).hasMoved(&elf.mf)) {
1215612163 return;
1215712164 }
1215812165 // Exit this `switch` to update those references.
......@@ -12161,7 +12168,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad
1216112168 // We are updating the references from `.plt.sec` to `.got.plt`.
1216212169 const got_plt_addr = elf.shndx.got_plt.vaddr(elf);
1216312170 const plt_sec_addr = elf.shndx.plt_sec.vaddr(elf);
12164 const plt_sec_slice = elf.shndx.plt_sec.get(elf).ni.slice(&elf.mf);
12171 const plt_sec_slice = elf.shndx.plt_sec.node(elf).slice(&elf.mf);
1216512172 switch (elf.identClass()) {
1216612173 .NONE, _ => unreachable,
1216712174 inline else => |class| {
......@@ -12194,7 +12201,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad
1219412201 // We also need to update all of the references from `.plt` to `.got.plt`.
1219512202 // However, if there's also a flush pending for `.got.plt`, don't bother doing
1219612203 // this now, because we'll do it when `.got.plt` is flushed anyway.
12197 if (elf.shndx.got_plt.get(elf).ni.hasMoved(&elf.mf)) {
12204 if (elf.shndx.got_plt.node(elf).hasMoved(&elf.mf)) {
1219812205 return;
1219912206 }
1220012207 // Exit this `switch` to update those references.
......@@ -12210,7 +12217,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad
1221012217 // We also need to update all of the references from `.plt` to `.got.plt`.
1221112218 // However, if there's also a flush pending for `.plt`, don't bother doing
1221212219 // this now, because we'll do it when `.plt` is flushed anyway.
12213 if (elf.shndx.plt.get(elf).ni.hasMoved(&elf.mf)) {
12220 if (elf.shndx.plt.node(elf).hasMoved(&elf.mf)) {
1221412221 return;
1221512222 }
1221612223 // Exit this `switch` to update those references.
......@@ -12219,7 +12226,7 @@ fn flushMovedPltSection(elf: *Elf, which: enum { plt, plt_sec, got_plt }, old_ad
1221912226 // We are updating the references from `.plt` to `.got.plt`.
1222012227 const got_plt_addr = elf.shndx.got_plt.vaddr(elf);
1222112228 const plt_addr = elf.shndx.plt.vaddr(elf);
12222 const plt_slice = elf.shndx.plt.get(elf).ni.slice(&elf.mf);
12229 const plt_slice = elf.shndx.plt.node(elf).slice(&elf.mf);
1222312230 switch (elf.identClass()) {
1222412231 .NONE, _ => unreachable,
1222512232 inline else => |class| {
......@@ -12657,7 +12664,7 @@ const VerdefAdapter = struct {
1265712664fn verdefId(elf: *Elf, version: String(.dynstr)) Error!u15 {
1265812665 const gpa = elf.base.comp.gpa;
1265912666 const adapter: VerdefAdapter = .{ .elf = elf };
12660 try elf.shndx.gnu_version_d.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, (elf.verdef.count() + 2) * @sizeOf(VerdefEntry));
12667 try elf.shndx.gnu_version_d.node(elf).ensureMinimumSize(gpa, &elf.mf, (elf.verdef.count() + 2) * @sizeOf(VerdefEntry));
1266112668 const gop = try elf.verdef.getOrPutAdapted(gpa, version, adapter);
1266212669
1266312670 if (gop.found_existing) {
......@@ -12766,7 +12773,7 @@ const VerneedAdapter = struct {
1276612773fn verneedId(elf: *Elf, file: String(.dynstr), version: String(.dynstr)) Error!u15 {
1276712774 const gpa = elf.base.comp.gpa;
1276812775 const adapter: VerneedAdapter = .{ .elf = elf };
12769 try elf.shndx.gnu_version_r.get(elf).ni.ensureMinimumSize(gpa, &elf.mf, (elf.verneed.count() + 2) * @sizeOf(VerneedEntry));
12776 try elf.shndx.gnu_version_r.node(elf).ensureMinimumSize(gpa, &elf.mf, (elf.verneed.count() + 2) * @sizeOf(VerneedEntry));
1277012777
1277112778 if (elf.verneed.getIndexAdapted(@as(VerneedAdapter.Key, .{
1277212779 .file = file,