From 6ad92108e2cbba06064724d8d91abaede20f355a Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 5 Jan 2023 21:21:29 +0100 Subject: ELF linker: support common-page-size and max-page-size lld opts These linker flags are required to build static ELF binaries that can run under the Blink emulator: https://github.com/jart/blink/issues/14 --- src/link/Elf.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/link') diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 4910f4b599..c27e4f166f 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1390,6 +1390,8 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v man.hash.add(self.base.options.z_nocopyreloc); man.hash.add(self.base.options.z_now); man.hash.add(self.base.options.z_relro); + man.hash.add(self.base.options.z_common_page_size orelse 0); + man.hash.add(self.base.options.z_max_page_size orelse 0); man.hash.add(self.base.options.hash_style); // strip does not need to go into the linker hash because it is part of the hash namespace if (self.base.options.link_libc) { @@ -1594,6 +1596,14 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v // LLD defaults to -zrelro try argv.append("-znorelro"); } + if (self.base.options.z_common_page_size) |size| { + try argv.append("-z"); + try argv.append(try std.fmt.allocPrint(arena, "common-page-size={d}", .{size})); + } + if (self.base.options.z_max_page_size) |size| { + try argv.append("-z"); + try argv.append(try std.fmt.allocPrint(arena, "max-page-size={d}", .{size})); + } if (getLDMOption(target)) |ldm| { // Any target ELF will use the freebsd osabi if suffixed with "_fbsd". -- cgit v1.2.3