elf: Align argument of __munmap to page size [BZ #28676]

On Linux/x86-64, for elf/tst-align3, we now get

munmap(0x7f88f9401000, 1126424)         = 0

instead of

munmap(0x7f1615200018, 544768)          = -1 EINVAL (Invalid argument)

Reviewed-by: Florian Weimer <fweimer@redhat.com>
This commit is contained in:
H.J. Lu 2021-12-13 07:17:29 -08:00
parent 0884724a95
commit fd6062ede3

View File

@ -55,6 +55,7 @@ _dl_map_segment (const struct loadcmd *c, ElfW(Addr) mappref,
if (delta)
__munmap ((void *) map_start, delta);
ElfW(Addr) map_end = map_start_aligned + maplength;
map_end = ALIGN_UP (map_end, GLRO(dl_pagesize));
delta = map_start + maplen - map_end;
if (delta)
__munmap ((void *) map_end, delta);