| author | |
| committer | |
| log | e8d008a8a83f10b8400691bef216147e08ac2daf |
| tree | db9aae30efd8882a1a0890262a2f169d20eb70fd |
| parent | 96c20adeee84dbd86a7036cce49ef0c58870bdce |
5 files changed, 14 insertions(+), 20 deletions(-)
src/link/Elf.zig+1-1| ... | ... | @@ -1372,7 +1372,7 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod |
| 1372 | 1372 | for (zo.atoms_indexes.items) |atom_index| { |
| 1373 | 1373 | const atom_ptr = zo.atom(atom_index) orelse continue; |
| 1374 | 1374 | if (!atom_ptr.alive) continue; |
| 1375 | const out_shndx = atom_ptr.outputShndx() orelse continue; | |
| 1375 | const out_shndx = atom_ptr.output_section_index; | |
| 1376 | 1376 | const shdr = &self.shdrs.items[out_shndx]; |
| 1377 | 1377 | if (shdr.sh_type == elf.SHT_NOBITS) continue; |
| 1378 | 1378 | const code = try zo.codeAlloc(self, atom_index); |
src/link/Elf/Atom.zig+5-11| ... | ... | @@ -48,8 +48,7 @@ pub fn name(self: Atom, elf_file: *Elf) []const u8 { |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | pub fn address(self: Atom, elf_file: *Elf) i64 { |
| 51 | const shndx = self.outputShndx() orelse return self.value; | |
| 52 | const shdr = elf_file.shdrs.items[shndx]; | |
| 51 | const shdr = elf_file.shdrs.items[self.output_section_index]; | |
| 53 | 52 | return @as(i64, @intCast(shdr.sh_addr)) + self.value; |
| 54 | 53 | } |
| 55 | 54 | |
| ... | ... | @@ -87,11 +86,6 @@ pub fn relocsShndx(self: Atom) ?u32 { |
| 87 | 86 | return self.relocs_section_index; |
| 88 | 87 | } |
| 89 | 88 | |
| 90 | pub fn outputShndx(self: Atom) ?u32 { | |
| 91 | if (self.output_section_index == 0) return null; | |
| 92 | return self.output_section_index; | |
| 93 | } | |
| 94 | ||
| 95 | 89 | pub fn priority(self: Atom, elf_file: *Elf) u64 { |
| 96 | 90 | const index = self.file(elf_file).?.index(); |
| 97 | 91 | return (@as(u64, @intCast(index)) << 32) | @as(u64, @intCast(self.input_section_index)); |
| ... | ... | @@ -122,8 +116,8 @@ pub fn freeListEligible(self: Atom, elf_file: *Elf) bool { |
| 122 | 116 | |
| 123 | 117 | pub fn allocate(self: *Atom, elf_file: *Elf) !void { |
| 124 | 118 | const zo = elf_file.zigObjectPtr().?; |
| 125 | const shdr = &elf_file.shdrs.items[self.outputShndx().?]; | |
| 126 | const meta = elf_file.last_atom_and_free_list_table.getPtr(self.outputShndx().?).?; | |
| 119 | const shdr = &elf_file.shdrs.items[self.output_section_index]; | |
| 120 | const meta = elf_file.last_atom_and_free_list_table.getPtr(self.output_section_index).?; | |
| 127 | 121 | const free_list = &meta.free_list; |
| 128 | 122 | const last_atom_index = &meta.last_atom_index; |
| 129 | 123 | const new_atom_ideal_capacity = Elf.padToIdeal(self.size); |
| ... | ... | @@ -199,7 +193,7 @@ pub fn allocate(self: *Atom, elf_file: *Elf) !void { |
| 199 | 193 | true; |
| 200 | 194 | if (expand_section) { |
| 201 | 195 | const needed_size: u64 = @intCast(self.value + @as(i64, @intCast(self.size))); |
| 202 | try elf_file.growAllocSection(self.outputShndx().?, needed_size); | |
| 196 | try elf_file.growAllocSection(self.output_section_index, needed_size); | |
| 203 | 197 | last_atom_index.* = self.atom_index; |
| 204 | 198 | |
| 205 | 199 | const zig_object = elf_file.zigObjectPtr().?; |
| ... | ... | @@ -258,7 +252,7 @@ pub fn free(self: *Atom, elf_file: *Elf) void { |
| 258 | 252 | const zo = elf_file.zigObjectPtr().?; |
| 259 | 253 | const comp = elf_file.base.comp; |
| 260 | 254 | const gpa = comp.gpa; |
| 261 | const shndx = self.outputShndx().?; | |
| 255 | const shndx = self.output_section_index; | |
| 262 | 256 | const meta = elf_file.last_atom_and_free_list_table.getPtr(shndx).?; |
| 263 | 257 | const free_list = &meta.free_list; |
| 264 | 258 | const last_atom_index = &meta.last_atom_index; |
src/link/Elf/Object.zig+2-2| ... | ... | @@ -1036,12 +1036,12 @@ pub fn addAtomsToRelaSections(self: *Object, elf_file: *Elf) !void { |
| 1036 | 1036 | break :blk self.initOutputSection(elf_file, shdr) catch unreachable; |
| 1037 | 1037 | }; |
| 1038 | 1038 | const shdr = &elf_file.shdrs.items[shndx]; |
| 1039 | shdr.sh_info = atom_ptr.outputShndx().?; | |
| 1039 | shdr.sh_info = atom_ptr.output_section_index; | |
| 1040 | 1040 | shdr.sh_link = elf_file.symtab_section_index.?; |
| 1041 | 1041 | |
| 1042 | 1042 | const comp = elf_file.base.comp; |
| 1043 | 1043 | const gpa = comp.gpa; |
| 1044 | const gop = try elf_file.output_rela_sections.getOrPut(gpa, atom_ptr.outputShndx().?); | |
| 1044 | const gop = try elf_file.output_rela_sections.getOrPut(gpa, atom_ptr.output_section_index); | |
| 1045 | 1045 | if (!gop.found_existing) gop.value_ptr.* = .{ .shndx = shndx }; |
| 1046 | 1046 | try gop.value_ptr.atom_list.append(gpa, .{ .index = atom_index, .file = self.index }); |
| 1047 | 1047 | } |
src/link/Elf/ZigObject.zig+4-4| ... | ... | @@ -311,7 +311,7 @@ pub fn newAtom(self: *ZigObject, elf_file: *Elf) !Symbol.Index { |
| 311 | 311 | /// TODO actually create fake input shdrs and return that instead. |
| 312 | 312 | pub fn inputShdr(self: *ZigObject, atom_index: Atom.Index, elf_file: *Elf) elf.Elf64_Shdr { |
| 313 | 313 | const atom_ptr = self.atom(atom_index) orelse return Elf.null_shdr; |
| 314 | const shndx = atom_ptr.outputShndx() orelse return Elf.null_shdr; | |
| 314 | const shndx = atom_ptr.output_section_index; | |
| 315 | 315 | var shdr = elf_file.shdrs.items[shndx]; |
| 316 | 316 | shdr.sh_addr = 0; |
| 317 | 317 | shdr.sh_offset = 0; |
| ... | ... | @@ -342,7 +342,7 @@ pub fn resolveSymbols(self: *ZigObject, elf_file: *Elf) void { |
| 342 | 342 | else => unreachable, |
| 343 | 343 | }; |
| 344 | 344 | const output_section_index = if (self.atom(atom_index)) |atom_ptr| |
| 345 | atom_ptr.outputShndx().? | |
| 345 | atom_ptr.output_section_index | |
| 346 | 346 | else |
| 347 | 347 | elf.SHN_UNDEF; |
| 348 | 348 | global.value = @intCast(esym.st_value); |
| ... | ... | @@ -523,7 +523,7 @@ pub fn addAtomsToRelaSections(self: *ZigObject, elf_file: *Elf) !void { |
| 523 | 523 | const rela_shndx = atom_ptr.relocsShndx() orelse continue; |
| 524 | 524 | // TODO this check will become obsolete when we rework our relocs mechanism at the ZigObject level |
| 525 | 525 | if (self.relocs.items[rela_shndx].items.len == 0) continue; |
| 526 | const out_shndx = atom_ptr.outputShndx().?; | |
| 526 | const out_shndx = atom_ptr.output_section_index; | |
| 527 | 527 | const out_shdr = elf_file.shdrs.items[out_shndx]; |
| 528 | 528 | if (out_shdr.sh_type == elf.SHT_NOBITS) continue; |
| 529 | 529 | |
| ... | ... | @@ -623,7 +623,7 @@ pub fn asFile(self: *ZigObject) File { |
| 623 | 623 | pub fn codeAlloc(self: *ZigObject, elf_file: *Elf, atom_index: Atom.Index) ![]u8 { |
| 624 | 624 | const gpa = elf_file.base.comp.gpa; |
| 625 | 625 | const atom_ptr = self.atom(atom_index).?; |
| 626 | const shdr = &elf_file.shdrs.items[atom_ptr.outputShndx().?]; | |
| 626 | const shdr = &elf_file.shdrs.items[atom_ptr.output_section_index]; | |
| 627 | 627 | |
| 628 | 628 | if (shdr.sh_flags & elf.SHF_TLS != 0) { |
| 629 | 629 | const tlv = self.tls_variables.get(atom_index).?; |
src/link/Elf/synthetic_sections.zig+2-2| ... | ... | @@ -1701,13 +1701,13 @@ pub const ComdatGroupSection = struct { |
| 1701 | 1701 | elf.SHT_RELA => { |
| 1702 | 1702 | const atom_index = object.atoms_indexes.items[shdr.sh_info]; |
| 1703 | 1703 | const atom = object.atom(atom_index).?; |
| 1704 | const rela = elf_file.output_rela_sections.get(atom.outputShndx().?).?; | |
| 1704 | const rela = elf_file.output_rela_sections.get(atom.output_section_index).?; | |
| 1705 | 1705 | try writer.writeInt(u32, rela.shndx, .little); |
| 1706 | 1706 | }, |
| 1707 | 1707 | else => { |
| 1708 | 1708 | const atom_index = object.atoms_indexes.items[shndx]; |
| 1709 | 1709 | const atom = object.atom(atom_index).?; |
| 1710 | try writer.writeInt(u32, atom.outputShndx().?, .little); | |
| 1710 | try writer.writeInt(u32, atom.output_section_index, .little); | |
| 1711 | 1711 | }, |
| 1712 | 1712 | } |
| 1713 | 1713 | } |