authorgravatar for motiejus@jakstys.ltMotiejus Jakštys <motiejus@jakstys.lt> 2022-10-16 12:53:11+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-18 12:55:31-04:00
log5ec76cf5c84f3863618e220ce41d09cc9781af8a
tree97d6d6bce27ed26cf543c360a90b4b877df963d7
parent787788996fbefef565b5097456463467b6b3d8d6

[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.

1 files changed, 6 insertions(+), 0 deletions(-)

src/main.zig+6
...@@ -696,6 +696,7 @@ fn buildOutputType(...@@ -696,6 +696,7 @@ fn buildOutputType(
696 var linker_print_gc_sections: bool = false;696 var linker_print_gc_sections: bool = false;
697 var linker_print_icf_sections: bool = false;697 var linker_print_icf_sections: bool = false;
698 var linker_print_map: bool = false;698 var linker_print_map: bool = false;
699 var linker_z_nocopyreloc = false;
699 var linker_z_nodelete = false;700 var linker_z_nodelete = false;
700 var linker_z_notext = false;701 var linker_z_notext = false;
701 var linker_z_defs = false;702 var linker_z_defs = false;
...@@ -1262,6 +1263,8 @@ fn buildOutputType(...@@ -1262,6 +1263,8 @@ fn buildOutputType(
1262 linker_z_defs = true;1263 linker_z_defs = true;
1263 } else if (mem.eql(u8, z_arg, "origin")) {1264 } else if (mem.eql(u8, z_arg, "origin")) {
1264 linker_z_origin = true;1265 linker_z_origin = true;
1266 } else if (mem.eql(u8, z_arg, "nocopyreloc")) {
1267 linker_z_nocopyreloc = true;
1265 } else if (mem.eql(u8, z_arg, "now")) {1268 } else if (mem.eql(u8, z_arg, "now")) {
1266 linker_z_now = true;1269 linker_z_now = true;
1267 } else if (mem.eql(u8, z_arg, "lazy")) {1270 } else if (mem.eql(u8, z_arg, "lazy")) {
...@@ -1825,6 +1828,8 @@ fn buildOutputType(...@@ -1825,6 +1828,8 @@ fn buildOutputType(
1825 linker_z_defs = true;1828 linker_z_defs = true;
1826 } else if (mem.eql(u8, z_arg, "origin")) {1829 } else if (mem.eql(u8, z_arg, "origin")) {
1827 linker_z_origin = true;1830 linker_z_origin = true;
1831 } else if (mem.eql(u8, z_arg, "nocopyreloc")) {
1832 linker_z_nocopyreloc = true;
1828 } else if (mem.eql(u8, z_arg, "noexecstack")) {1833 } else if (mem.eql(u8, z_arg, "noexecstack")) {
1829 // noexecstack is the default when linking with LLD1834 // noexecstack is the default when linking with LLD
1830 } else if (mem.eql(u8, z_arg, "now")) {1835 } else if (mem.eql(u8, z_arg, "now")) {
...@@ -2894,6 +2899,7 @@ fn buildOutputType(...@@ -2894,6 +2899,7 @@ fn buildOutputType(
2894 .linker_print_map = linker_print_map,2899 .linker_print_map = linker_print_map,
2895 .linker_global_base = linker_global_base,2900 .linker_global_base = linker_global_base,
2896 .linker_export_symbol_names = linker_export_symbol_names.items,2901 .linker_export_symbol_names = linker_export_symbol_names.items,
2902 .linker_z_nocopyreloc = linker_z_nocopyreloc,
2897 .linker_z_nodelete = linker_z_nodelete,2903 .linker_z_nodelete = linker_z_nodelete,
2898 .linker_z_notext = linker_z_notext,2904 .linker_z_notext = linker_z_notext,
2899 .linker_z_defs = linker_z_defs,2905 .linker_z_defs = linker_z_defs,