Skip to content

Commit ad6e095

Browse files
FireFox317andrewrk
authored andcommitted
stage2.Elf: fix off by one error in writeOffsetTableEntry
The code was using the length of the local symbols, which also includes the null symbol. Fix this by using the offset table instead, which only keeps track of the symbols that end up in the got.
1 parent 4fb896f commit ad6e095

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/link/Elf.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2706,7 +2706,7 @@ fn writeOffsetTableEntry(self: *Elf, index: usize) !void {
27062706
if (self.offset_table_count_dirty) {
27072707
// TODO Also detect virtual address collisions.
27082708
const allocated_size = self.allocatedSize(shdr.sh_offset);
2709-
const needed_size = self.local_symbols.items.len * entry_size;
2709+
const needed_size = self.offset_table.items.len * entry_size;
27102710
if (needed_size > allocated_size) {
27112711
// Must move the entire got section.
27122712
const new_offset = self.findFreeSpace(needed_size, entry_size);

0 commit comments

Comments
 (0)