@@ -401,6 +401,14 @@ const usage_build_generic =
401
401
\\ -fno-allow-shlib-undefined Disallows undefined symbols in shared libraries
402
402
\\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker
403
403
\\ --emit-relocs Enable output of relocation sections for post build tools
404
+ \\ -z [flag] Linker flags
405
+ \\ nodelete Indicate that the object cannot be deleted from a process
406
+ \\ notext Permit read-only relocations in read-only segments
407
+ \\ defs Force a fatal error if any undefined symbols remain
408
+ \\ origin Indicate that the object must have its origin processed
409
+ \\ noexecstack Indicate that the object requires an executable stack
410
+ \\ now Force all relocations to be processed on load
411
+ \\ relro Force all relocations to be resolved and be read-only on load
404
412
\\ -dynamic Force output to be dynamically linked
405
413
\\ -static Force output to be statically linked
406
414
\\ -Bsymbolic Bind global references locally
@@ -595,6 +603,7 @@ fn buildOutputType(
595
603
var linker_allow_shlib_undefined : ? bool = null ;
596
604
var linker_bind_global_refs_locally : ? bool = null ;
597
605
var linker_z_nodelete = false ;
606
+ var linker_z_notext = false ;
598
607
var linker_z_defs = false ;
599
608
var linker_z_origin = false ;
600
609
var linker_z_noexecstack = false ;
@@ -1086,6 +1095,29 @@ fn buildOutputType(
1086
1095
linker_allow_shlib_undefined = true ;
1087
1096
} else if (mem .eql (u8 , arg , "-fno-allow-shlib-undefined" )) {
1088
1097
linker_allow_shlib_undefined = false ;
1098
+ } else if (mem .eql (u8 , arg , "-z" )) {
1099
+ i += 1 ;
1100
+ if (i >= args .len ) {
1101
+ fatal ("expected linker arg after '{s}'" , .{arg });
1102
+ }
1103
+ const z_arg = args [i ];
1104
+ if (mem .eql (u8 , z_arg , "nodelete" )) {
1105
+ linker_z_nodelete = true ;
1106
+ } else if (mem .eql (u8 , z_arg , "notext" )) {
1107
+ linker_z_notext = true ;
1108
+ } else if (mem .eql (u8 , z_arg , "defs" )) {
1109
+ linker_z_defs = true ;
1110
+ } else if (mem .eql (u8 , z_arg , "origin" )) {
1111
+ linker_z_origin = true ;
1112
+ } else if (mem .eql (u8 , z_arg , "noexecstack" )) {
1113
+ linker_z_noexecstack = true ;
1114
+ } else if (mem .eql (u8 , z_arg , "now" )) {
1115
+ linker_z_now = true ;
1116
+ } else if (mem .eql (u8 , z_arg , "relro" )) {
1117
+ linker_z_relro = true ;
1118
+ } else {
1119
+ warn ("unsupported linker arg: -z {s}" , .{z_arg });
1120
+ }
1089
1121
} else if (mem .eql (u8 , arg , "-Bsymbolic" )) {
1090
1122
linker_bind_global_refs_locally = true ;
1091
1123
} else if (mem .eql (u8 , arg , "--debug-compile-errors" )) {
@@ -1422,6 +1454,8 @@ fn buildOutputType(
1422
1454
const z_arg = linker_args .items [i ];
1423
1455
if (mem .eql (u8 , z_arg , "nodelete" )) {
1424
1456
linker_z_nodelete = true ;
1457
+ } else if (mem .eql (u8 , z_arg , "notext" )) {
1458
+ linker_z_notext = true ;
1425
1459
} else if (mem .eql (u8 , z_arg , "defs" )) {
1426
1460
linker_z_defs = true ;
1427
1461
} else if (mem .eql (u8 , z_arg , "origin" )) {
@@ -2108,6 +2142,7 @@ fn buildOutputType(
2108
2142
.linker_allow_shlib_undefined = linker_allow_shlib_undefined ,
2109
2143
.linker_bind_global_refs_locally = linker_bind_global_refs_locally ,
2110
2144
.linker_z_nodelete = linker_z_nodelete ,
2145
+ .linker_z_notext = linker_z_notext ,
2111
2146
.linker_z_defs = linker_z_defs ,
2112
2147
.linker_z_origin = linker_z_origin ,
2113
2148
.linker_z_noexecstack = linker_z_noexecstack ,
0 commit comments