| author | |
| committer | |
| log | a16e6706b337e2c7247238d08f205594d777a63a |
| tree | 16fa4ba0998cbc4c2db75319277dd6431ccdeea5 |
| parent | d8b1ef9430e0e383769ffa0a43750515aaa32280 |
4 files changed, 7 insertions(+), 7 deletions(-)
src/link/Elf/Atom.zig+1-1| ... | @@ -319,7 +319,7 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El | ... | @@ -319,7 +319,7 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El |
| 319 | r_sym = elf_file.sectionSymbolOutputSymtabIndex(target.outputShndx().?); | 319 | r_sym = elf_file.sectionSymbolOutputSymtabIndex(target.outputShndx().?); |
| 320 | }, | 320 | }, |
| 321 | else => { | 321 | else => { |
| 322 | r_sym = target.outputSymtabIndex(elf_file); | 322 | r_sym = target.outputSymtabIndex(elf_file) orelse 0; |
| 323 | }, | 323 | }, |
| 324 | } | 324 | } |
| 325 | 325 |
src/link/Elf/Symbol.zig+2-2| ... | @@ -107,8 +107,8 @@ pub fn address(symbol: Symbol, opts: struct { plt: bool = true }, elf_file: *Elf | ... | @@ -107,8 +107,8 @@ pub fn address(symbol: Symbol, opts: struct { plt: bool = true }, elf_file: *Elf |
| 107 | return symbol.value; | 107 | return symbol.value; |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | pub fn outputSymtabIndex(symbol: Symbol, elf_file: *Elf) u32 { | 110 | pub fn outputSymtabIndex(symbol: Symbol, elf_file: *Elf) ?u32 { |
| 111 | assert(symbol.flags.output_symtab); | 111 | if (!symbol.flags.output_symtab) return null; |
| 112 | const file_ptr = symbol.file(elf_file).?; | 112 | const file_ptr = symbol.file(elf_file).?; |
| 113 | const symtab_ctx = switch (file_ptr) { | 113 | const symtab_ctx = switch (file_ptr) { |
| 114 | inline else => |x| x.output_symtab_ctx, | 114 | inline else => |x| x.output_symtab_ctx, |
src/link/Elf/ZigObject.zig+2| ... | @@ -538,6 +538,8 @@ pub fn addAtomsToRelaSections(self: ZigObject, elf_file: *Elf) !void { | ... | @@ -538,6 +538,8 @@ pub fn addAtomsToRelaSections(self: ZigObject, elf_file: *Elf) !void { |
| 538 | if (!atom.flags.alive) continue; | 538 | if (!atom.flags.alive) continue; |
| 539 | _ = atom.relocsShndx() orelse continue; | 539 | _ = atom.relocsShndx() orelse continue; |
| 540 | const out_shndx = atom.outputShndx().?; | 540 | const out_shndx = atom.outputShndx().?; |
| 541 | const out_shdr = elf_file.shdrs.items[out_shndx]; | ||
| 542 | if (out_shdr.sh_type == elf.SHT_NOBITS) continue; | ||
| 541 | 543 | ||
| 542 | const gpa = elf_file.base.allocator; | 544 | const gpa = elf_file.base.allocator; |
| 543 | const sec = elf_file.output_rela_sections.getPtr(out_shndx).?; | 545 | const sec = elf_file.output_rela_sections.getPtr(out_shndx).?; |
src/link/Elf/file.zig+2-4| ... | @@ -165,8 +165,7 @@ pub const File = union(enum) { | ... | @@ -165,8 +165,7 @@ pub const File = union(enum) { |
| 165 | pub fn writeSymtab(file: File, elf_file: *Elf) void { | 165 | pub fn writeSymtab(file: File, elf_file: *Elf) void { |
| 166 | for (file.locals()) |local_index| { | 166 | for (file.locals()) |local_index| { |
| 167 | const local = elf_file.symbol(local_index); | 167 | const local = elf_file.symbol(local_index); |
| 168 | if (!local.flags.output_symtab) continue; | 168 | const idx = local.outputSymtabIndex(elf_file) orelse continue; |
| 169 | const idx = local.outputSymtabIndex(elf_file); | ||
| 170 | const out_sym = &elf_file.symtab.items[idx]; | 169 | const out_sym = &elf_file.symtab.items[idx]; |
| 171 | out_sym.st_name = @intCast(elf_file.strtab.items.len); | 170 | out_sym.st_name = @intCast(elf_file.strtab.items.len); |
| 172 | elf_file.strtab.appendSliceAssumeCapacity(local.name(elf_file)); | 171 | elf_file.strtab.appendSliceAssumeCapacity(local.name(elf_file)); |
| ... | @@ -178,11 +177,10 @@ pub const File = union(enum) { | ... | @@ -178,11 +177,10 @@ pub const File = union(enum) { |
| 178 | const global = elf_file.symbol(global_index); | 177 | const global = elf_file.symbol(global_index); |
| 179 | const file_ptr = global.file(elf_file) orelse continue; | 178 | const file_ptr = global.file(elf_file) orelse continue; |
| 180 | if (file_ptr.index() != file.index()) continue; | 179 | if (file_ptr.index() != file.index()) continue; |
| 181 | if (!global.flags.output_symtab) continue; | 180 | const idx = global.outputSymtabIndex(elf_file) orelse continue; |
| 182 | const st_name = @as(u32, @intCast(elf_file.strtab.items.len)); | 181 | const st_name = @as(u32, @intCast(elf_file.strtab.items.len)); |
| 183 | elf_file.strtab.appendSliceAssumeCapacity(global.name(elf_file)); | 182 | elf_file.strtab.appendSliceAssumeCapacity(global.name(elf_file)); |
| 184 | elf_file.strtab.appendAssumeCapacity(0); | 183 | elf_file.strtab.appendAssumeCapacity(0); |
| 185 | const idx = global.outputSymtabIndex(elf_file); | ||
| 186 | const out_sym = &elf_file.symtab.items[idx]; | 184 | const out_sym = &elf_file.symtab.items[idx]; |
| 187 | out_sym.st_name = st_name; | 185 | out_sym.st_name = st_name; |
| 188 | global.setOutputSym(elf_file, out_sym); | 186 | global.setOutputSym(elf_file, out_sym); |