[PATCH v6 09/23] loongarch: Add <bits/pagesize.h>
Florian Weimer
fweimer@redhat.com
Tue May 20 09:23:14 GMT 2025
According to arch/loongarch/Kconfig in the kernel sources, LoongArch
supports 4 KiB, 16 KiB, and 64 KiB page sizes. However, only 16 KiB
pages are expected to work and are actively maintained.
To avoid load segment gaps in ld.so, lower the page size for the
binary to 16 KiB explicitly.
---
sysdeps/loongarch/Makefile | 6 ++++++
sysdeps/loongarch/bits/pagesize.h | 2 ++
2 files changed, 8 insertions(+)
create mode 100644 sysdeps/loongarch/bits/pagesize.h
diff --git a/sysdeps/loongarch/Makefile b/sysdeps/loongarch/Makefile
index b00c090faa..de6e0393ba 100644
--- a/sysdeps/loongarch/Makefile
+++ b/sysdeps/loongarch/Makefile
@@ -16,6 +16,12 @@ sysdep-dl-routines += \
tlsdesc \
# sysdep-dl-routines
+# Only 16 KiB pages are supported, but binutils ld produces binaries
+# with 64 KiB page support. This introduces gaps between ld.so load
+# segments. To avoid that, lower the maximum supported page size to
+# 16 KiB.
+LDFLAGS-rtld += -Wl,-z,max-page-size=16384
+
gen-as-const-headers += \
dl-link.sym \
# gen-as-const-headers
diff --git a/sysdeps/loongarch/bits/pagesize.h b/sysdeps/loongarch/bits/pagesize.h
new file mode 100644
index 0000000000..79d34aaaf6
--- /dev/null
+++ b/sysdeps/loongarch/bits/pagesize.h
@@ -0,0 +1,2 @@
+#define __GLIBC_PAGE_SHIFT_MIN 14
+#define __GLIBC_PAGE_SHIFT_MAX 14
--
2.49.0
More information about the Libc-alpha
mailing list