@@ -4184,26 +4184,21 @@ pub fn allocateNonAllocSections(self: *Elf) !void {
4184
4184
shdr .sh_offset ,
4185
4185
new_offset ,
4186
4186
});
4187
- const zig_object = self .zigObjectPtr ().? ;
4188
- const existing_size = blk : {
4189
- if (shndx == self .debug_info_section_index .? )
4190
- break :blk zig_object .debug_info_section_zig_size ;
4191
- if (shndx == self .debug_abbrev_section_index .? )
4192
- break :blk zig_object .debug_abbrev_section_zig_size ;
4193
- if (shndx == self .debug_str_section_index .? )
4194
- break :blk zig_object .debug_str_section_zig_size ;
4195
- if (shndx == self .debug_aranges_section_index .? )
4196
- break :blk zig_object .debug_aranges_section_zig_size ;
4197
- if (shndx == self .debug_line_section_index .? )
4198
- break :blk zig_object .debug_line_section_zig_size ;
4199
- if (shndx == self .debug_line_str_section_index .? )
4200
- break :blk zig_object .debug_line_str_section_zig_size ;
4201
- if (shndx == self .debug_loclists_section_index .? )
4202
- break :blk zig_object .debug_loclists_section_zig_size ;
4203
- if (shndx == self .debug_rnglists_section_index .? )
4204
- break :blk zig_object .debug_rnglists_section_zig_size ;
4205
- unreachable ;
4206
- };
4187
+ const zo = self .zigObjectPtr ().? ;
4188
+ const existing_size = for ([_ ]Symbol.Index {
4189
+ zo .debug_info_index .? ,
4190
+ zo .debug_abbrev_index .? ,
4191
+ zo .debug_aranges_index .? ,
4192
+ zo .debug_str_index .? ,
4193
+ zo .debug_line_index .? ,
4194
+ zo .debug_line_str_index .? ,
4195
+ zo .debug_loclists_index .? ,
4196
+ zo .debug_rnglists_index .? ,
4197
+ }) | sym_index | {
4198
+ const sym = zo .symbol (sym_index );
4199
+ const atom_ptr = sym .atom (self ).? ;
4200
+ if (atom_ptr .output_section_index == shndx ) break atom_ptr .size ;
4201
+ } else 0 ;
4207
4202
const amt = try self .base .file .? .copyRangeAll (
4208
4203
shdr .sh_offset ,
4209
4204
self .base .file .? ,
@@ -4299,24 +4294,21 @@ fn writeAtoms(self: *Elf) !void {
4299
4294
4300
4295
// TODO really, really handle debug section separately
4301
4296
const base_offset = if (self .isDebugSection (@intCast (shndx ))) blk : {
4302
- const zig_object = self .zigObjectPtr ().? ;
4303
- if (shndx == self .debug_info_section_index .? )
4304
- break :blk zig_object .debug_info_section_zig_size ;
4305
- if (shndx == self .debug_abbrev_section_index .? )
4306
- break :blk zig_object .debug_abbrev_section_zig_size ;
4307
- if (shndx == self .debug_str_section_index .? )
4308
- break :blk zig_object .debug_str_section_zig_size ;
4309
- if (shndx == self .debug_aranges_section_index .? )
4310
- break :blk zig_object .debug_aranges_section_zig_size ;
4311
- if (shndx == self .debug_line_section_index .? )
4312
- break :blk zig_object .debug_line_section_zig_size ;
4313
- if (shndx == self .debug_line_str_section_index .? )
4314
- break :blk zig_object .debug_line_str_section_zig_size ;
4315
- if (shndx == self .debug_loclists_section_index .? )
4316
- break :blk zig_object .debug_loclists_section_zig_size ;
4317
- if (shndx == self .debug_rnglists_section_index .? )
4318
- break :blk zig_object .debug_rnglists_section_zig_size ;
4319
- unreachable ;
4297
+ const zo = self .zigObjectPtr ().? ;
4298
+ break :blk for ([_ ]Symbol.Index {
4299
+ zo .debug_info_index .? ,
4300
+ zo .debug_abbrev_index .? ,
4301
+ zo .debug_aranges_index .? ,
4302
+ zo .debug_str_index .? ,
4303
+ zo .debug_line_index .? ,
4304
+ zo .debug_line_str_index .? ,
4305
+ zo .debug_loclists_index .? ,
4306
+ zo .debug_rnglists_index .? ,
4307
+ }) | sym_index | {
4308
+ const sym = zo .symbol (sym_index );
4309
+ const atom_ptr = sym .atom (self ).? ;
4310
+ if (atom_ptr .output_section_index == shndx ) break atom_ptr .size ;
4311
+ } else 0 ;
4320
4312
} else 0 ;
4321
4313
const sh_offset = shdr .sh_offset + base_offset ;
4322
4314
const sh_size = math .cast (usize , shdr .sh_size - base_offset ) orelse return error .Overflow ;
0 commit comments