From 7a2fde973d27c7c47dc6eba174c71ae93af29d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 6 Oct 2024 14:03:08 +0200 Subject: [PATCH] link.Elf: Fix page size calculation for more architectures. Sourced from binutils/bfd. --- src/link/Elf.zig | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/link/Elf.zig b/src/link/Elf.zig index a0ec37668e..f7b0529d8f 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -188,11 +188,41 @@ pub fn createEmpty( else => return error.UnsupportedELFArchitecture, }; + // This is the max page size that the target system can run with, aka the ABI page size. Not to + // be confused with the common page size, which is the page size that's used in practice on most + // systems. const page_size: u32 = switch (target.cpu.arch) { - .aarch64, .hexagon, .powerpc64le => 0x10000, - .sparc64 => 0x2000, + .bpfel, + .bpfeb, + .sparc64, + => 0x100000, + .aarch64, + .aarch64_be, + .amdgcn, + .hexagon, + .mips, + .mipsel, + .mips64, + .mips64el, + .powerpc, + .powerpcle, + .powerpc64, + .powerpc64le, + .sparc, + => 0x10000, + .loongarch32, + .loongarch64, + => 0x4000, + .arc, + .m68k, + => 0x2000, + .msp430, + => 0x4, + .avr, + => 0x1, else => 0x1000, }; + const is_dyn_lib = output_mode == .Lib and link_mode == .dynamic; const default_sym_version: elf.Elf64_Versym = if (is_dyn_lib or comp.config.rdynamic) elf.VER_NDX_GLOBAL