| ... | @@ -585,7 +585,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -585,7 +585,7 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 585 | const ptr_size = self.ptrWidthBytes(); | 585 | const ptr_size = self.ptrWidthBytes(); |
| 586 | const target = self.base.comp.root_mod.resolved_target.result; | 586 | const target = self.base.comp.root_mod.resolved_target.result; |
| 587 | const ptr_bit_width = target.ptrBitWidth(); | 587 | const ptr_bit_width = target.ptrBitWidth(); |
| 588 | const zig_object = self.zigObjectPtr().?; | 588 | const zo = self.zigObjectPtr().?; |
| 589 | | 589 | |
| 590 | const fillSection = struct { | 590 | const fillSection = struct { |
| 591 | fn fillSection(elf_file: *Elf, shdr: *elf.Elf64_Shdr, size: u64, phndx: ?u16) !void { | 591 | fn fillSection(elf_file: *Elf, shdr: *elf.Elf64_Shdr, size: u64, phndx: ?u16) !void { |
| ... | @@ -766,7 +766,27 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -766,7 +766,27 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 766 | try self.last_atom_and_free_list_table.putNoClobber(gpa, self.zig_bss_section_index.?, .{}); | 766 | try self.last_atom_and_free_list_table.putNoClobber(gpa, self.zig_bss_section_index.?, .{}); |
| 767 | } | 767 | } |
| 768 | | 768 | |
| 769 | if (zig_object.dwarf) |*dwarf| { | 769 | if (zo.dwarf) |*dwarf| { |
| | 770 | const addSectionSymbol = struct { |
| | 771 | fn addSectionSymbol( |
| | 772 | zig_object: *ZigObject, |
| | 773 | alloc: Allocator, |
| | 774 | name: [:0]const u8, |
| | 775 | alignment: Atom.Alignment, |
| | 776 | shndx: u32, |
| | 777 | ) !Symbol.Index { |
| | 778 | const name_off = try zig_object.addString(alloc, name); |
| | 779 | const index = try zig_object.newSymbolWithAtom(alloc, name_off); |
| | 780 | const sym = zig_object.symbol(index); |
| | 781 | const esym = &zig_object.symtab.items(.elf_sym)[sym.esym_index]; |
| | 782 | esym.st_info |= elf.STT_SECTION; |
| | 783 | const atom_ptr = zig_object.atom(sym.ref.index).?; |
| | 784 | atom_ptr.alignment = alignment; |
| | 785 | atom_ptr.output_section_index = shndx; |
| | 786 | return index; |
| | 787 | } |
| | 788 | }.addSectionSymbol; |
| | 789 | |
| 770 | if (self.debug_str_section_index == null) { | 790 | if (self.debug_str_section_index == null) { |
| 771 | self.debug_str_section_index = try self.addSection(.{ | 791 | self.debug_str_section_index = try self.addSection(.{ |
| 772 | .name = try self.insertShString(".debug_str"), | 792 | .name = try self.insertShString(".debug_str"), |
| ... | @@ -775,7 +795,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -775,7 +795,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 775 | .type = elf.SHT_PROGBITS, | 795 | .type = elf.SHT_PROGBITS, |
| 776 | .addralign = 1, | 796 | .addralign = 1, |
| 777 | }); | 797 | }); |
| 778 | zig_object.debug_str_section_dirty = true; | 798 | zo.debug_str_section_dirty = true; |
| | 799 | zo.debug_str_index = try addSectionSymbol(zo, gpa, ".debug_str", .@"1", self.debug_str_section_index.?); |
| 779 | try self.output_sections.putNoClobber(gpa, self.debug_str_section_index.?, .{}); | 800 | try self.output_sections.putNoClobber(gpa, self.debug_str_section_index.?, .{}); |
| 780 | } | 801 | } |
| 781 | | 802 | |
| ... | @@ -785,7 +806,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -785,7 +806,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 785 | .type = elf.SHT_PROGBITS, | 806 | .type = elf.SHT_PROGBITS, |
| 786 | .addralign = 1, | 807 | .addralign = 1, |
| 787 | }); | 808 | }); |
| 788 | zig_object.debug_info_section_dirty = true; | 809 | zo.debug_info_section_dirty = true; |
| | 810 | zo.debug_info_index = try addSectionSymbol(zo, gpa, ".debug_info", .@"1", self.debug_info_section_index.?); |
| 789 | try self.output_sections.putNoClobber(gpa, self.debug_info_section_index.?, .{}); | 811 | try self.output_sections.putNoClobber(gpa, self.debug_info_section_index.?, .{}); |
| 790 | } | 812 | } |
| 791 | | 813 | |
| ... | @@ -795,7 +817,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -795,7 +817,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 795 | .type = elf.SHT_PROGBITS, | 817 | .type = elf.SHT_PROGBITS, |
| 796 | .addralign = 1, | 818 | .addralign = 1, |
| 797 | }); | 819 | }); |
| 798 | zig_object.debug_abbrev_section_dirty = true; | 820 | zo.debug_abbrev_section_dirty = true; |
| | 821 | zo.debug_abbrev_index = try addSectionSymbol(zo, gpa, ".debug_abbrev", .@"1", self.debug_abbrev_section_index.?); |
| 799 | try self.output_sections.putNoClobber(gpa, self.debug_abbrev_section_index.?, .{}); | 822 | try self.output_sections.putNoClobber(gpa, self.debug_abbrev_section_index.?, .{}); |
| 800 | } | 823 | } |
| 801 | | 824 | |
| ... | @@ -805,7 +828,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -805,7 +828,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 805 | .type = elf.SHT_PROGBITS, | 828 | .type = elf.SHT_PROGBITS, |
| 806 | .addralign = 16, | 829 | .addralign = 16, |
| 807 | }); | 830 | }); |
| 808 | zig_object.debug_aranges_section_dirty = true; | 831 | zo.debug_aranges_section_dirty = true; |
| | 832 | zo.debug_aranges_index = try addSectionSymbol(zo, gpa, ".debug_aranges", .@"16", self.debug_aranges_section_index.?); |
| 809 | try self.output_sections.putNoClobber(gpa, self.debug_aranges_section_index.?, .{}); | 833 | try self.output_sections.putNoClobber(gpa, self.debug_aranges_section_index.?, .{}); |
| 810 | } | 834 | } |
| 811 | | 835 | |
| ... | @@ -815,7 +839,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -815,7 +839,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 815 | .type = elf.SHT_PROGBITS, | 839 | .type = elf.SHT_PROGBITS, |
| 816 | .addralign = 1, | 840 | .addralign = 1, |
| 817 | }); | 841 | }); |
| 818 | zig_object.debug_line_section_dirty = true; | 842 | zo.debug_line_section_dirty = true; |
| | 843 | zo.debug_line_index = try addSectionSymbol(zo, gpa, ".debug_line", .@"1", self.debug_line_section_index.?); |
| 819 | try self.output_sections.putNoClobber(gpa, self.debug_line_section_index.?, .{}); | 844 | try self.output_sections.putNoClobber(gpa, self.debug_line_section_index.?, .{}); |
| 820 | } | 845 | } |
| 821 | | 846 | |
| ... | @@ -827,7 +852,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -827,7 +852,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 827 | .type = elf.SHT_PROGBITS, | 852 | .type = elf.SHT_PROGBITS, |
| 828 | .addralign = 1, | 853 | .addralign = 1, |
| 829 | }); | 854 | }); |
| 830 | zig_object.debug_line_str_section_dirty = true; | 855 | zo.debug_line_str_section_dirty = true; |
| | 856 | zo.debug_line_str_index = try addSectionSymbol(zo, gpa, ".debug_line_str", .@"1", self.debug_line_str_section_index.?); |
| 831 | try self.output_sections.putNoClobber(gpa, self.debug_line_str_section_index.?, .{}); | 857 | try self.output_sections.putNoClobber(gpa, self.debug_line_str_section_index.?, .{}); |
| 832 | } | 858 | } |
| 833 | | 859 | |
| ... | @@ -837,7 +863,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -837,7 +863,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 837 | .type = elf.SHT_PROGBITS, | 863 | .type = elf.SHT_PROGBITS, |
| 838 | .addralign = 1, | 864 | .addralign = 1, |
| 839 | }); | 865 | }); |
| 840 | zig_object.debug_loclists_section_dirty = true; | 866 | zo.debug_loclists_section_dirty = true; |
| | 867 | zo.debug_loclists_index = try addSectionSymbol(zo, gpa, ".debug_loclists", .@"1", self.debug_loclists_section_index.?); |
| 841 | try self.output_sections.putNoClobber(gpa, self.debug_loclists_section_index.?, .{}); | 868 | try self.output_sections.putNoClobber(gpa, self.debug_loclists_section_index.?, .{}); |
| 842 | } | 869 | } |
| 843 | | 870 | |
| ... | @@ -847,7 +874,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { | ... | @@ -847,7 +874,8 @@ pub fn initMetadata(self: *Elf, options: InitMetadataOptions) !void { |
| 847 | .type = elf.SHT_PROGBITS, | 874 | .type = elf.SHT_PROGBITS, |
| 848 | .addralign = 1, | 875 | .addralign = 1, |
| 849 | }); | 876 | }); |
| 850 | zig_object.debug_rnglists_section_dirty = true; | 877 | zo.debug_rnglists_section_dirty = true; |
| | 878 | zo.debug_rnglists_index = try addSectionSymbol(zo, gpa, ".debug_rnglists", .@"1", self.debug_rnglists_section_index.?); |
| 851 | try self.output_sections.putNoClobber(gpa, self.debug_rnglists_section_index.?, .{}); | 879 | try self.output_sections.putNoClobber(gpa, self.debug_rnglists_section_index.?, .{}); |
| 852 | } | 880 | } |
| 853 | | 881 | |