| author | |
| committer | |
| log | 5c84f9dad456c54dcb1937d13837fabefa507135 |
| tree | 867b812282eba323edecd1d0850a6b02d44ea0e1 |
| parent | bf0afaa876391571f6072650bf450356b26c928d |
5 files changed, 18 insertions(+), 0 deletions(-)
lib/std/build.zig+4| ... | ... | @@ -1239,6 +1239,7 @@ pub const LibExeObjStep = struct { |
| 1239 | 1239 | /// Create a .eh_frame_hdr section and a PT_GNU_EH_FRAME segment in the ELF |
| 1240 | 1240 | /// file. |
| 1241 | 1241 | link_eh_frame_hdr: bool = false, |
| 1242 | link_emit_relocs: bool = false, | |
| 1242 | 1243 | |
| 1243 | 1244 | /// Place every function in its own section so that unused ones may be |
| 1244 | 1245 | /// safely garbage-collected during the linking phase. |
| ... | ... | @@ -2075,6 +2076,9 @@ pub const LibExeObjStep = struct { |
| 2075 | 2076 | if (self.link_eh_frame_hdr) { |
| 2076 | 2077 | try zig_args.append("--eh-frame-hdr"); |
| 2077 | 2078 | } |
| 2079 | if(self.link_emit_relocs){ | |
| 2080 | try zig_args.append("-emit-relocs"); | |
| 2081 | } | |
| 2078 | 2082 | if (self.link_function_sections) { |
| 2079 | 2083 | try zig_args.append("-ffunction-sections"); |
| 2080 | 2084 | } |
src/Compilation.zig+3| ... | ... | @@ -352,6 +352,7 @@ pub const InitOptions = struct { |
| 352 | 352 | time_report: bool = false, |
| 353 | 353 | stack_report: bool = false, |
| 354 | 354 | link_eh_frame_hdr: bool = false, |
| 355 | link_emit_relocs: bool = false, | |
| 355 | 356 | linker_script: ?[]const u8 = null, |
| 356 | 357 | version_script: ?[]const u8 = null, |
| 357 | 358 | override_soname: ?[]const u8 = null, |
| ... | ... | @@ -447,6 +448,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 447 | 448 | options.system_libs.len != 0 or |
| 448 | 449 | options.link_libc or options.link_libcpp or |
| 449 | 450 | options.link_eh_frame_hdr or |
| 451 | options.link_emit_relocs or | |
| 450 | 452 | options.output_mode == .Lib or |
| 451 | 453 | options.lld_argv.len != 0 or |
| 452 | 454 | options.linker_script != null or options.version_script != null) |
| ... | ... | @@ -769,6 +771,7 @@ pub fn create(gpa: *Allocator, options: InitOptions) !*Compilation { |
| 769 | 771 | .version_script = options.version_script, |
| 770 | 772 | .gc_sections = options.linker_gc_sections, |
| 771 | 773 | .eh_frame_hdr = options.link_eh_frame_hdr, |
| 774 | .emit_relocs = options.link_emit_relocs, | |
| 772 | 775 | .rdynamic = options.rdynamic, |
| 773 | 776 | .extra_lld_args = options.lld_argv, |
| 774 | 777 | .override_soname = options.override_soname, |
src/link.zig+1| ... | ... | @@ -60,6 +60,7 @@ pub const Options = struct { |
| 60 | 60 | link_libcpp: bool, |
| 61 | 61 | function_sections: bool, |
| 62 | 62 | eh_frame_hdr: bool, |
| 63 | emit_relocs: bool, | |
| 63 | 64 | rdynamic: bool, |
| 64 | 65 | z_nodelete: bool, |
| 65 | 66 | z_defs: bool, |
src/link/Elf.zig+5| ... | ... | @@ -1286,6 +1286,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1286 | 1286 | man.hash.add(stack_size); |
| 1287 | 1287 | man.hash.add(gc_sections); |
| 1288 | 1288 | man.hash.add(self.base.options.eh_frame_hdr); |
| 1289 | man.hash.add(self.base.options.emit_relocs) | |
| 1289 | 1290 | man.hash.add(self.base.options.rdynamic); |
| 1290 | 1291 | man.hash.addListOfBytes(self.base.options.extra_lld_args); |
| 1291 | 1292 | man.hash.addListOfBytes(self.base.options.lib_dirs); |
| ... | ... | @@ -1364,6 +1365,10 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1364 | 1365 | if (self.base.options.eh_frame_hdr) { |
| 1365 | 1366 | try argv.append("--eh-frame-hdr"); |
| 1366 | 1367 | } |
| 1368 | ||
| 1369 | if (self.base.options.emit_relocs) { | |
| 1370 | try argv.append("-emit-relocs"); | |
| 1371 | } | |
| 1367 | 1372 | |
| 1368 | 1373 | if (self.base.options.rdynamic) { |
| 1369 | 1374 | try argv.append("--export-dynamic"); |
src/main.zig+5| ... | ... | @@ -273,6 +273,7 @@ const usage_build_generic = |
| 273 | 273 | \\ -rdynamic Add all symbols to the dynamic symbol table |
| 274 | 274 | \\ -rpath [path] Add directory to the runtime library search path |
| 275 | 275 | \\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker |
| 276 | \\ -emit-relocs Enable output of relocation sections for post build tools | |
| 276 | 277 | \\ -dynamic Force output to be dynamically linked |
| 277 | 278 | \\ -static Force output to be statically linked |
| 278 | 279 | \\ -Bsymbolic Bind global references locally |
| ... | ... | @@ -438,6 +439,7 @@ fn buildOutputType( |
| 438 | 439 | var use_lld: ?bool = null; |
| 439 | 440 | var use_clang: ?bool = null; |
| 440 | 441 | var link_eh_frame_hdr = false; |
| 442 | var link_emit_relocs = false; | |
| 441 | 443 | var each_lib_rpath = false; |
| 442 | 444 | var libc_paths_file: ?[]const u8 = null; |
| 443 | 445 | var machine_code_model: std.builtin.CodeModel = .default; |
| ... | ... | @@ -838,6 +840,8 @@ fn buildOutputType( |
| 838 | 840 | function_sections = true; |
| 839 | 841 | } else if (mem.eql(u8, arg, "--eh-frame-hdr")) { |
| 840 | 842 | link_eh_frame_hdr = true; |
| 843 | } else if (mem.eql(u8, arg, "-emit-relocs")) { | |
| 844 | link_emit_relocs = true; | |
| 841 | 845 | } else if (mem.eql(u8, arg, "-Bsymbolic")) { |
| 842 | 846 | linker_bind_global_refs_locally = true; |
| 843 | 847 | } else if (mem.eql(u8, arg, "--verbose-link")) { |
| ... | ... | @@ -1580,6 +1584,7 @@ fn buildOutputType( |
| 1580 | 1584 | .linker_z_nodelete = linker_z_nodelete, |
| 1581 | 1585 | .linker_z_defs = linker_z_defs, |
| 1582 | 1586 | .link_eh_frame_hdr = link_eh_frame_hdr, |
| 1587 | .link_emit_relocs = link_emit_relocs, | |
| 1583 | 1588 | .stack_size_override = stack_size_override, |
| 1584 | 1589 | .strip = strip, |
| 1585 | 1590 | .single_threaded = single_threaded, |