Commit d8cae4d197

Isaac Freund <mail@isaacfreund.com>
2022-06-08 15:13:04
std.build: Expose `-z norelro` and `-z lazy`
1 parent 3381779
Changed files (1)
lib
lib/std/build.zig
@@ -1570,6 +1570,12 @@ pub const LibExeObjStep = struct {
     /// Permit read-only relocations in read-only segments. Disallowed by default.
     link_z_notext: bool = false,
 
+    /// Force all relocations to be read-only after processing.
+    link_z_relro: bool = true,
+
+    /// Allow relocations to be lazily processed after load.
+    link_z_lazy: bool = false,
+
     /// (Darwin) Install name for the dylib
     install_name: ?[]const u8 = null,
 
@@ -2577,6 +2583,14 @@ pub const LibExeObjStep = struct {
             try zig_args.append("-z");
             try zig_args.append("notext");
         }
+        if (!self.link_z_relro) {
+            try zig_args.append("-z");
+            try zig_args.append("norelro");
+        }
+        if (self.link_z_lazy) {
+            try zig_args.append("-z");
+            try zig_args.append("lazy");
+        }
 
         if (self.libc_file) |libc_file| {
             try zig_args.append("--libc");