Index: ldso/ldso/powerpc/dl-sysdep.h
===================================================================
--- ldso/ldso/powerpc/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/powerpc/dl-sysdep.h	(working copy)
@@ -68,9 +68,9 @@ extern unsigned long _dl_linux_resolver(
 void _dl_init_got(unsigned long *lpnt,struct elf_resolve *tpnt);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
    PLT entries should not be allowed to define the value.
Index: ldso/ldso/arm/dl-sysdep.h
===================================================================
--- ldso/ldso/arm/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/arm/dl-sysdep.h	(working copy)
@@ -56,9 +56,9 @@ struct elf_resolve;
 unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
    PLT entries should not be allowed to define the value.
Index: ldso/ldso/sh64/dl-sysdep.h
===================================================================
--- ldso/ldso/sh64/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/sh64/dl-sysdep.h	(working copy)
@@ -26,9 +26,9 @@ struct elf_resolve;
 extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
    TLS variable, so undefined references should not be allowed to
Index: ldso/ldso/dl-elf.c
===================================================================
--- ldso/ldso/dl-elf.c	(revision 24137)
+++ ldso/ldso/dl-elf.c	(working copy)
@@ -442,7 +442,7 @@ struct elf_resolve *_dl_load_elf_shared_
 
 	DL_CHECK_LIB_TYPE (epnt, piclib, _dl_progname, libname);
 
-	maxvma = (maxvma + ADDR_ALIGN) & ~ADDR_ALIGN;
+	maxvma = (maxvma + ADDR_ALIGN) & PAGE_ALIGN;
 	minvma = minvma & ~0xffffU;
 
 	flags = MAP_PRIVATE /*| MAP_DENYWRITE */ ;
Index: ldso/ldso/m68k/dl-sysdep.h
===================================================================
--- ldso/ldso/m68k/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/m68k/dl-sysdep.h	(working copy)
@@ -26,9 +26,9 @@ struct elf_resolve;
 extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
    PLT entries should not be allowed to define the value.
Index: ldso/ldso/i386/dl-sysdep.h
===================================================================
--- ldso/ldso/i386/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/i386/dl-sysdep.h	(working copy)
@@ -26,9 +26,9 @@ struct elf_resolve;
 extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
    TLS variable, so undefined references should not be allowed to
Index: ldso/ldso/avr32/dl-sysdep.h
===================================================================
--- ldso/ldso/avr32/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/avr32/dl-sysdep.h	(working copy)
@@ -47,9 +47,9 @@
 unsigned long _dl_linux_resolver(unsigned long got_offset, unsigned long *got);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 #define elf_machine_type_class(type)				\
 	((type == R_AVR32_JMP_SLOT) * ELF_RTYPE_CLASS_PLT)
Index: ldso/ldso/frv/dl-sysdep.h
===================================================================
--- ldso/ldso/frv/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/frv/dl-sysdep.h	(working copy)
@@ -53,9 +53,9 @@ extern int _dl_linux_resolve(void) __att
 
 /* 16KiB page alignment.  Should perhaps be made dynamic using
    getpagesize(), based on AT_PAGESZ from auxvt?  */
-#define PAGE_ALIGN 0xffffc000
-#define ADDR_ALIGN 0x3fff
-#define OFFS_ALIGN 0x7fffc000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 struct funcdesc_ht;
 
Index: ldso/ldso/x86_64/dl-sysdep.h
===================================================================
--- ldso/ldso/x86_64/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/x86_64/dl-sysdep.h	(working copy)
@@ -42,9 +42,9 @@ struct elf_resolve;
 extern unsigned long _dl_linux_resolver(struct elf_resolve * tpnt, int reloc_entry);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
    TLS variable, so undefined references should not be allowed to
Index: ldso/ldso/cris/dl-sysdep.h
===================================================================
--- ldso/ldso/cris/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/cris/dl-sysdep.h	(working copy)
@@ -19,9 +19,9 @@ struct elf_resolve;
 extern unsigned long _dl_linux_resolver(struct elf_resolve *tpnt, int reloc_entry);
 
 /* 8192 bytes alignment */
-#define PAGE_ALIGN 0xffffe000
-#define ADDR_ALIGN 0x1fff
-#define OFFS_ALIGN 0xffffe000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* The union of reloc-type-classes where the reloc TYPE is a member.
 
Index: ldso/ldso/xtensa/dl-sysdep.h
===================================================================
--- ldso/ldso/xtensa/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/xtensa/dl-sysdep.h	(working copy)
@@ -77,9 +77,9 @@ struct elf_resolve;
 extern unsigned long _dl_linux_resolver (struct elf_resolve *, int);
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
    undefined references should not be allowed to define the value.  */
Index: ldso/ldso/sparc/dl-sysdep.h
===================================================================
--- ldso/ldso/sparc/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/sparc/dl-sysdep.h	(working copy)
@@ -89,17 +89,11 @@ sparc_mod(unsigned long m, unsigned long
 #define do_rem(result, n, base) ((result) = sparc_mod(n, base))
 #endif
 
-/* 4096 bytes alignment */
-#if defined(__sparc_v9__)
-/* ...but 8192 is required for mmap() on sparc64 kernel */
-#define PAGE_ALIGN 0xffffe000
-#define ADDR_ALIGN 0x1fff
-#define OFFS_ALIGN 0x7fffe000
-#elif defined(__sparc_v8__)
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-#endif
+/* 4096 bytes alignment for __sparc_v8__ */
+/* ...but 8192 is required for __sparc_v9__'s mmap() on sparc64 kernel */
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry, so
    PLT entries should not be allowed to define the value.
Index: ldso/ldso/mips/dl-sysdep.h
===================================================================
--- ldso/ldso/mips/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/mips/dl-sysdep.h	(working copy)
@@ -147,15 +147,13 @@ struct elf_resolve;
 void _dl_perform_mips_global_got_relocations(struct elf_resolve *tpnt, int lazy);
 
 /* 4096 bytes alignment */
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
 #if _MIPS_SIM == _MIPS_SIM_ABI64
-#define PAGE_ALIGN (~0xfffUL)
-#define ADDR_ALIGN 0xfffUL
-#define OFFS_ALIGN (0x10000000000UL-0x1000)
-#else	/* O32 || N32 */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
-#endif	/* O32 || N32 */
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
+#else /* O32 || N32 */
+#define OFFS_ALIGN (0x10000000000UL - _dl_pagesize)
+#endif
 
 #define elf_machine_type_class(type)		ELF_RTYPE_CLASS_PLT
 /* MIPS does not have COPY relocs */
Index: ldso/ldso/sh/dl-sysdep.h
===================================================================
--- ldso/ldso/sh/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/sh/dl-sysdep.h	(working copy)
@@ -84,9 +84,9 @@ _dl_urem(unsigned int n, unsigned int ba
 #define do_rem(result, n, base)     ((result) = _dl_urem((n), (base)))
 
 /* 4096 bytes alignment */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 /* ELF_RTYPE_CLASS_PLT iff TYPE describes relocation of a PLT entry or
    TLS variable, so undefined references should not be allowed to
Index: ldso/ldso/bfin/dl-sysdep.h
===================================================================
--- ldso/ldso/bfin/dl-sysdep.h	(revision 24137)
+++ ldso/ldso/bfin/dl-sysdep.h	(working copy)
@@ -69,9 +69,9 @@ extern int _dl_linux_resolve(void) __att
 
 /* 4KiB page alignment.  Should perhaps be made dynamic using
    getpagesize(), based on AT_PAGESZ from auxvt?  */
-#define PAGE_ALIGN 0xfffff000
-#define ADDR_ALIGN 0xfff
-#define OFFS_ALIGN 0x7ffff000
+#define PAGE_ALIGN (~ADDR_ALIGN)
+#define ADDR_ALIGN (_dl_pagesize - 1)
+#define OFFS_ALIGN ((PAGE_ALIGN) & ~(1 << 31))
 
 struct funcdesc_ht;
 
