| author | |
| committer | |
| log | 372b407740224ae20fad49647bbde56330b24967 |
| tree | 2af818d959da7f7dce5b7a5ab28befa0614f72c8 |
| parent | 435b74acd6384029588755ae87568d03911da5c2 |
since it's accessed by Compilation. fixes an invalid check of
bin_file==null3 files changed, 12 insertions(+), 13 deletions(-)
src/Compilation.zig+4-4| ... | ... | @@ -85,6 +85,7 @@ skip_linker_dependencies: bool, |
| 85 | 85 | no_builtin: bool, |
| 86 | 86 | function_sections: bool, |
| 87 | 87 | data_sections: bool, |
| 88 | link_eh_frame_hdr: bool, | |
| 88 | 89 | native_system_include_paths: []const []const u8, |
| 89 | 90 | /// List of symbols forced as undefined in the symbol table |
| 90 | 91 | /// thus forcing their resolution by the linker. |
| ... | ... | @@ -1509,6 +1510,7 @@ pub fn create(gpa: Allocator, options: CreateOptions) !*Compilation { |
| 1509 | 1510 | .native_system_include_paths = options.native_system_include_paths, |
| 1510 | 1511 | .wasi_emulated_libs = options.wasi_emulated_libs, |
| 1511 | 1512 | .force_undefined_symbols = options.force_undefined_symbols, |
| 1513 | .link_eh_frame_hdr = link_eh_frame_hdr, | |
| 1512 | 1514 | }; |
| 1513 | 1515 | |
| 1514 | 1516 | // Prevent some footguns by making the "any" fields of config reflect |
| ... | ... | @@ -1558,7 +1560,6 @@ pub fn create(gpa: Allocator, options: CreateOptions) !*Compilation { |
| 1558 | 1560 | .image_base = options.image_base, |
| 1559 | 1561 | .version_script = options.version_script, |
| 1560 | 1562 | .gc_sections = options.linker_gc_sections, |
| 1561 | .eh_frame_hdr = link_eh_frame_hdr, | |
| 1562 | 1563 | .emit_relocs = options.link_emit_relocs, |
| 1563 | 1564 | .soname = options.soname, |
| 1564 | 1565 | .compatibility_version = options.compatibility_version, |
| ... | ... | @@ -2457,6 +2458,7 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes |
| 2457 | 2458 | |
| 2458 | 2459 | man.hash.add(comp.skip_linker_dependencies); |
| 2459 | 2460 | man.hash.add(comp.include_compiler_rt); |
| 2461 | man.hash.add(comp.link_eh_frame_hdr); | |
| 2460 | 2462 | if (comp.config.link_libc) { |
| 2461 | 2463 | man.hash.add(comp.libc_installation != null); |
| 2462 | 2464 | const target = comp.root_mod.resolved_target.result; |
| ... | ... | @@ -2490,7 +2492,6 @@ fn addNonIncrementalStuffToCacheManifest(comp: *Compilation, man: *Cache.Manifes |
| 2490 | 2492 | switch (lf.tag) { |
| 2491 | 2493 | .elf => { |
| 2492 | 2494 | const elf = lf.cast(link.File.Elf).?; |
| 2493 | man.hash.add(elf.eh_frame_hdr); | |
| 2494 | 2495 | man.hash.add(elf.image_base); |
| 2495 | 2496 | man.hash.add(elf.emit_relocs); |
| 2496 | 2497 | man.hash.add(elf.z_nodelete); |
| ... | ... | @@ -6213,8 +6214,7 @@ fn buildOutputFromZig( |
| 6213 | 6214 | |
| 6214 | 6215 | assert(output_mode != .Exe); |
| 6215 | 6216 | |
| 6216 | const lf = comp.bin_file.?; | |
| 6217 | const unwind_tables = if (lf.cast(link.File.Elf)) |elf| elf.eh_frame_hdr else false; | |
| 6217 | const unwind_tables = comp.link_eh_frame_hdr; | |
| 6218 | 6218 | const strip = comp.compilerRtStrip(); |
| 6219 | 6219 | const optimize_mode = comp.compilerRtOptMode(); |
| 6220 | 6220 |
src/link.zig-1| ... | ... | @@ -85,7 +85,6 @@ pub const File = struct { |
| 85 | 85 | entry_addr: ?u64, |
| 86 | 86 | stack_size: ?u64, |
| 87 | 87 | image_base: ?u64, |
| 88 | eh_frame_hdr: bool, | |
| 89 | 88 | emit_relocs: bool, |
| 90 | 89 | z_nodelete: bool, |
| 91 | 90 | z_notext: bool, |
src/link/Elf.zig+8-8| ... | ... | @@ -1,6 +1,5 @@ |
| 1 | 1 | base: link.File, |
| 2 | 2 | image_base: u64, |
| 3 | eh_frame_hdr: bool, | |
| 4 | 3 | emit_relocs: bool, |
| 5 | 4 | z_nodelete: bool, |
| 6 | 5 | z_notext: bool, |
| ... | ... | @@ -306,7 +305,6 @@ pub fn createEmpty( |
| 306 | 305 | }; |
| 307 | 306 | }, |
| 308 | 307 | |
| 309 | .eh_frame_hdr = options.eh_frame_hdr, | |
| 310 | 308 | .emit_relocs = options.emit_relocs, |
| 311 | 309 | .z_nodelete = options.z_nodelete, |
| 312 | 310 | .z_notext = options.z_notext, |
| ... | ... | @@ -1726,7 +1724,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void { |
| 1726 | 1724 | try argv.append("--print-gc-sections"); |
| 1727 | 1725 | } |
| 1728 | 1726 | |
| 1729 | if (self.eh_frame_hdr) { | |
| 1727 | if (comp.link_eh_frame_hdr) { | |
| 1730 | 1728 | try argv.append("--eh-frame-hdr"); |
| 1731 | 1729 | } |
| 1732 | 1730 | |
| ... | ... | @@ -2437,7 +2435,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v |
| 2437 | 2435 | man.hash.add(self.image_base); |
| 2438 | 2436 | man.hash.add(self.base.gc_sections); |
| 2439 | 2437 | man.hash.addOptional(self.sort_section); |
| 2440 | man.hash.add(self.eh_frame_hdr); | |
| 2438 | man.hash.add(comp.link_eh_frame_hdr); | |
| 2441 | 2439 | man.hash.add(self.emit_relocs); |
| 2442 | 2440 | man.hash.add(comp.config.rdynamic); |
| 2443 | 2441 | man.hash.addListOfBytes(self.lib_dirs); |
| ... | ... | @@ -2633,7 +2631,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v |
| 2633 | 2631 | try argv.append("--print-map"); |
| 2634 | 2632 | } |
| 2635 | 2633 | |
| 2636 | if (self.eh_frame_hdr) { | |
| 2634 | if (comp.link_eh_frame_hdr) { | |
| 2637 | 2635 | try argv.append("--eh-frame-hdr"); |
| 2638 | 2636 | } |
| 2639 | 2637 | |
| ... | ... | @@ -3317,6 +3315,9 @@ pub fn deleteDeclExport( |
| 3317 | 3315 | } |
| 3318 | 3316 | |
| 3319 | 3317 | fn addLinkerDefinedSymbols(self: *Elf) !void { |
| 3318 | const comp = self.base.comp; | |
| 3319 | const gpa = comp.gpa; | |
| 3320 | ||
| 3320 | 3321 | const linker_defined_index = self.linker_defined_index orelse return; |
| 3321 | 3322 | const linker_defined = self.file(linker_defined_index).?.linker_defined; |
| 3322 | 3323 | self.dynamic_index = try linker_defined.addGlobal("_DYNAMIC", self); |
| ... | ... | @@ -3331,7 +3332,7 @@ fn addLinkerDefinedSymbols(self: *Elf) !void { |
| 3331 | 3332 | self.plt_index = try linker_defined.addGlobal("_PROCEDURE_LINKAGE_TABLE_", self); |
| 3332 | 3333 | self.end_index = try linker_defined.addGlobal("_end", self); |
| 3333 | 3334 | |
| 3334 | if (self.eh_frame_hdr) { | |
| 3335 | if (comp.link_eh_frame_hdr) { | |
| 3335 | 3336 | self.gnu_eh_frame_hdr_index = try linker_defined.addGlobal("__GNU_EH_FRAME_HDR", self); |
| 3336 | 3337 | } |
| 3337 | 3338 | |
| ... | ... | @@ -3345,7 +3346,6 @@ fn addLinkerDefinedSymbols(self: *Elf) !void { |
| 3345 | 3346 | |
| 3346 | 3347 | for (self.shdrs.items) |shdr| { |
| 3347 | 3348 | if (self.getStartStopBasename(shdr)) |name| { |
| 3348 | const gpa = self.base.comp.gpa; | |
| 3349 | 3349 | try self.start_stop_indexes.ensureUnusedCapacity(gpa, 2); |
| 3350 | 3350 | |
| 3351 | 3351 | const start = try std.fmt.allocPrintZ(gpa, "__start_{s}", .{name}); |
| ... | ... | @@ -3510,7 +3510,7 @@ fn initSyntheticSections(self: *Elf) !void { |
| 3510 | 3510 | .offset = std.math.maxInt(u64), |
| 3511 | 3511 | }); |
| 3512 | 3512 | |
| 3513 | if (self.eh_frame_hdr) { | |
| 3513 | if (comp.link_eh_frame_hdr) { | |
| 3514 | 3514 | self.eh_frame_hdr_section_index = try self.addSection(.{ |
| 3515 | 3515 | .name = ".eh_frame_hdr", |
| 3516 | 3516 | .type = elf.SHT_PROGBITS, |