Hauke Mehrtens 04f10eb796 build: set max-page-size linker flag to match target page size
ELF binaries embed the maximum page size used during linking in the
PT_LOAD segment alignment. If this value is larger than the actual
system page size, the kernel will still load the binary but wastes
memory due to over-alignment. If it is smaller, the binary may fail
to load or cause incorrect behavior with features like RELRO.

Most architectures use 4KB pages, but loongarch64 uses 16KB pages
(CONFIG_PAGE_SIZE_16KB). Explicitly pass -z max-page-size to the
linker so that binaries are built with the correct page alignment for
the target, avoiding issues with RELRO segment padding and ensuring
correct memory mapping on the target system.

Before binutils 2.39 RELRO sections were padded to common page size
which is 4K on MIPS, with binutils 3.29 the padding was changed to
max page size which is 64K on MIPS. With this change we will pad them to
4K again.

This reduces the size of user space binaries in OpenWrt.
The size of the uncompressed root file system of a mips malta be build
decreased by about 20%.

old file size:
```
$ du -s build_dir/target-mips_24kc_musl/root-malta/
15844	build_dir/target-mips_24kc_musl/root-malta/
```

New file size:
```
$ du -s build_dir/target-mips_24kc_musl/root-malta/
12564	build_dir/target-mips_24kc_musl/root-malta/
```

The size of the image did not decrease much because of the strong
compression used by OpenWrt.

Link: https://github.com/openwrt/openwrt/pull/22800
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
2026-04-08 00:34:59 +02:00
..
2026-02-17 01:29:57 +01:00
2021-02-05 14:54:47 +01:00
2026-02-13 15:40:13 +01:00
2024-12-02 19:30:22 +00:00
2026-01-21 22:42:20 +01:00
2022-11-27 00:52:06 +01:00
2025-10-20 00:55:06 +02:00
2025-11-27 20:26:37 +01:00
2026-02-13 15:40:13 +01:00
2026-01-02 18:07:02 +01:00
2021-10-24 18:20:50 +02:00