| ... | @@ -3,7 +3,7 @@ symtab: std.ArrayListUnmanaged(elf.Elf64_Sym) = .{}, | ... | @@ -3,7 +3,7 @@ symtab: std.ArrayListUnmanaged(elf.Elf64_Sym) = .{}, |
| 3 | symbols: std.ArrayListUnmanaged(Symbol.Index) = .{}, | 3 | symbols: std.ArrayListUnmanaged(Symbol.Index) = .{}, |
| 4 | alive: bool = true, | 4 | alive: bool = true, |
| 5 | | 5 | |
| 6 | // output_symtab_size: Elf.SymtabSize = .{}, | 6 | output_symtab_size: Elf.SymtabSize = .{}, |
| 7 | | 7 | |
| 8 | pub fn deinit(self: *LinkerDefined, allocator: Allocator) void { | 8 | pub fn deinit(self: *LinkerDefined, allocator: Allocator) void { |
| 9 | self.symtab.deinit(allocator); | 9 | self.symtab.deinit(allocator); |
| ... | @@ -56,33 +56,25 @@ pub fn resolveSymbols(self: *LinkerDefined, elf_file: *Elf) void { | ... | @@ -56,33 +56,25 @@ pub fn resolveSymbols(self: *LinkerDefined, elf_file: *Elf) void { |
| 56 | // } | 56 | // } |
| 57 | // } | 57 | // } |
| 58 | | 58 | |
| 59 | // pub fn calcSymtabSize(self: *InternalObject, elf_file: *Elf) !void { | 59 | pub fn updateSymtabSize(self: *LinkerDefined, elf_file: *Elf) void { |
| 60 | // if (elf_file.options.strip_all) return; | 60 | for (self.globals()) |global_index| { |
| 61 | | 61 | const global = elf_file.symbol(global_index); |
| 62 | // for (self.getGlobals()) |global_index| { | 62 | if (global.file(elf_file)) |file| if (file.index() != self.index) continue; |
| 63 | // const global = elf_file.getSymbol(global_index); | 63 | global.flags.output_symtab = true; |
| 64 | // if (global.getFile(elf_file)) |file| if (file.getIndex() != self.index) continue; | 64 | self.output_symtab_size.nlocals += 1; |
| 65 | // global.flags.output_symtab = true; | 65 | } |
| 66 | // self.output_symtab_size.nlocals += 1; | 66 | } |
| 67 | // self.output_symtab_size.strsize += @as(u32, @intCast(global.getName(elf_file).len + 1)); | | |
| 68 | // } | | |
| 69 | // } | | |
| 70 | | | |
| 71 | // pub fn writeSymtab(self: *LinkerDefined, elf_file: *Elf, ctx: Elf.WriteSymtabCtx) !void { | | |
| 72 | // if (elf_file.options.strip_all) return; | | |
| 73 | | | |
| 74 | // const gpa = elf_file.base.allocator; | | |
| 75 | | 67 | |
| 76 | // var ilocal = ctx.ilocal; | 68 | pub fn writeSymtab(self: *LinkerDefined, elf_file: *Elf, ctx: anytype) void { |
| 77 | // for (self.getGlobals()) |global_index| { | 69 | var ilocal = ctx.ilocal; |
| 78 | // const global = elf_file.getSymbol(global_index); | 70 | for (self.globals()) |global_index| { |
| 79 | // if (global.getFile(elf_file)) |file| if (file.getIndex() != self.index) continue; | 71 | const global = elf_file.symbol(global_index); |
| 80 | // if (!global.flags.output_symtab) continue; | 72 | if (global.file(elf_file)) |file| if (file.index() != self.index) continue; |
| 81 | // const st_name = try ctx.strtab.insert(gpa, global.getName(elf_file)); | 73 | if (!global.flags.output_symtab) continue; |
| 82 | // ctx.symtab[ilocal] = global.asElfSym(st_name, elf_file); | 74 | global.setOutputSym(elf_file, &ctx.symtab[ilocal]); |
| 83 | // ilocal += 1; | 75 | ilocal += 1; |
| 84 | // } | 76 | } |
| 85 | // } | 77 | } |
| 86 | | 78 | |
| 87 | pub fn sourceSymbol(self: *LinkerDefined, symbol_index: Symbol.Index) *elf.Elf64_Sym { | 79 | pub fn sourceSymbol(self: *LinkerDefined, symbol_index: Symbol.Index) *elf.Elf64_Sym { |
| 88 | return &self.symtab.items[symbol_index]; | 80 | return &self.symtab.items[symbol_index]; |