| author | |
| committer | |
| log | 860beda55fd94fc56fce20c79aa6ddadce9baf39 |
| tree | 06a55b71c5ee5803dcecc1fc074b9d9b5af2f5c9 |
| parent | 6faed6269fca56d583d2bc5bf35f55a51eb54cdf |
2 files changed, 14 insertions(+), 18 deletions(-)
src/link/Elf.zig+8-9| ... | ... | @@ -111,7 +111,6 @@ symbols_free_list: std.ArrayListUnmanaged(Symbol.Index) = .{}, |
| 111 | 111 | |
| 112 | 112 | phdr_table_dirty: bool = false, |
| 113 | 113 | shdr_table_dirty: bool = false, |
| 114 | got_addresses_dirty: bool = false, | |
| 115 | 114 | |
| 116 | 115 | debug_strtab_dirty: bool = false, |
| 117 | 116 | debug_abbrev_section_dirty: bool = false, |
| ... | ... | @@ -904,9 +903,10 @@ pub fn growAllocSection(self: *Elf, shdr_index: u16, needed_size: u64) !void { |
| 904 | 903 | // and grow. |
| 905 | 904 | { |
| 906 | 905 | const dirty_addr = phdr.p_vaddr + phdr.p_memsz; |
| 907 | self.got_addresses_dirty = for (self.got.entries.items) |entry| { | |
| 906 | const got_addresses_dirty = for (self.got.entries.items) |entry| { | |
| 908 | 907 | if (self.symbol(entry.symbol_index).value >= dirty_addr) break true; |
| 909 | 908 | } else false; |
| 909 | _ = got_addresses_dirty; | |
| 910 | 910 | |
| 911 | 911 | // TODO mark relocs dirty |
| 912 | 912 | } |
| ... | ... | @@ -1504,8 +1504,6 @@ pub fn flushModule(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node |
| 1504 | 1504 | assert(!self.phdr_table_dirty); |
| 1505 | 1505 | assert(!self.shdr_table_dirty); |
| 1506 | 1506 | assert(!self.debug_strtab_dirty); |
| 1507 | assert(!self.got.dirty); | |
| 1508 | assert(!self.got_addresses_dirty); | |
| 1509 | 1507 | } |
| 1510 | 1508 | |
| 1511 | 1509 | const ParseError = error{ |
| ... | ... | @@ -3660,13 +3658,14 @@ fn updateSymtabSize(self: *Elf) !void { |
| 3660 | 3658 | } |
| 3661 | 3659 | |
| 3662 | 3660 | fn writeSyntheticSections(self: *Elf) !void { |
| 3663 | if (self.got_addresses_dirty) { | |
| 3664 | const shdr = &self.shdrs.items[self.got_section_index.?]; | |
| 3665 | var buffer = try std.ArrayList(u8).initCapacity(self.base.allocator, self.got.size(self)); | |
| 3661 | const gpa = self.base.allocator; | |
| 3662 | ||
| 3663 | if (self.got_section_index) |index| { | |
| 3664 | const shdr = self.shdrs.items[index]; | |
| 3665 | var buffer = try std.ArrayList(u8).initCapacity(gpa, self.got.size(self)); | |
| 3666 | 3666 | defer buffer.deinit(); |
| 3667 | try self.got.writeAllEntries(self, buffer.writer()); | |
| 3667 | try self.got.write(self, buffer.writer()); | |
| 3668 | 3668 | try self.base.file.?.pwriteAll(buffer.items, shdr.sh_offset); |
| 3669 | self.got_addresses_dirty = false; | |
| 3670 | 3669 | } |
| 3671 | 3670 | |
| 3672 | 3671 | if (self.shstrtab_section_index) |index| { |
src/link/Elf/synthetic_sections.zig+6-9| ... | ... | @@ -1,7 +1,6 @@ |
| 1 | 1 | pub const GotSection = struct { |
| 2 | 2 | entries: std.ArrayListUnmanaged(Entry) = .{}, |
| 3 | 3 | needs_rela: bool = false, |
| 4 | dirty: bool = false, | |
| 5 | 4 | output_symtab_size: Elf.SymtabSize = .{}, |
| 6 | 5 | |
| 7 | 6 | pub const Index = u32; |
| ... | ... | @@ -48,7 +47,6 @@ pub const GotSection = struct { |
| 48 | 47 | break :blk last.cell_index + @as(Index, @intCast(last.len())); |
| 49 | 48 | } else 0; |
| 50 | 49 | entry.* = .{ .tag = undefined, .symbol_index = undefined, .cell_index = cell_index }; |
| 51 | got.dirty = true; | |
| 52 | 50 | return index; |
| 53 | 51 | } |
| 54 | 52 | |
| ... | ... | @@ -117,11 +115,11 @@ pub const GotSection = struct { |
| 117 | 115 | |
| 118 | 116 | pub fn writeEntry(got: *GotSection, elf_file: *Elf, index: Index) !void { |
| 119 | 117 | const entry_size: u16 = elf_file.archPtrWidthBytes(); |
| 120 | if (got.dirty) { | |
| 121 | const needed_size = got.size(elf_file); | |
| 122 | try elf_file.growAllocSection(elf_file.got_section_index.?, needed_size); | |
| 123 | got.dirty = false; | |
| 124 | } | |
| 118 | // if (got.dirty) { | |
| 119 | // const needed_size = got.size(elf_file); | |
| 120 | // try elf_file.growAllocSection(elf_file.got_section_index.?, needed_size); | |
| 121 | // got.dirty = false; | |
| 122 | // } | |
| 125 | 123 | const endian = elf_file.base.options.target.cpu.arch.endian(); |
| 126 | 124 | const entry = got.entries.items[index]; |
| 127 | 125 | const shdr = &elf_file.shdrs.items[elf_file.got_section_index.?]; |
| ... | ... | @@ -169,8 +167,7 @@ pub const GotSection = struct { |
| 169 | 167 | } |
| 170 | 168 | } |
| 171 | 169 | |
| 172 | pub fn writeAllEntries(got: GotSection, elf_file: *Elf, writer: anytype) !void { | |
| 173 | assert(!got.dirty); | |
| 170 | pub fn write(got: GotSection, elf_file: *Elf, writer: anytype) !void { | |
| 174 | 171 | const entry_size: u16 = elf_file.archPtrWidthBytes(); |
| 175 | 172 | const endian = elf_file.base.options.target.cpu.arch.endian(); |
| 176 | 173 | for (got.entries.items) |entry| { |