From 5ec76cf5c84f3863618e220ce41d09cc9781af8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Sun, 16 Oct 2022 12:53:11 +0300 Subject: [PATCH] [elf] main.zig: add -z nocopyreloc I did not fully wire it up in main.zig when I originally implemented `-z nocopyreloc` in #11679 (440f5249f1a). Finish it. If we strictly follow the rules, we should bump the cache has version, since the field was technically added only now. But since nobody complained thus far, I don't think many users care that much about it and we can omit it. --- src/main.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.zig b/src/main.zig index e18acd9051..0f08109e9b 100644 --- a/src/main.zig +++ b/src/main.zig @@ -696,6 +696,7 @@ fn buildOutputType( var linker_print_gc_sections: bool = false; var linker_print_icf_sections: bool = false; var linker_print_map: bool = false; + var linker_z_nocopyreloc = false; var linker_z_nodelete = false; var linker_z_notext = false; var linker_z_defs = false; @@ -1262,6 +1263,8 @@ fn buildOutputType( linker_z_defs = true; } else if (mem.eql(u8, z_arg, "origin")) { linker_z_origin = true; + } else if (mem.eql(u8, z_arg, "nocopyreloc")) { + linker_z_nocopyreloc = true; } else if (mem.eql(u8, z_arg, "now")) { linker_z_now = true; } else if (mem.eql(u8, z_arg, "lazy")) { @@ -1825,6 +1828,8 @@ fn buildOutputType( linker_z_defs = true; } else if (mem.eql(u8, z_arg, "origin")) { linker_z_origin = true; + } else if (mem.eql(u8, z_arg, "nocopyreloc")) { + linker_z_nocopyreloc = true; } else if (mem.eql(u8, z_arg, "noexecstack")) { // noexecstack is the default when linking with LLD } else if (mem.eql(u8, z_arg, "now")) { @@ -2894,6 +2899,7 @@ fn buildOutputType( .linker_print_map = linker_print_map, .linker_global_base = linker_global_base, .linker_export_symbol_names = linker_export_symbol_names.items, + .linker_z_nocopyreloc = linker_z_nocopyreloc, .linker_z_nodelete = linker_z_nodelete, .linker_z_notext = linker_z_notext, .linker_z_defs = linker_z_defs,