From bc39bddd5fd66037bc524bb7c824230fbb249e01 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 29 Aug 2024 22:08:36 +0200 Subject: elf: remove isDebugSection helper --- src/link/Elf/ZigObject.zig | 4 +++- src/link/Elf/relocatable.zig | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 13 deletions(-) (limited to 'src/link/Elf') diff --git a/src/link/Elf/ZigObject.zig b/src/link/Elf/ZigObject.zig index 39df4b78cc..0173ffb40b 100644 --- a/src/link/Elf/ZigObject.zig +++ b/src/link/Elf/ZigObject.zig @@ -52,8 +52,8 @@ debug_rnglists_section_dirty: bool = false, eh_frame_section_dirty: bool = false, text_index: ?Symbol.Index = null, -data_relro_index: ?Symbol.Index = null, rodata_index: ?Symbol.Index = null, +data_relro_index: ?Symbol.Index = null, data_index: ?Symbol.Index = null, bss_index: ?Symbol.Index = null, eh_frame_index: ?Symbol.Index = null, @@ -2003,6 +2003,8 @@ fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, elf_file: *Elf) !void { shdr.sh_addralign = @max(shdr.sh_addralign, atom_ptr.alignment.toByteUnits().?); const sect_atom_ptr = for ([_]?Symbol.Index{ + self.text_index, + self.rodata_index, self.data_index, self.data_relro_index, }) |maybe_sym_index| { diff --git a/src/link/Elf/relocatable.zig b/src/link/Elf/relocatable.zig index 8f5ea8e25b..4397bc2ca3 100644 --- a/src/link/Elf/relocatable.zig +++ b/src/link/Elf/relocatable.zig @@ -436,18 +436,18 @@ fn writeAtoms(elf_file: *Elf) !void { log.debug("writing atoms in '{s}' section", .{elf_file.getShString(shdr.sh_name)}); // TODO really, really handle debug section separately - const base_offset = if (elf_file.isDebugSection(@intCast(shndx))) blk: { - const zo = elf_file.zigObjectPtr().?; - break :blk for ([_]Symbol.Index{ - zo.debug_info_index.?, - zo.debug_abbrev_index.?, - zo.debug_aranges_index.?, - zo.debug_str_index.?, - zo.debug_line_index.?, - zo.debug_line_str_index.?, - zo.debug_loclists_index.?, - zo.debug_rnglists_index.?, - }) |sym_index| { + const base_offset = if (elf_file.zigObjectPtr()) |zo| blk: { + break :blk for ([_]?Symbol.Index{ + zo.debug_info_index, + zo.debug_abbrev_index, + zo.debug_aranges_index, + zo.debug_str_index, + zo.debug_line_index, + zo.debug_line_str_index, + zo.debug_loclists_index, + zo.debug_rnglists_index, + }) |maybe_sym_index| { + const sym_index = maybe_sym_index orelse continue; const sym = zo.symbol(sym_index); const atom_ptr = sym.atom(elf_file).?; if (atom_ptr.output_section_index == shndx) break atom_ptr.size; -- cgit v1.2.3