| ... | @@ -154,7 +154,8 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option | ... | @@ -154,7 +154,8 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option |
| 154 | | 154 | |
| 155 | // Index 0 is always a null symbol. | 155 | // Index 0 is always a null symbol. |
| 156 | try self.locals.append(allocator, null_sym); | 156 | try self.locals.append(allocator, null_sym); |
| 157 | | 157 | // Allocate atom index 0 to null atom |
| | 158 | try self.atoms.append(allocator, .{}); |
| 158 | // There must always be a null section in index 0 | 159 | // There must always be a null section in index 0 |
| 159 | try self.sections.append(allocator, .{ | 160 | try self.sections.append(allocator, .{ |
| 160 | .shdr = .{ | 161 | .shdr = .{ |
| ... | @@ -212,6 +213,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { | ... | @@ -212,6 +213,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { |
| 212 | if (use_llvm) { | 213 | if (use_llvm) { |
| 213 | self.llvm_object = try LlvmObject.create(gpa, options); | 214 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 214 | } | 215 | } |
| | 216 | |
| 215 | return self; | 217 | return self; |
| 216 | } | 218 | } |
| 217 | | 219 | |
| ... | @@ -2158,11 +2160,7 @@ pub fn createAtom(self: *Elf) !Atom.Index { | ... | @@ -2158,11 +2160,7 @@ pub fn createAtom(self: *Elf) !Atom.Index { |
| 2158 | const atom_ptr = try self.atoms.addOne(gpa); | 2160 | const atom_ptr = try self.atoms.addOne(gpa); |
| 2159 | const sym_index = try self.allocateSymbol(); | 2161 | const sym_index = try self.allocateSymbol(); |
| 2160 | try self.atom_by_index_table.putNoClobber(gpa, sym_index, atom_index); | 2162 | try self.atom_by_index_table.putNoClobber(gpa, sym_index, atom_index); |
| 2161 | atom_ptr.* = .{ | 2163 | atom_ptr.* = .{ .sym_index = sym_index }; |
| 2162 | .sym_index = sym_index, | | |
| 2163 | .prev_index = null, | | |
| 2164 | .next_index = null, | | |
| 2165 | }; | | |
| 2166 | log.debug("creating ATOM(%{d}) at index {d}", .{ sym_index, atom_index }); | 2164 | log.debug("creating ATOM(%{d}) at index {d}", .{ sym_index, atom_index }); |
| 2167 | return atom_index; | 2165 | return atom_index; |
| 2168 | } | 2166 | } |
| ... | @@ -2300,14 +2298,7 @@ pub fn allocateSymbol(self: *Elf) !u32 { | ... | @@ -2300,14 +2298,7 @@ pub fn allocateSymbol(self: *Elf) !u32 { |
| 2300 | break :blk index; | 2298 | break :blk index; |
| 2301 | } | 2299 | } |
| 2302 | }; | 2300 | }; |
| 2303 | self.locals.items[index] = .{ | 2301 | self.locals.items[index] = null_sym; |
| 2304 | .st_name = 0, | | |
| 2305 | .st_info = 0, | | |
| 2306 | .st_other = 0, | | |
| 2307 | .st_shndx = 0, | | |
| 2308 | .st_value = 0, | | |
| 2309 | .st_size = 0, | | |
| 2310 | }; | | |
| 2311 | return index; | 2302 | return index; |
| 2312 | } | 2303 | } |
| 2313 | | 2304 | |