| ... | @@ -224,6 +224,17 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option | ... | @@ -224,6 +224,17 @@ pub fn openPath(allocator: Allocator, sub_path: []const u8, options: link.Option |
| 224 | .sh_addralign = 0, | 224 | .sh_addralign = 0, |
| 225 | .sh_entsize = 0, | 225 | .sh_entsize = 0, |
| 226 | }); | 226 | }); |
| | 227 | // Append null byte to string tables |
| | 228 | try self.shstrtab.buffer.append(allocator, 0); |
| | 229 | try self.strtab.buffer.append(allocator, 0); |
| | 230 | |
| | 231 | if (options.module != null and !options.use_llvm) { |
| | 232 | if (!options.strip) { |
| | 233 | self.dwarf = Dwarf.init(allocator, &self.base, options.target); |
| | 234 | } |
| | 235 | |
| | 236 | // TODO move populateMissingMetadata here renamed to zig_module.initMetadata(); |
| | 237 | } |
| 227 | | 238 | |
| 228 | try self.populateMissingMetadata(); | 239 | try self.populateMissingMetadata(); |
| 229 | | 240 | |
| ... | @@ -249,12 +260,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { | ... | @@ -249,12 +260,6 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { |
| 249 | else | 260 | else |
| 250 | elf.VER_NDX_LOCAL; | 261 | elf.VER_NDX_LOCAL; |
| 251 | | 262 | |
| 252 | const use_llvm = options.use_llvm; | | |
| 253 | var dwarf: ?Dwarf = if (!options.strip and options.module != null and !use_llvm) | | |
| 254 | Dwarf.init(gpa, &self.base, options.target) | | |
| 255 | else | | |
| 256 | null; | | |
| 257 | | | |
| 258 | self.* = .{ | 263 | self.* = .{ |
| 259 | .base = .{ | 264 | .base = .{ |
| 260 | .tag = .elf, | 265 | .tag = .elf, |
| ... | @@ -262,12 +267,11 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { | ... | @@ -262,12 +267,11 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Elf { |
| 262 | .allocator = gpa, | 267 | .allocator = gpa, |
| 263 | .file = null, | 268 | .file = null, |
| 264 | }, | 269 | }, |
| 265 | .dwarf = dwarf, | | |
| 266 | .ptr_width = ptr_width, | 270 | .ptr_width = ptr_width, |
| 267 | .page_size = page_size, | 271 | .page_size = page_size, |
| 268 | .default_sym_version = default_sym_version, | 272 | .default_sym_version = default_sym_version, |
| 269 | }; | 273 | }; |
| 270 | if (use_llvm and options.module != null) { | 274 | if (options.use_llvm and options.module != null) { |
| 271 | self.llvm_object = try LlvmObject.create(gpa, options); | 275 | self.llvm_object = try LlvmObject.create(gpa, options); |
| 272 | } | 276 | } |
| 273 | | 277 | |
| ... | @@ -734,8 +738,6 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -734,8 +738,6 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 734 | } | 738 | } |
| 735 | | 739 | |
| 736 | if (self.shstrtab_section_index == null) { | 740 | if (self.shstrtab_section_index == null) { |
| 737 | assert(self.shstrtab.buffer.items.len == 0); | | |
| 738 | try self.shstrtab.buffer.append(gpa, 0); // need a 0 at position 0 | | |
| 739 | self.shstrtab_section_index = try self.allocateNonAllocSection(.{ | 741 | self.shstrtab_section_index = try self.allocateNonAllocSection(.{ |
| 740 | .name = ".shstrtab", | 742 | .name = ".shstrtab", |
| 741 | .size = @intCast(self.shstrtab.buffer.items.len), | 743 | .size = @intCast(self.shstrtab.buffer.items.len), |
| ... | @@ -745,8 +747,6 @@ pub fn populateMissingMetadata(self: *Elf) !void { | ... | @@ -745,8 +747,6 @@ pub fn populateMissingMetadata(self: *Elf) !void { |
| 745 | } | 747 | } |
| 746 | | 748 | |
| 747 | if (self.strtab_section_index == null) { | 749 | if (self.strtab_section_index == null) { |
| 748 | assert(self.strtab.buffer.items.len == 0); | | |
| 749 | try self.strtab.buffer.append(gpa, 0); // need a 0 at position 0 | | |
| 750 | self.strtab_section_index = try self.allocateNonAllocSection(.{ | 750 | self.strtab_section_index = try self.allocateNonAllocSection(.{ |
| 751 | .name = ".strtab", | 751 | .name = ".strtab", |
| 752 | .size = @intCast(self.strtab.buffer.items.len), | 752 | .size = @intCast(self.strtab.buffer.items.len), |