authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-12 12:17:24+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2026-08-16 09:30:27+01:00
logc6d7ab8a234cedf08cd63f14db6e020ee5bd6c34
tree82eee08b9d928dccf5feec6bef9b7cbc76d520e2
parent31500242f0c82b8d3b5e1d7a683a8a6f4c803bb2
signaturelock-open Commit is signed but in an unrecognized format.

Elf2: delete some dead code


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

src/link/Elf2.zig+1-43
......@@ -119,8 +119,6 @@ got: std.array_hash_map.Auto(GotKey, Section.RelaIndex.Optional),
119119plt: std.array_hash_map.Auto(String(.strtab), void),
120120/// The `.plt` section contains zero or more symbol relocations starting at this index.
121121plt_first_symbol_reloc: SymbolReloc.Index,
122/// The `.dynamic` section contains zero or more symbol relocations starting at this index.
123dynamic_first_symbol_reloc: SymbolReloc.Index,
124122
125123needed: std.array_hash_map.Auto(String(.dynstr), void),
126124inputs: std.ArrayList(struct {
......@@ -195,8 +193,6 @@ const Node = union(enum) {
195193 shdr,
196194 segment: u32,
197195 /// The section '.plt' may contain relocations via `elf.plt_first_symbol_reloc`.
198 ///
199 /// The section '.dynamic' may contain relocations via `elf.dynamic_first_symbol_reloc`.
200196 section: Section.Index,
201197 /// Only valid for static libraries, represents one non-zcu archive member.
202198 input_member: InputIndex,
......@@ -634,11 +630,6 @@ const Section = struct {
634630 const old_size = elf.targetLoad(&shdr.size);
635631 const new_size = old_size + ent_size;
636632 elf.targetStore(&shdr.size, new_size);
637 if (rela_shndx == elf.shndx.rela_dyn) {
638 elf.updateDynamicEntry(std.elf.DT_RELASZ, new_size);
639 } else if (rela_shndx == elf.shndx.rela_plt) {
640 elf.updateDynamicEntry(std.elf.DT_PLTRELSZ, new_size);
641 }
642633 break :new_index @fromBackingInt(@intCast(@divExact(old_size, ent_size)));
643634 };
644635 const relas: []class.ElfN().Rela = @ptrCast(@alignCast(
......@@ -3045,9 +3036,6 @@ const StringTable = struct {
30453036 break :size .{ old_size, new_size };
30463037 },
30473038 };
3048 if (shndx == elf.shndx.dynstr) {
3049 elf.updateDynamicEntry(std.elf.DT_STRSZ, new_size);
3050 }
30513039 try elf.ensureNodeSize(ni, new_size);
30523040 const slice = ni.slice(&elf.mf)[old_size..];
30533041 @memcpy(slice[0..key.len], key);
......@@ -3202,7 +3190,6 @@ fn create(
32023190 .got = .empty,
32033191 .plt = .empty,
32043192 .plt_first_symbol_reloc = .none,
3205 .dynamic_first_symbol_reloc = .none,
32063193 .needed = .empty,
32073194 .inputs = .empty,
32083195 .input_pending_index = 0,
......@@ -5313,7 +5300,7 @@ fn loadObject(
53135300 const old_size = elf.targetLoad(&shdr.size);
53145301 const new_size = old_size + section.shdr.size;
53155302 elf.targetStore(&shdr.size, @intCast(new_size));
5316 elf.updateInitFiniArraySectionSize(shndx.*, init_fini_section_name, @"type", new_size);
5303 elf.updateInitFiniArraySectionSize(shndx.*, init_fini_section_name);
53175304 },
53185305 }
53195306 break :shndx shndx.*;
......@@ -5878,19 +5865,7 @@ fn updateInitFiniArraySectionSize(
58785865 elf: *Elf,
58795866 shndx: Section.Index,
58805867 comptime name: []const u8,
5881 @"type": std.elf.SHT,
5882 new_size: u64,
58835868) void {
5884 if (elf.shndx.dynamic != .UNDEF) {
5885 const arraysz_dyn_key: u32 = switch (@"type") {
5886 .INIT_ARRAY => std.elf.DT_INIT_ARRAYSZ,
5887 .FINI_ARRAY => std.elf.DT_FINI_ARRAYSZ,
5888 .PREINIT_ARRAY => std.elf.DT_PREINIT_ARRAYSZ,
5889 else => unreachable,
5890 };
5891 elf.updateDynamicEntry(arraysz_dyn_key, new_size);
5892 }
5893
58945869 const end_vaddr: u64 = switch (elf.shdrPtr(shndx)) {
58955870 inline else => |shdr| shndx.vaddr(elf) + elf.targetLoad(&shdr.size),
58965871 };
......@@ -7648,8 +7623,6 @@ fn flushMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!void
76487623 elf.flushMovedPltSection(.got_plt, old_addr, addr);
76497624 } else if (shndx == elf.shndx.plt_sec) {
76507625 elf.flushMovedPltSection(.plt_sec, old_addr, addr);
7651 } else if (shndx == elf.shndx.dynamic) {
7652 elf.flushMovedNodeRelocs(ni, addr, elf.dynamic_first_symbol_reloc, .none);
76537626 }
76547627 },
76557628 .input_member => {},
......@@ -7940,21 +7913,6 @@ fn flushNextMoved(elf: *Elf, ni: MappedFile.Node.Index) std.mem.Allocator.Error!
79407913 }
79417914}
79427915
7943fn updateDynamicEntry(elf: *Elf, key: u32, new_val: u64) void {
7944 switch (elf.shdrPtr(elf.shndx.dynamic)) {
7945 inline else => |shdr, class| {
7946 const dynamic_size = elf.targetLoad(&shdr.size);
7947 const dynamic_entries: [][2]class.ElfN().Addr = @ptrCast(@alignCast(
7948 elf.shndx.dynamic.get(elf).ni.slice(&elf.mf)[0..@intCast(dynamic_size)],
7949 ));
7950 for (dynamic_entries) |*dynamic_entry| {
7951 if (elf.targetLoad(&dynamic_entry[0]) == key) {
7952 elf.targetStore(&dynamic_entry[1], @intCast(new_val));
7953 }
7954 }
7955 },
7956 }
7957}
79587916fn addPltEntry(elf: *Elf, global_name: String(.strtab), dynsym_index: u32) void {
79597917 const target_endian = elf.targetEndian();
79607918