[PATCH] ldso: use ALIGN macros instead of _dl_pagesize where suitable

Jeremy Kerr jk at ozlabs.org
Wed Nov 26 10:34:07 UTC 2008


We have a couple of places where _dl_pagesize is used directly, but one
of the ALIGN macros would suit better. Use these instead.

Signed-off-by: Jeremy Kerr <jk at ozlabs.org>

---

 ldso/ldso/dl-elf.c |    4 ++--
 ldso/ldso/ldso.c   |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

Index: uClibc/ldso/ldso/dl-elf.c
===================================================================
--- uClibc.orig/ldso/ldso/dl-elf.c	2008-11-26 21:15:15.000000000 +1100
+++ uClibc/ldso/ldso/dl-elf.c	2008-11-26 21:29:06.000000000 +1100
@@ -119,8 +119,8 @@ void
 _dl_protect_relro (struct elf_resolve *l)
 {
 	ElfW(Addr) base = (ElfW(Addr)) DL_RELOC_ADDR(l->loadaddr, l->relro_addr);
-	ElfW(Addr) start = (base & ~(_dl_pagesize - 1));
-	ElfW(Addr) end = ((base + l->relro_size) & ~(_dl_pagesize - 1));
+	ElfW(Addr) start = (base & PAGE_ALIGN);
+	ElfW(Addr) end = ((base + l->relro_size) & PAGE_ALIGN);
 	_dl_if_debug_dprint("RELRO protecting %s:  start:%x, end:%x\n", l->libname, start, end);
 	if (start != end &&
 	    _dl_mprotect ((void *) start, end - start, PROT_READ) < 0) {
Index: uClibc/ldso/ldso/ldso.c
===================================================================
--- uClibc.orig/ldso/ldso/ldso.c	2008-11-26 21:18:37.000000000 +1100
+++ uClibc/ldso/ldso/ldso.c	2008-11-26 21:18:49.000000000 +1100
@@ -914,7 +914,7 @@ void *_dl_malloc(size_t size)
 		   The actual page size doesn't really matter; as long
 		   as we're self-consistent here, we're safe.  */
 		if (size < _dl_pagesize)
-			rounded_size = (size + _dl_pagesize - 1) & _dl_pagesize;
+			rounded_size = (size + ADDR_ALIGN) & _dl_pagesize;
 		else
 			rounded_size = size;
 



More information about the uClibc mailing list