| ... | @@ -909,10 +909,7 @@ pub fn growAllocSection(self: *Elf, shdr_index: u16, needed_size: u64) !void { | ... | @@ -909,10 +909,7 @@ pub fn growAllocSection(self: *Elf, shdr_index: u16, needed_size: u64) !void { |
| 909 | if (needed_size > self.allocatedSize(shdr.sh_offset) and !is_zerofill) { | 909 | if (needed_size > self.allocatedSize(shdr.sh_offset) and !is_zerofill) { |
| 910 | // Must move the entire section. | 910 | // Must move the entire section. |
| 911 | const new_offset = self.findFreeSpace(needed_size, self.page_size); | 911 | const new_offset = self.findFreeSpace(needed_size, self.page_size); |
| 912 | const existing_size = if (self.last_atom_and_free_list_table.get(shdr_index)) |meta| blk: { | 912 | const existing_size = shdr.sh_size; |
| 913 | const last = self.atom(meta.last_atom_index) orelse break :blk 0; | | |
| 914 | break :blk (last.value + last.size) - phdr.p_vaddr; | | |
| 915 | } else shdr.sh_size; | | |
| 916 | shdr.sh_size = 0; | 913 | shdr.sh_size = 0; |
| 917 | | 914 | |
| 918 | log.debug("new '{s}' file offset 0x{x} to 0x{x}", .{ | 915 | log.debug("new '{s}' file offset 0x{x} to 0x{x}", .{ |
| ... | @@ -922,6 +919,7 @@ pub fn growAllocSection(self: *Elf, shdr_index: u16, needed_size: u64) !void { | ... | @@ -922,6 +919,7 @@ pub fn growAllocSection(self: *Elf, shdr_index: u16, needed_size: u64) !void { |
| 922 | }); | 919 | }); |
| 923 | | 920 | |
| 924 | const amt = try self.base.file.?.copyRangeAll(shdr.sh_offset, self.base.file.?, new_offset, existing_size); | 921 | const amt = try self.base.file.?.copyRangeAll(shdr.sh_offset, self.base.file.?, new_offset, existing_size); |
| | 922 | // TODO figure out what to about this error condition - how to communicate it up. |
| 925 | if (amt != existing_size) return error.InputOutput; | 923 | if (amt != existing_size) return error.InputOutput; |
| 926 | | 924 | |
| 927 | shdr.sh_offset = new_offset; | 925 | shdr.sh_offset = new_offset; |