authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-10-08 15:10:38+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-10-09 12:38:53-07:00
loge9d819a29e928d1f9069e12609806dacb558bb3f
treefb61219ed5e8efecd5da7704c40a010a8f4ef3ed
parente448fb960137e5aa83a1e7c2e6cbbf688f4fce05

elf: clean up how we create un-allocated sections


3 files changed, 1 insertions(+), 44 deletions(-)

src/link/Elf.zig+1-24
...@@ -1801,7 +1801,6 @@ pub fn initOutputSection(self: *Elf, args: struct {...@@ -1801,7 +1801,6 @@ pub fn initOutputSection(self: *Elf, args: struct {
1801 .type = @"type",1801 .type = @"type",
1802 .flags = flags,1802 .flags = flags,
1803 .name = try self.insertShString(name),1803 .name = try self.insertShString(name),
1804 .offset = std.math.maxInt(u64),
1805 });1804 });
1806 return out_shndx;1805 return out_shndx;
1807}1806}
...@@ -2867,7 +2866,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2867,7 +2866,6 @@ fn initSyntheticSections(self: *Elf) !void {
2867 elf.SHT_PROGBITS,2866 elf.SHT_PROGBITS,
2868 .flags = elf.SHF_ALLOC,2867 .flags = elf.SHF_ALLOC,
2869 .addralign = ptr_size,2868 .addralign = ptr_size,
2870 .offset = std.math.maxInt(u64),
2871 });2869 });
2872 }2870 }
2873 if (comp.link_eh_frame_hdr and self.eh_frame_hdr_section_index == null) {2871 if (comp.link_eh_frame_hdr and self.eh_frame_hdr_section_index == null) {
...@@ -2876,7 +2874,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2876,7 +2874,6 @@ fn initSyntheticSections(self: *Elf) !void {
2876 .type = elf.SHT_PROGBITS,2874 .type = elf.SHT_PROGBITS,
2877 .flags = elf.SHF_ALLOC,2875 .flags = elf.SHF_ALLOC,
2878 .addralign = 4,2876 .addralign = 4,
2879 .offset = std.math.maxInt(u64),
2880 });2877 });
2881 }2878 }
2882 }2879 }
...@@ -2887,7 +2884,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2887,7 +2884,6 @@ fn initSyntheticSections(self: *Elf) !void {
2887 .type = elf.SHT_PROGBITS,2884 .type = elf.SHT_PROGBITS,
2888 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,2885 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
2889 .addralign = ptr_size,2886 .addralign = ptr_size,
2890 .offset = std.math.maxInt(u64),
2891 });2887 });
2892 }2888 }
28932889
...@@ -2897,7 +2893,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2897,7 +2893,6 @@ fn initSyntheticSections(self: *Elf) !void {
2897 .type = elf.SHT_PROGBITS,2893 .type = elf.SHT_PROGBITS,
2898 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,2894 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
2899 .addralign = @alignOf(u64),2895 .addralign = @alignOf(u64),
2900 .offset = std.math.maxInt(u64),
2901 });2896 });
2902 }2897 }
29032898
...@@ -2919,7 +2914,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2919,7 +2914,6 @@ fn initSyntheticSections(self: *Elf) !void {
2919 .flags = elf.SHF_ALLOC,2914 .flags = elf.SHF_ALLOC,
2920 .addralign = @alignOf(elf.Elf64_Rela),2915 .addralign = @alignOf(elf.Elf64_Rela),
2921 .entsize = @sizeOf(elf.Elf64_Rela),2916 .entsize = @sizeOf(elf.Elf64_Rela),
2922 .offset = std.math.maxInt(u64),
2923 });2917 });
2924 }2918 }
29252919
...@@ -2930,7 +2924,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2930,7 +2924,6 @@ fn initSyntheticSections(self: *Elf) !void {
2930 .type = elf.SHT_PROGBITS,2924 .type = elf.SHT_PROGBITS,
2931 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,2925 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,
2932 .addralign = 16,2926 .addralign = 16,
2933 .offset = std.math.maxInt(u64),
2934 });2927 });
2935 }2928 }
2936 if (self.rela_plt_section_index == null) {2929 if (self.rela_plt_section_index == null) {
...@@ -2940,7 +2933,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2940,7 +2933,6 @@ fn initSyntheticSections(self: *Elf) !void {
2940 .flags = elf.SHF_ALLOC,2933 .flags = elf.SHF_ALLOC,
2941 .addralign = @alignOf(elf.Elf64_Rela),2934 .addralign = @alignOf(elf.Elf64_Rela),
2942 .entsize = @sizeOf(elf.Elf64_Rela),2935 .entsize = @sizeOf(elf.Elf64_Rela),
2943 .offset = std.math.maxInt(u64),
2944 });2936 });
2945 }2937 }
2946 }2938 }
...@@ -2951,7 +2943,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2951,7 +2943,6 @@ fn initSyntheticSections(self: *Elf) !void {
2951 .type = elf.SHT_PROGBITS,2943 .type = elf.SHT_PROGBITS,
2952 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,2944 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,
2953 .addralign = 16,2945 .addralign = 16,
2954 .offset = std.math.maxInt(u64),
2955 });2946 });
2956 }2947 }
29572948
...@@ -2960,7 +2951,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2960,7 +2951,6 @@ fn initSyntheticSections(self: *Elf) !void {
2960 .name = try self.insertShString(".copyrel"),2951 .name = try self.insertShString(".copyrel"),
2961 .type = elf.SHT_NOBITS,2952 .type = elf.SHT_NOBITS,
2962 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,2953 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
2963 .offset = std.math.maxInt(u64),
2964 });2954 });
2965 }2955 }
29662956
...@@ -2979,7 +2969,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2979,7 +2969,6 @@ fn initSyntheticSections(self: *Elf) !void {
2979 .type = elf.SHT_PROGBITS,2969 .type = elf.SHT_PROGBITS,
2980 .flags = elf.SHF_ALLOC,2970 .flags = elf.SHF_ALLOC,
2981 .addralign = 1,2971 .addralign = 1,
2982 .offset = std.math.maxInt(u64),
2983 });2972 });
2984 }2973 }
29852974
...@@ -2991,7 +2980,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -2991,7 +2980,6 @@ fn initSyntheticSections(self: *Elf) !void {
2991 .type = elf.SHT_STRTAB,2980 .type = elf.SHT_STRTAB,
2992 .entsize = 1,2981 .entsize = 1,
2993 .addralign = 1,2982 .addralign = 1,
2994 .offset = std.math.maxInt(u64),
2995 });2983 });
2996 }2984 }
2997 if (self.dynamic_section_index == null) {2985 if (self.dynamic_section_index == null) {
...@@ -3001,7 +2989,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -3001,7 +2989,6 @@ fn initSyntheticSections(self: *Elf) !void {
3001 .type = elf.SHT_DYNAMIC,2989 .type = elf.SHT_DYNAMIC,
3002 .entsize = @sizeOf(elf.Elf64_Dyn),2990 .entsize = @sizeOf(elf.Elf64_Dyn),
3003 .addralign = @alignOf(elf.Elf64_Dyn),2991 .addralign = @alignOf(elf.Elf64_Dyn),
3004 .offset = std.math.maxInt(u64),
3005 });2992 });
3006 }2993 }
3007 if (self.dynsymtab_section_index == null) {2994 if (self.dynsymtab_section_index == null) {
...@@ -3012,7 +2999,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -3012,7 +2999,6 @@ fn initSyntheticSections(self: *Elf) !void {
3012 .addralign = @alignOf(elf.Elf64_Sym),2999 .addralign = @alignOf(elf.Elf64_Sym),
3013 .entsize = @sizeOf(elf.Elf64_Sym),3000 .entsize = @sizeOf(elf.Elf64_Sym),
3014 .info = 1,3001 .info = 1,
3015 .offset = std.math.maxInt(u64),
3016 });3002 });
3017 }3003 }
3018 if (self.hash_section_index == null) {3004 if (self.hash_section_index == null) {
...@@ -3022,7 +3008,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -3022,7 +3008,6 @@ fn initSyntheticSections(self: *Elf) !void {
3022 .type = elf.SHT_HASH,3008 .type = elf.SHT_HASH,
3023 .addralign = 4,3009 .addralign = 4,
3024 .entsize = 4,3010 .entsize = 4,
3025 .offset = std.math.maxInt(u64),
3026 });3011 });
3027 }3012 }
3028 if (self.gnu_hash_section_index == null) {3013 if (self.gnu_hash_section_index == null) {
...@@ -3031,7 +3016,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -3031,7 +3016,6 @@ fn initSyntheticSections(self: *Elf) !void {
3031 .flags = elf.SHF_ALLOC,3016 .flags = elf.SHF_ALLOC,
3032 .type = elf.SHT_GNU_HASH,3017 .type = elf.SHT_GNU_HASH,
3033 .addralign = 8,3018 .addralign = 8,
3034 .offset = std.math.maxInt(u64),
3035 });3019 });
3036 }3020 }
30373021
...@@ -3047,7 +3031,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -3047,7 +3031,6 @@ fn initSyntheticSections(self: *Elf) !void {
3047 .type = elf.SHT_GNU_VERSYM,3031 .type = elf.SHT_GNU_VERSYM,
3048 .addralign = @alignOf(elf.Elf64_Versym),3032 .addralign = @alignOf(elf.Elf64_Versym),
3049 .entsize = @sizeOf(elf.Elf64_Versym),3033 .entsize = @sizeOf(elf.Elf64_Versym),
3050 .offset = std.math.maxInt(u64),
3051 });3034 });
3052 }3035 }
3053 if (self.verneed_section_index == null) {3036 if (self.verneed_section_index == null) {
...@@ -3056,7 +3039,6 @@ fn initSyntheticSections(self: *Elf) !void {...@@ -3056,7 +3039,6 @@ fn initSyntheticSections(self: *Elf) !void {
3056 .flags = elf.SHF_ALLOC,3039 .flags = elf.SHF_ALLOC,
3057 .type = elf.SHT_GNU_VERNEED,3040 .type = elf.SHT_GNU_VERNEED,
3058 .addralign = @alignOf(elf.Elf64_Verneed),3041 .addralign = @alignOf(elf.Elf64_Verneed),
3059 .offset = std.math.maxInt(u64),
3060 });3042 });
3061 }3043 }
3062 }3044 }
...@@ -3077,7 +3059,6 @@ pub fn initSymtab(self: *Elf) !void {...@@ -3077,7 +3059,6 @@ pub fn initSymtab(self: *Elf) !void {
3077 .type = elf.SHT_SYMTAB,3059 .type = elf.SHT_SYMTAB,
3078 .addralign = if (small_ptr) @alignOf(elf.Elf32_Sym) else @alignOf(elf.Elf64_Sym),3060 .addralign = if (small_ptr) @alignOf(elf.Elf32_Sym) else @alignOf(elf.Elf64_Sym),
3079 .entsize = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym),3061 .entsize = if (small_ptr) @sizeOf(elf.Elf32_Sym) else @sizeOf(elf.Elf64_Sym),
3080 .offset = std.math.maxInt(u64),
3081 });3062 });
3082 }3063 }
3083 if (self.strtab_section_index == null) {3064 if (self.strtab_section_index == null) {
...@@ -3086,7 +3067,6 @@ pub fn initSymtab(self: *Elf) !void {...@@ -3086,7 +3067,6 @@ pub fn initSymtab(self: *Elf) !void {
3086 .type = elf.SHT_STRTAB,3067 .type = elf.SHT_STRTAB,
3087 .entsize = 1,3068 .entsize = 1,
3088 .addralign = 1,3069 .addralign = 1,
3089 .offset = std.math.maxInt(u64),
3090 });3070 });
3091 }3071 }
3092}3072}
...@@ -3098,7 +3078,6 @@ pub fn initShStrtab(self: *Elf) !void {...@@ -3098,7 +3078,6 @@ pub fn initShStrtab(self: *Elf) !void {
3098 .type = elf.SHT_STRTAB,3078 .type = elf.SHT_STRTAB,
3099 .entsize = 1,3079 .entsize = 1,
3100 .addralign = 1,3080 .addralign = 1,
3101 .offset = std.math.maxInt(u64),
3102 });3081 });
3103 }3082 }
3104}3083}
...@@ -4760,7 +4739,6 @@ pub fn addRelaShdr(self: *Elf, name: u32, shndx: u32) !u32 {...@@ -4760,7 +4739,6 @@ pub fn addRelaShdr(self: *Elf, name: u32, shndx: u32) !u32 {
4760 .entsize = entsize,4739 .entsize = entsize,
4761 .info = shndx,4740 .info = shndx,
4762 .addralign = addralign,4741 .addralign = addralign,
4763 .offset = std.math.maxInt(u64),
4764 });4742 });
4765}4743}
47664744
...@@ -4772,7 +4750,6 @@ pub const AddSectionOpts = struct {...@@ -4772,7 +4750,6 @@ pub const AddSectionOpts = struct {
4772 info: u32 = 0,4750 info: u32 = 0,
4773 addralign: u64 = 0,4751 addralign: u64 = 0,
4774 entsize: u64 = 0,4752 entsize: u64 = 0,
4775 offset: u64 = 0,
4776};4753};
47774754
4778pub fn addSection(self: *Elf, opts: AddSectionOpts) !u32 {4755pub fn addSection(self: *Elf, opts: AddSectionOpts) !u32 {
...@@ -4784,7 +4761,7 @@ pub fn addSection(self: *Elf, opts: AddSectionOpts) !u32 {...@@ -4784,7 +4761,7 @@ pub fn addSection(self: *Elf, opts: AddSectionOpts) !u32 {
4784 .sh_type = opts.type,4761 .sh_type = opts.type,
4785 .sh_flags = opts.flags,4762 .sh_flags = opts.flags,
4786 .sh_addr = 0,4763 .sh_addr = 0,
4787 .sh_offset = opts.offset,4764 .sh_offset = 0,
4788 .sh_size = 0,4765 .sh_size = 0,
4789 .sh_link = opts.link,4766 .sh_link = opts.link,
4790 .sh_info = opts.info,4767 .sh_info = opts.info,
src/link/Elf/ZigObject.zig-18
...@@ -130,7 +130,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -130,7 +130,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
130 .entsize = 1,130 .entsize = 1,
131 .type = elf.SHT_PROGBITS,131 .type = elf.SHT_PROGBITS,
132 .addralign = 1,132 .addralign = 1,
133 .offset = std.math.maxInt(u64),
134 });133 });
135 self.debug_str_section_dirty = true;134 self.debug_str_section_dirty = true;
136 self.debug_str_index = try addSectionSymbolWithAtom(self, gpa, ".debug_str", .@"1", osec);135 self.debug_str_index = try addSectionSymbolWithAtom(self, gpa, ".debug_str", .@"1", osec);
...@@ -141,7 +140,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -141,7 +140,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
141 .name = try elf_file.insertShString(".debug_info"),140 .name = try elf_file.insertShString(".debug_info"),
142 .type = elf.SHT_PROGBITS,141 .type = elf.SHT_PROGBITS,
143 .addralign = 1,142 .addralign = 1,
144 .offset = std.math.maxInt(u64),
145 });143 });
146 self.debug_info_section_dirty = true;144 self.debug_info_section_dirty = true;
147 self.debug_info_index = try addSectionSymbolWithAtom(self, gpa, ".debug_info", .@"1", osec);145 self.debug_info_index = try addSectionSymbolWithAtom(self, gpa, ".debug_info", .@"1", osec);
...@@ -152,7 +150,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -152,7 +150,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
152 .name = try elf_file.insertShString(".debug_abbrev"),150 .name = try elf_file.insertShString(".debug_abbrev"),
153 .type = elf.SHT_PROGBITS,151 .type = elf.SHT_PROGBITS,
154 .addralign = 1,152 .addralign = 1,
155 .offset = std.math.maxInt(u64),
156 });153 });
157 self.debug_abbrev_section_dirty = true;154 self.debug_abbrev_section_dirty = true;
158 self.debug_abbrev_index = try addSectionSymbolWithAtom(self, gpa, ".debug_abbrev", .@"1", osec);155 self.debug_abbrev_index = try addSectionSymbolWithAtom(self, gpa, ".debug_abbrev", .@"1", osec);
...@@ -163,7 +160,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -163,7 +160,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
163 .name = try elf_file.insertShString(".debug_aranges"),160 .name = try elf_file.insertShString(".debug_aranges"),
164 .type = elf.SHT_PROGBITS,161 .type = elf.SHT_PROGBITS,
165 .addralign = 16,162 .addralign = 16,
166 .offset = std.math.maxInt(u64),
167 });163 });
168 self.debug_aranges_section_dirty = true;164 self.debug_aranges_section_dirty = true;
169 self.debug_aranges_index = try addSectionSymbolWithAtom(self, gpa, ".debug_aranges", .@"16", osec);165 self.debug_aranges_index = try addSectionSymbolWithAtom(self, gpa, ".debug_aranges", .@"16", osec);
...@@ -174,7 +170,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -174,7 +170,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
174 .name = try elf_file.insertShString(".debug_line"),170 .name = try elf_file.insertShString(".debug_line"),
175 .type = elf.SHT_PROGBITS,171 .type = elf.SHT_PROGBITS,
176 .addralign = 1,172 .addralign = 1,
177 .offset = std.math.maxInt(u64),
178 });173 });
179 self.debug_line_section_dirty = true;174 self.debug_line_section_dirty = true;
180 self.debug_line_index = try addSectionSymbolWithAtom(self, gpa, ".debug_line", .@"1", osec);175 self.debug_line_index = try addSectionSymbolWithAtom(self, gpa, ".debug_line", .@"1", osec);
...@@ -187,7 +182,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -187,7 +182,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
187 .entsize = 1,182 .entsize = 1,
188 .type = elf.SHT_PROGBITS,183 .type = elf.SHT_PROGBITS,
189 .addralign = 1,184 .addralign = 1,
190 .offset = std.math.maxInt(u64),
191 });185 });
192 self.debug_line_str_section_dirty = true;186 self.debug_line_str_section_dirty = true;
193 self.debug_line_str_index = try addSectionSymbolWithAtom(self, gpa, ".debug_line_str", .@"1", osec);187 self.debug_line_str_index = try addSectionSymbolWithAtom(self, gpa, ".debug_line_str", .@"1", osec);
...@@ -198,7 +192,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -198,7 +192,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
198 .name = try elf_file.insertShString(".debug_loclists"),192 .name = try elf_file.insertShString(".debug_loclists"),
199 .type = elf.SHT_PROGBITS,193 .type = elf.SHT_PROGBITS,
200 .addralign = 1,194 .addralign = 1,
201 .offset = std.math.maxInt(u64),
202 });195 });
203 self.debug_loclists_section_dirty = true;196 self.debug_loclists_section_dirty = true;
204 self.debug_loclists_index = try addSectionSymbolWithAtom(self, gpa, ".debug_loclists", .@"1", osec);197 self.debug_loclists_index = try addSectionSymbolWithAtom(self, gpa, ".debug_loclists", .@"1", osec);
...@@ -209,7 +202,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -209,7 +202,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
209 .name = try elf_file.insertShString(".debug_rnglists"),202 .name = try elf_file.insertShString(".debug_rnglists"),
210 .type = elf.SHT_PROGBITS,203 .type = elf.SHT_PROGBITS,
211 .addralign = 1,204 .addralign = 1,
212 .offset = std.math.maxInt(u64),
213 });205 });
214 self.debug_rnglists_section_dirty = true;206 self.debug_rnglists_section_dirty = true;
215 self.debug_rnglists_index = try addSectionSymbolWithAtom(self, gpa, ".debug_rnglists", .@"1", osec);207 self.debug_rnglists_index = try addSectionSymbolWithAtom(self, gpa, ".debug_rnglists", .@"1", osec);
...@@ -224,7 +216,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {...@@ -224,7 +216,6 @@ pub fn init(self: *ZigObject, elf_file: *Elf, options: InitOptions) !void {
224 elf.SHT_PROGBITS,216 elf.SHT_PROGBITS,
225 .flags = elf.SHF_ALLOC,217 .flags = elf.SHF_ALLOC,
226 .addralign = ptr_size,218 .addralign = ptr_size,
227 .offset = std.math.maxInt(u64),
228 });219 });
229 self.eh_frame_section_dirty = true;220 self.eh_frame_section_dirty = true;
230 self.eh_frame_index = try addSectionSymbolWithAtom(self, gpa, ".eh_frame", Atom.Alignment.fromNonzeroByteUnits(ptr_size), osec);221 self.eh_frame_index = try addSectionSymbolWithAtom(self, gpa, ".eh_frame", Atom.Alignment.fromNonzeroByteUnits(ptr_size), osec);
...@@ -1026,7 +1017,6 @@ pub fn lowerUav(...@@ -1026,7 +1017,6 @@ pub fn lowerUav(
1026 .type = elf.SHT_PROGBITS,1017 .type = elf.SHT_PROGBITS,
1027 .addralign = 1,1018 .addralign = 1,
1028 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,1019 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
1029 .offset = std.math.maxInt(u64),
1030 });1020 });
1031 self.data_relro_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data.rel.ro"), osec);1021 self.data_relro_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data.rel.ro"), osec);
1032 break :osec osec;1022 break :osec osec;
...@@ -1166,7 +1156,6 @@ fn getNavShdrIndex(...@@ -1166,7 +1156,6 @@ fn getNavShdrIndex(
1166 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,1156 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,
1167 .name = try elf_file.insertShString(".text"),1157 .name = try elf_file.insertShString(".text"),
1168 .addralign = 1,1158 .addralign = 1,
1169 .offset = std.math.maxInt(u64),
1170 });1159 });
1171 self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec);1160 self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec);
1172 return osec;1161 return osec;
...@@ -1200,7 +1189,6 @@ fn getNavShdrIndex(...@@ -1200,7 +1189,6 @@ fn getNavShdrIndex(
1200 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,1189 .flags = elf.SHF_ALLOC | elf.SHF_WRITE | elf.SHF_TLS,
1201 .name = try elf_file.insertShString(".tdata"),1190 .name = try elf_file.insertShString(".tdata"),
1202 .addralign = 1,1191 .addralign = 1,
1203 .offset = std.math.maxInt(u64),
1204 });1192 });
1205 self.tdata_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".tdata"), osec);1193 self.tdata_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".tdata"), osec);
1206 return osec;1194 return osec;
...@@ -1213,7 +1201,6 @@ fn getNavShdrIndex(...@@ -1213,7 +1201,6 @@ fn getNavShdrIndex(
1213 .type = elf.SHT_PROGBITS,1201 .type = elf.SHT_PROGBITS,
1214 .addralign = 1,1202 .addralign = 1,
1215 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,1203 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
1216 .offset = std.math.maxInt(u64),
1217 });1204 });
1218 self.data_relro_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data.rel.ro"), osec);1205 self.data_relro_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data.rel.ro"), osec);
1219 return osec;1206 return osec;
...@@ -1228,7 +1215,6 @@ fn getNavShdrIndex(...@@ -1228,7 +1215,6 @@ fn getNavShdrIndex(
1228 .type = elf.SHT_PROGBITS,1215 .type = elf.SHT_PROGBITS,
1229 .addralign = ptr_size,1216 .addralign = ptr_size,
1230 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,1217 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
1231 .offset = std.math.maxInt(u64),
1232 });1218 });
1233 self.data_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data"), osec);1219 self.data_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data"), osec);
1234 return osec;1220 return osec;
...@@ -1268,7 +1254,6 @@ fn getNavShdrIndex(...@@ -1268,7 +1254,6 @@ fn getNavShdrIndex(
1268 .type = elf.SHT_PROGBITS,1254 .type = elf.SHT_PROGBITS,
1269 .addralign = ptr_size,1255 .addralign = ptr_size,
1270 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,1256 .flags = elf.SHF_ALLOC | elf.SHF_WRITE,
1271 .offset = std.math.maxInt(u64),
1272 });1257 });
1273 self.data_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data"), osec);1258 self.data_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".data"), osec);
1274 return osec;1259 return osec;
...@@ -1521,7 +1506,6 @@ pub fn updateFunc(...@@ -1521,7 +1506,6 @@ pub fn updateFunc(
1521 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,1506 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,
1522 .type = elf.SHT_PROGBITS,1507 .type = elf.SHT_PROGBITS,
1523 .addralign = 1,1508 .addralign = 1,
1524 .offset = std.math.maxInt(u64),
1525 });1509 });
1526 self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec);1510 self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec);
1527 break :osec osec;1511 break :osec osec;
...@@ -1697,7 +1681,6 @@ fn updateLazySymbol(...@@ -1697,7 +1681,6 @@ fn updateLazySymbol(
1697 .type = elf.SHT_PROGBITS,1681 .type = elf.SHT_PROGBITS,
1698 .addralign = 1,1682 .addralign = 1,
1699 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,1683 .flags = elf.SHF_ALLOC | elf.SHF_EXECINSTR,
1700 .offset = std.math.maxInt(u64),
1701 });1684 });
1702 self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec);1685 self.text_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".text"), osec);
1703 break :osec osec;1686 break :osec osec;
...@@ -1710,7 +1693,6 @@ fn updateLazySymbol(...@@ -1710,7 +1693,6 @@ fn updateLazySymbol(
1710 .type = elf.SHT_PROGBITS,1693 .type = elf.SHT_PROGBITS,
1711 .addralign = 1,1694 .addralign = 1,
1712 .flags = elf.SHF_ALLOC,1695 .flags = elf.SHF_ALLOC,
1713 .offset = std.math.maxInt(u64),
1714 });1696 });
1715 self.rodata_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".rodata"), osec);1697 self.rodata_index = try self.addSectionSymbol(gpa, try self.addString(gpa, ".rodata"), osec);
1716 break :osec osec;1698 break :osec osec;
src/link/Elf/relocatable.zig-2
...@@ -295,7 +295,6 @@ fn initSections(elf_file: *Elf) !void {...@@ -295,7 +295,6 @@ fn initSections(elf_file: *Elf) !void {
295 elf.SHT_PROGBITS,295 elf.SHT_PROGBITS,
296 .flags = elf.SHF_ALLOC,296 .flags = elf.SHF_ALLOC,
297 .addralign = elf_file.ptrWidthBytes(),297 .addralign = elf_file.ptrWidthBytes(),
298 .offset = std.math.maxInt(u64),
299 });298 });
300 }299 }
301 elf_file.eh_frame_rela_section_index = elf_file.sectionByName(".rela.eh_frame") orelse300 elf_file.eh_frame_rela_section_index = elf_file.sectionByName(".rela.eh_frame") orelse
...@@ -324,7 +323,6 @@ fn initComdatGroups(elf_file: *Elf) !void {...@@ -324,7 +323,6 @@ fn initComdatGroups(elf_file: *Elf) !void {
324 .type = elf.SHT_GROUP,323 .type = elf.SHT_GROUP,
325 .entsize = @sizeOf(u32),324 .entsize = @sizeOf(u32),
326 .addralign = @alignOf(u32),325 .addralign = @alignOf(u32),
327 .offset = std.math.maxInt(u64),
328 }),326 }),
329 .cg_ref = .{ .index = @intCast(cg_index), .file = index },327 .cg_ref = .{ .index = @intCast(cg_index), .file = index },
330 };328 };