This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Fix mapstart calculation for variable page size
- From: Daniel Jacobowitz <drow at false dot org>
- To: libc-alpha at sourceware dot org
- Date: Mon, 5 Nov 2007 14:03:40 -0500
- Subject: Fix mapstart calculation for variable page size
dlopen calculates l_map_start by rounding down to the nearest page
start. But for the main program, glibc still rounds down based on
the PT_LOAD segment alignment. This isn't right; any whole pages
between the value calculated that way and ph->p_vaddr may be reused
for a mapping outside the main program.
--
Daniel Jacobowitz
CodeSourcery
2007-11-05 Daniel Jacobowitz <dan@codesourcery.com>
* elf/rtld.c (dl_main): Use the page size to find the map start.
Index: elf/rtld.c
===================================================================
RCS file: /cvs/glibc/libc/elf/rtld.c,v
retrieving revision 1.372
diff -u -p -r1.372 rtld.c
--- elf/rtld.c 31 Oct 2007 15:28:19 -0000 1.372
+++ elf/rtld.c 5 Nov 2007 15:13:34 -0000
@@ -1166,7 +1166,7 @@ of this helper program; chances are you
ElfW(Addr) allocend;
/* Remember where the main program starts in memory. */
- mapstart = (main_map->l_addr + (ph->p_vaddr & ~(ph->p_align - 1)));
+ mapstart = (main_map->l_addr + (ph->p_vaddr & ~(GLRO(dl_pagesize) - 1)));
if (main_map->l_map_start > mapstart)
main_map->l_map_start = mapstart;