| ... | ... | @@ -1324,7 +1324,7 @@ pub const File = struct { |
| 1324 | 1324 | shstrtab_sect.sh_offset = self.findFreeSpace(needed_size, 1); |
| 1325 | 1325 | } |
| 1326 | 1326 | shstrtab_sect.sh_size = needed_size; |
| 1327 | | log.debug(.link, "shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size }); |
| 1327 | log.debug(.link, "writing shstrtab start=0x{x} end=0x{x}\n", .{ shstrtab_sect.sh_offset, shstrtab_sect.sh_offset + needed_size }); |
| 1328 | 1328 | |
| 1329 | 1329 | try self.file.?.pwriteAll(self.shstrtab.items, shstrtab_sect.sh_offset); |
| 1330 | 1330 | if (!self.shdr_table_dirty) { |
| ... | ... | @@ -1980,11 +1980,17 @@ pub const File = struct { |
| 1980 | 1980 | src_fn.off = self.dbgLineNeededHeaderBytes() * alloc_num / alloc_den; |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | | const needed_size = src_fn.off + src_fn.len; |
| 1983 | const last_src_fn = self.dbg_line_fn_last.?; |
| 1984 | const needed_size = last_src_fn.off + last_src_fn.len; |
| 1984 | 1985 | if (needed_size != debug_line_sect.sh_size) { |
| 1985 | 1986 | if (needed_size > self.allocatedSize(debug_line_sect.sh_offset)) { |
| 1986 | 1987 | const new_offset = self.findFreeSpace(needed_size, 1); |
| 1987 | | const existing_size = src_fn.off; |
| 1988 | const existing_size = last_src_fn.off; |
| 1989 | log.debug(.link, "moving .debug_line section: {} bytes from 0x{x} to 0x{x}\n", .{ |
| 1990 | existing_size, |
| 1991 | debug_line_sect.sh_offset, |
| 1992 | new_offset, |
| 1993 | }); |
| 1988 | 1994 | const amt = try self.file.?.copyRangeAll(debug_line_sect.sh_offset, self.file.?, new_offset, existing_size); |
| 1989 | 1995 | if (amt != existing_size) return error.InputOutput; |
| 1990 | 1996 | debug_line_sect.sh_offset = new_offset; |
| ... | ... | @@ -2112,7 +2118,6 @@ pub const File = struct { |
| 2112 | 2118 | |
| 2113 | 2119 | fn writeSectHeader(self: *Elf, index: usize) !void { |
| 2114 | 2120 | const foreign_endian = self.base.options.target.cpu.arch.endian() != std.Target.current.cpu.arch.endian(); |
| 2115 | | const offset = self.sections.items[index].sh_offset; |
| 2116 | 2121 | switch (self.base.options.target.cpu.arch.ptrBitWidth()) { |
| 2117 | 2122 | 32 => { |
| 2118 | 2123 | var shdr: [1]elf.Elf32_Shdr = undefined; |
| ... | ... | @@ -2120,6 +2125,7 @@ pub const File = struct { |
| 2120 | 2125 | if (foreign_endian) { |
| 2121 | 2126 | bswapAllFields(elf.Elf32_Shdr, &shdr[0]); |
| 2122 | 2127 | } |
| 2128 | const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf32_Shdr); |
| 2123 | 2129 | return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset); |
| 2124 | 2130 | }, |
| 2125 | 2131 | 64 => { |
| ... | ... | @@ -2127,6 +2133,7 @@ pub const File = struct { |
| 2127 | 2133 | if (foreign_endian) { |
| 2128 | 2134 | bswapAllFields(elf.Elf64_Shdr, &shdr[0]); |
| 2129 | 2135 | } |
| 2136 | const offset = self.shdr_table_offset.? + index * @sizeOf(elf.Elf64_Shdr); |
| 2130 | 2137 | return self.file.?.pwriteAll(mem.sliceAsBytes(&shdr), offset); |
| 2131 | 2138 | }, |
| 2132 | 2139 | else => return error.UnsupportedArchitecture, |