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