From 60084e34b63a9ad5bdd7381bab2d7bc30db106c9 Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Fri, 18 Sep 2015 09:27:45 -0400 Subject: Use ALIGN_* macros in _dl_map_object_from_fd. Cleanup _dl_map_object_from_fd to make it clear exactly what we're doing with the mappings i.e. extending the the start of the map down to a page boundary, extending the end of the map up to a page boundary, and offset itself also to page boundary. The result is much easier to read as expected from the ALIGN_* cleanups. --- elf/dl-load.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'elf/dl-load.c') diff --git a/elf/dl-load.c b/elf/dl-load.c index 0c052e449a..993a419bdd 100644 --- a/elf/dl-load.c +++ b/elf/dl-load.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1077,12 +1078,11 @@ _dl_map_object_from_fd (const char *name, int fd, struct filebuf *fbp, } struct loadcmd *c = &loadcmds[nloadcmds++]; - c->mapstart = ph->p_vaddr & ~(GLRO(dl_pagesize) - 1); - c->mapend = ((ph->p_vaddr + ph->p_filesz + GLRO(dl_pagesize) - 1) - & ~(GLRO(dl_pagesize) - 1)); + c->mapstart = ALIGN_DOWN (ph->p_vaddr, GLRO(dl_pagesize)); + c->mapend = ALIGN_UP (ph->p_vaddr + ph->p_filesz, GLRO(dl_pagesize)); c->dataend = ph->p_vaddr + ph->p_filesz; c->allocend = ph->p_vaddr + ph->p_memsz; - c->mapoff = ph->p_offset & ~(GLRO(dl_pagesize) - 1); + c->mapoff = ALIGN_DOWN (ph->p_offset, GLRO(dl_pagesize)); /* Determine whether there is a gap between the last segment and this one. */ -- cgit v1.2.3