| ... | ... | @@ -34,12 +34,16 @@ pub fn flushStaticLib(elf_file: *Elf, comp: *Compilation, module_obj_path: ?[]co |
| 34 | 34 | // First, we flush relocatable object file generated with our backends. |
| 35 | 35 | if (elf_file.zigObjectPtr()) |zig_object| { |
| 36 | 36 | zig_object.resolveSymbols(elf_file); |
| 37 | try elf_file.addCommentString(); |
| 38 | try elf_file.finalizeMergeSections(); |
| 37 | 39 | zig_object.claimUnresolvedObject(elf_file); |
| 38 | 40 | |
| 41 | try elf_file.initMergeSections(); |
| 39 | 42 | try elf_file.initSymtab(); |
| 40 | 43 | try elf_file.initShStrtab(); |
| 41 | 44 | try elf_file.sortShdrs(); |
| 42 | 45 | try zig_object.addAtomsToRelaSections(elf_file); |
| 46 | try elf_file.updateMergeSectionSizes(); |
| 43 | 47 | try updateSectionSizes(elf_file); |
| 44 | 48 | |
| 45 | 49 | try allocateAllocSections(elf_file); |
| ... | ... | @@ -49,6 +53,7 @@ pub fn flushStaticLib(elf_file: *Elf, comp: *Compilation, module_obj_path: ?[]co |
| 49 | 53 | state_log.debug("{}", .{elf_file.dumpState()}); |
| 50 | 54 | } |
| 51 | 55 | |
| 56 | try elf_file.writeMergeSections(); |
| 52 | 57 | try writeSyntheticSections(elf_file); |
| 53 | 58 | try elf_file.writeShdrTable(); |
| 54 | 59 | try elf_file.writeElfHeader(); |
| ... | ... | @@ -185,6 +190,7 @@ pub fn flushObject(elf_file: *Elf, comp: *Compilation, module_obj_path: ?[]const |
| 185 | 190 | claimUnresolved(elf_file); |
| 186 | 191 | |
| 187 | 192 | try initSections(elf_file); |
| 193 | try elf_file.initMergeSections(); |
| 188 | 194 | try elf_file.sortShdrs(); |
| 189 | 195 | if (elf_file.zigObjectPtr()) |zig_object| { |
| 190 | 196 | try zig_object.addAtomsToRelaSections(elf_file); |
| ... | ... | @@ -280,25 +286,6 @@ fn initSections(elf_file: *Elf) !void { |
| 280 | 286 | try object.initRelaSections(elf_file); |
| 281 | 287 | } |
| 282 | 288 | |
| 283 | | for (elf_file.merge_sections.items) |*msec| { |
| 284 | | if (msec.subsections.items.len == 0) continue; |
| 285 | | const name = msec.name(elf_file); |
| 286 | | const shndx = elf_file.sectionByName(name) orelse try elf_file.addSection(.{ |
| 287 | | .name = name, |
| 288 | | .type = msec.type, |
| 289 | | .flags = msec.flags, |
| 290 | | }); |
| 291 | | msec.output_section_index = shndx; |
| 292 | | |
| 293 | | var entsize = elf_file.mergeSubsection(msec.subsections.items[0]).entsize; |
| 294 | | for (msec.subsections.items) |index| { |
| 295 | | const msub = elf_file.mergeSubsection(index); |
| 296 | | entsize = @min(entsize, msub.entsize); |
| 297 | | } |
| 298 | | const shdr = &elf_file.shdrs.items[shndx]; |
| 299 | | shdr.sh_entsize = entsize; |
| 300 | | } |
| 301 | | |
| 302 | 289 | const needs_eh_frame = for (elf_file.objects.items) |index| { |
| 303 | 290 | if (elf_file.file(index).?.object.cies.items.len > 0) break true; |
| 304 | 291 | } else false; |