| ... | @@ -302,21 +302,28 @@ fn initSections(elf_file: *Elf) !void { | ... | @@ -302,21 +302,28 @@ fn initSections(elf_file: *Elf) !void { |
| 302 | try msec.initOutputSection(elf_file); | 302 | try msec.initOutputSection(elf_file); |
| 303 | } | 303 | } |
| 304 | | 304 | |
| 305 | const needs_eh_frame = for (elf_file.objects.items) |index| { | 305 | const needs_eh_frame = if (elf_file.zigObjectPtr()) |zo| |
| | 306 | zo.eh_frame_index != null |
| | 307 | else for (elf_file.objects.items) |index| { |
| 306 | if (elf_file.file(index).?.object.cies.items.len > 0) break true; | 308 | if (elf_file.file(index).?.object.cies.items.len > 0) break true; |
| 307 | } else false; | 309 | } else false; |
| 308 | if (needs_eh_frame) { | 310 | if (needs_eh_frame) { |
| 309 | if (elf_file.eh_frame_section_index == null) { | 311 | if (elf_file.eh_frame_section_index == null) { |
| 310 | elf_file.eh_frame_section_index = try elf_file.addSection(.{ | 312 | elf_file.eh_frame_section_index = blk: { |
| 311 | .name = try elf_file.insertShString(".eh_frame"), | 313 | if (elf_file.zigObjectPtr()) |zo| { |
| 312 | .type = if (elf_file.getTarget().cpu.arch == .x86_64) | 314 | if (zo.eh_frame_index) |idx| break :blk zo.symbol(idx).atom(elf_file).?.output_section_index; |
| 313 | elf.SHT_X86_64_UNWIND | 315 | } |
| 314 | else | 316 | break :blk try elf_file.addSection(.{ |
| 315 | elf.SHT_PROGBITS, | 317 | .name = try elf_file.insertShString(".eh_frame"), |
| 316 | .flags = elf.SHF_ALLOC, | 318 | .type = if (elf_file.getTarget().cpu.arch == .x86_64) |
| 317 | .addralign = elf_file.ptrWidthBytes(), | 319 | elf.SHT_X86_64_UNWIND |
| 318 | .offset = std.math.maxInt(u64), | 320 | else |
| 319 | }); | 321 | elf.SHT_PROGBITS, |
| | 322 | .flags = elf.SHF_ALLOC, |
| | 323 | .addralign = elf_file.ptrWidthBytes(), |
| | 324 | .offset = std.math.maxInt(u64), |
| | 325 | }); |
| | 326 | }; |
| 320 | } | 327 | } |
| 321 | elf_file.eh_frame_rela_section_index = try elf_file.addRelaShdr( | 328 | elf_file.eh_frame_rela_section_index = try elf_file.addRelaShdr( |
| 322 | try elf_file.insertShString(".rela.eh_frame"), | 329 | try elf_file.insertShString(".rela.eh_frame"), |