diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2024-09-03 14:45:59 +0200 |
|---|---|---|
| committer | Jakub Konka <kubkon@jakubkonka.com> | 2024-09-04 13:34:26 +0200 |
| commit | 5cdad186fe1cb83c6d79642433bfbe330436914a (patch) | |
| tree | 1faa27605eff1543d40902ec53d64c4e3674c7fb /src | |
| parent | 88e0d49febf5839654e4a5f3dc02ad6b2a82e242 (diff) | |
| download | zig-5cdad186fe1cb83c6d79642433bfbe330436914a.tar.gz zig-5cdad186fe1cb83c6d79642433bfbe330436914a.zip | |
elf: do not create .eh_frame section if ZigObject already did so in relocatable mode
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/Elf/relocatable.zig | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/link/Elf/relocatable.zig b/src/link/Elf/relocatable.zig index 6499bc207b..ea710e7b2a 100644 --- a/src/link/Elf/relocatable.zig +++ b/src/link/Elf/relocatable.zig @@ -302,21 +302,28 @@ fn initSections(elf_file: *Elf) !void { try msec.initOutputSection(elf_file); } - const needs_eh_frame = for (elf_file.objects.items) |index| { + const needs_eh_frame = if (elf_file.zigObjectPtr()) |zo| + zo.eh_frame_index != null + else for (elf_file.objects.items) |index| { if (elf_file.file(index).?.object.cies.items.len > 0) break true; } else false; if (needs_eh_frame) { if (elf_file.eh_frame_section_index == null) { - elf_file.eh_frame_section_index = try elf_file.addSection(.{ - .name = try elf_file.insertShString(".eh_frame"), - .type = if (elf_file.getTarget().cpu.arch == .x86_64) - elf.SHT_X86_64_UNWIND - else - elf.SHT_PROGBITS, - .flags = elf.SHF_ALLOC, - .addralign = elf_file.ptrWidthBytes(), - .offset = std.math.maxInt(u64), - }); + elf_file.eh_frame_section_index = blk: { + if (elf_file.zigObjectPtr()) |zo| { + if (zo.eh_frame_index) |idx| break :blk zo.symbol(idx).atom(elf_file).?.output_section_index; + } + break :blk try elf_file.addSection(.{ + .name = try elf_file.insertShString(".eh_frame"), + .type = if (elf_file.getTarget().cpu.arch == .x86_64) + elf.SHT_X86_64_UNWIND + else + elf.SHT_PROGBITS, + .flags = elf.SHF_ALLOC, + .addralign = elf_file.ptrWidthBytes(), + .offset = std.math.maxInt(u64), + }); + }; } elf_file.eh_frame_rela_section_index = try elf_file.addRelaShdr( try elf_file.insertShString(".rela.eh_frame"), |
