diff options
| author | Frank Denis <github@pureftpd.org> | 2023-01-05 21:21:29 +0100 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-01-05 19:39:17 -0700 |
| commit | 6ad92108e2cbba06064724d8d91abaede20f355a (patch) | |
| tree | 4551c42980bf7044fd67edcbe51f7d9a257344c6 /src/link | |
| parent | c28c38d1e5648a45e8b3b2edbd1c732edb8d2642 (diff) | |
| download | zig-6ad92108e2cbba06064724d8d91abaede20f355a.tar.gz zig-6ad92108e2cbba06064724d8d91abaede20f355a.zip | |
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
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Elf.zig | 10 |
1 files changed, 10 insertions, 0 deletions
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". |
