| ... | ... | @@ -2799,6 +2799,22 @@ fn writeAllGlobalSymbols(self: *Elf) !void { |
| 2799 | 2799 | .p32 => @sizeOf(elf.Elf32_Sym), |
| 2800 | 2800 | .p64 => @sizeOf(elf.Elf64_Sym), |
| 2801 | 2801 | }; |
| 2802 | const sym_align: u16 = switch (self.ptr_width) { |
| 2803 | .p32 => @alignOf(elf.Elf32_Sym), |
| 2804 | .p64 => @alignOf(elf.Elf64_Sym), |
| 2805 | }; |
| 2806 | const needed_size = (self.local_symbols.items.len + self.global_symbols.items.len) * sym_size; |
| 2807 | if (needed_size > self.allocatedSize(syms_sect.sh_offset)) { |
| 2808 | // Move all the symbols to a new file location. |
| 2809 | const new_offset = self.findFreeSpace(needed_size, sym_align); |
| 2810 | const existing_size = @as(u64, syms_sect.sh_info) * sym_size; |
| 2811 | const amt = try self.base.file.?.copyRangeAll(syms_sect.sh_offset, self.base.file.?, new_offset, existing_size); |
| 2812 | if (amt != existing_size) return error.InputOutput; |
| 2813 | syms_sect.sh_offset = new_offset; |
| 2814 | } |
| 2815 | syms_sect.sh_size = needed_size; // anticipating adding the global symbols later |
| 2816 | self.shdr_table_dirty = true; // TODO look into only writing one section |
| 2817 | |
| 2802 | 2818 | const foreign_endian = self.base.options.target.cpu.arch.endian() != builtin.cpu.arch.endian(); |
| 2803 | 2819 | const global_syms_off = syms_sect.sh_offset + self.local_symbols.items.len * sym_size; |
| 2804 | 2820 | switch (self.ptr_width) { |