From ce54b92b046b65464e2d16b3842f3e97e3e0f27e Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 3 Dec 2008 19:40:55 +0000 Subject: - Use runtime pagesize (Jeremy Kerr) Some powerpc machines can support 64k pages, enabled by the CONFIG_64K_PAGES option in linux. However, the uClibc dynamic loader won't currently work on these machines, as it uses hard-coded values (PAGE_ALIGN, ADDR_ALIGN and OFFS_ALIGN) in the ldso architecture-specific headers. When running on a kernel with 64k pages, ld.so tries to mmap with 4k-aligned addresses, rather than 64k, so mmap fails with -EINVAL. When booting a 64k machine with a uClibc dynamic linker, init fails with: /init:500: can't map '/lib/libc.so.0' /init:500: can't map '/lib/libc.so.0' /init:500: can't map '/lib/libc.so.0' /init: can't load library 'libc.so.0' Kernel panic - not syncing: Attempted to kill init! This change allows ld.so determine these alignment masks at runtime, rather than compile-time. Since we have the _dl_pagesize variable available, we can use that to generate the appropriate masks. Since almost all of the architectures can use the common definitions for the _ALIGN macros, we can consolidate them all in ldso.h, and override in the sysdep headers where necessary (ie, mips). This allows me to start a uClibc-based root fs on a 64k machine. Signed-off-by: Jeremy Kerr --- ldso/include/ldso.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ldso/include') diff --git a/ldso/include/ldso.h b/ldso/include/ldso.h index 35a72fc5e..ec0663cea 100644 --- a/ldso/include/ldso.h +++ b/ldso/include/ldso.h @@ -39,6 +39,19 @@ #include #include +/* common align masks, if not specified by sysdep headers */ +#ifndef ADDR_ALIGN +#define ADDR_ALIGN (_dl_pagesize - 1) +#endif + +#ifndef PAGE_ALIGN +#define PAGE_ALIGN (~ADDR_ALIGN) +#endif + +#ifndef OFFS_ALIGN +#define OFFS_ALIGN (PAGE_ALIGN & ~(1ul << (sizeof(_dl_pagesize) * 8 - 1))) +#endif + /* For INIT/FINI dependency sorting. */ struct init_fini_list { struct init_fini_list *next; -- cgit v1.2.3