| ... | @@ -727,7 +727,10 @@ pub fn allocateChunk(self: *Elf, shndx: u32, size: u64, alignment: Atom.Alignmen | ... | @@ -727,7 +727,10 @@ pub fn allocateChunk(self: *Elf, shndx: u32, size: u64, alignment: Atom.Alignmen |
| 727 | true; | 727 | true; |
| 728 | if (expand_section) { | 728 | if (expand_section) { |
| 729 | const needed_size = res.value + size; | 729 | const needed_size = res.value + size; |
| 730 | try self.growAllocSection(shndx, needed_size); | 730 | if (shdr.sh_flags & elf.SHF_ALLOC != 0) |
| | 731 | try self.growAllocSection(shndx, needed_size) |
| | 732 | else |
| | 733 | try self.growNonAllocSection(shndx, needed_size, @intCast(alignment.toByteUnits().?), true); |
| 731 | } | 734 | } |
| 732 | | 735 | |
| 733 | return res; | 736 | return res; |
| ... | @@ -1036,9 +1039,6 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod | ... | @@ -1036,9 +1039,6 @@ pub fn flushModule(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_nod |
| 1036 | try self.setHashSections(); | 1039 | try self.setHashSections(); |
| 1037 | try self.setVersionSymtab(); | 1040 | try self.setVersionSymtab(); |
| 1038 | | 1041 | |
| 1039 | for (self.objects.items) |index| { | | |
| 1040 | try self.file(index).?.object.addAtomsToOutputSections(self); | | |
| 1041 | } | | |
| 1042 | try self.sortInitFini(); | 1042 | try self.sortInitFini(); |
| 1043 | try self.updateMergeSectionSizes(); | 1043 | try self.updateMergeSectionSizes(); |
| 1044 | try self.updateSectionSizes(); | 1044 | try self.updateSectionSizes(); |
| ... | @@ -3560,29 +3560,29 @@ fn updateSectionSizes(self: *Elf) !void { | ... | @@ -3560,29 +3560,29 @@ fn updateSectionSizes(self: *Elf) !void { |
| 3560 | } | 3560 | } |
| 3561 | | 3561 | |
| 3562 | const slice = self.sections.slice(); | 3562 | const slice = self.sections.slice(); |
| 3563 | for (slice.items(.shdr), slice.items(.atom_list)) |*shdr, atom_list| { | 3563 | // for (slice.items(.shdr), slice.items(.atom_list)) |*shdr, atom_list| { |
| 3564 | if (atom_list.items.len == 0) continue; | 3564 | // if (atom_list.items.len == 0) continue; |
| 3565 | if (self.requiresThunks() and shdr.sh_flags & elf.SHF_EXECINSTR != 0) continue; | 3565 | // if (self.requiresThunks() and shdr.sh_flags & elf.SHF_EXECINSTR != 0) continue; |
| 3566 | for (atom_list.items) |ref| { | 3566 | // for (atom_list.items) |ref| { |
| 3567 | const atom_ptr = self.atom(ref) orelse continue; | 3567 | // const atom_ptr = self.atom(ref) orelse continue; |
| 3568 | if (!atom_ptr.alive) continue; | 3568 | // if (!atom_ptr.alive) continue; |
| 3569 | const offset = atom_ptr.alignment.forward(shdr.sh_size); | 3569 | // const offset = atom_ptr.alignment.forward(shdr.sh_size); |
| 3570 | const padding = offset - shdr.sh_size; | 3570 | // const padding = offset - shdr.sh_size; |
| 3571 | atom_ptr.value = @intCast(offset); | 3571 | // atom_ptr.value = @intCast(offset); |
| 3572 | shdr.sh_size += padding + atom_ptr.size; | 3572 | // shdr.sh_size += padding + atom_ptr.size; |
| 3573 | shdr.sh_addralign = @max(shdr.sh_addralign, atom_ptr.alignment.toByteUnits() orelse 1); | 3573 | // shdr.sh_addralign = @max(shdr.sh_addralign, atom_ptr.alignment.toByteUnits() orelse 1); |
| 3574 | } | 3574 | // } |
| 3575 | } | 3575 | // } |
| 3576 | | 3576 | |
| 3577 | if (self.requiresThunks()) { | 3577 | // if (self.requiresThunks()) { |
| 3578 | for (slice.items(.shdr), slice.items(.atom_list), 0..) |*shdr, atom_list, shndx| { | 3578 | // for (slice.items(.shdr), slice.items(.atom_list), 0..) |*shdr, atom_list, shndx| { |
| 3579 | if (shdr.sh_flags & elf.SHF_EXECINSTR == 0) continue; | 3579 | // if (shdr.sh_flags & elf.SHF_EXECINSTR == 0) continue; |
| 3580 | if (atom_list.items.len == 0) continue; | 3580 | // if (atom_list.items.len == 0) continue; |
| 3581 | | 3581 | |
| 3582 | // Create jump/branch range extenders if needed. | 3582 | // // Create jump/branch range extenders if needed. |
| 3583 | try self.createThunks(shdr, @intCast(shndx)); | 3583 | // try self.createThunks(shdr, @intCast(shndx)); |
| 3584 | } | 3584 | // } |
| 3585 | } | 3585 | // } |
| 3586 | | 3586 | |
| 3587 | const shdrs = slice.items(.shdr); | 3587 | const shdrs = slice.items(.shdr); |
| 3588 | if (self.eh_frame_section_index) |index| { | 3588 | if (self.eh_frame_section_index) |index| { |