diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-08-18 14:54:12 +0200 |
|---|---|---|
| committer | Jacob Young <jacobly0@users.noreply.github.com> | 2024-08-21 01:43:21 -0400 |
| commit | 56e1ae21e42b63ea4409b68950691fb89bfd1d21 (patch) | |
| tree | 1ce47fe18c6dc4297f94e7a6fefa9464c24ee15d /src | |
| parent | 41f2302865b92db81d839788393b126a34a56e62 (diff) | |
| download | zig-56e1ae21e42b63ea4409b68950691fb89bfd1d21.tar.gz zig-56e1ae21e42b63ea4409b68950691fb89bfd1d21.zip | |
elf: populate debug atoms on the linker side after Dwarf.flushModule
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/Dwarf.zig | 2 | ||||
| -rw-r--r-- | src/link/Elf/ZigObject.zig | 37 |
2 files changed, 38 insertions, 1 deletions
diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index 60c0bac4a8..f74d8e82a4 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -201,7 +201,7 @@ const StringSection = struct { }; /// A linker section containing a sequence of `Unit`s. -const Section = struct { +pub const Section = struct { dirty: bool, pad_to_ideal: bool, alignment: InternPool.Alignment, diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index f951e7ea71..a82d1f8809 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -181,6 +181,43 @@ pub fn flushModule(self: *ZigObject, elf_file: *Elf, tid: Zcu.PerThread.Id) !voi const pt: Zcu.PerThread = .{ .zcu = elf_file.base.comp.module.?, .tid = tid }; try dwarf.flushModule(pt); + // TODO invert this logic so that we manage the output section with the atom, not the + // other way around + for ([_]u32{ + self.debug_info_index.?, + self.debug_abbrev_index.?, + self.debug_str_index.?, + self.debug_aranges_index.?, + self.debug_line_index.?, + self.debug_line_str_index.?, + self.debug_loclists_index.?, + self.debug_rnglists_index.?, + }, [_]Dwarf.Section{ + dwarf.debug_info.section, + dwarf.debug_abbrev.section, + dwarf.debug_str.section, + dwarf.debug_aranges.section, + dwarf.debug_line.section, + dwarf.debug_line_str.section, + dwarf.debug_loclists.section, + dwarf.debug_rnglists.section, + }) |sym_index, sect| { + const sym = self.symbol(sym_index); + const atom_ptr = self.atom(sym.ref.index).?; + if (!atom_ptr.alive) continue; + const shdr = elf_file.shdrs.items[sym.outputShndx(elf_file).?]; + const esym = &self.symtab.items(.elf_sym)[sym.esym_index]; + esym.st_size = shdr.sh_size; + atom_ptr.size = shdr.sh_size; + atom_ptr.alignment = Atom.Alignment.fromNonzeroByteUnits(shdr.sh_addralign); + + const relocs = &self.relocs.items[atom_ptr.relocsShndx().?]; + _ = relocs; + for (sect.units.items) |unit| { + _ = unit; + } + } + self.debug_abbrev_section_dirty = false; self.debug_aranges_section_dirty = false; self.debug_rnglists_section_dirty = false; |
