From d8cae4d1974ae0948cfd4cad5a2bb6e8c4248609 Mon Sep 17 00:00:00 2001 From: Isaac Freund Date: Wed, 8 Jun 2022 15:13:04 +0200 Subject: std.build: Expose `-z norelro` and `-z lazy` --- lib/std/build.zig | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/std') diff --git a/lib/std/build.zig b/lib/std/build.zig index a738a39a1b..ce527ff021 100644 --- a/lib/std/build.zig +++ b/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"); -- cgit v1.2.3