Skip to content

Commit e9f4cfc

Browse files
author
sewardj
committed
Don't assume that page size is 4K when loading PIEs. Fixes #263034.
(Dodji Seketeli, [email protected]) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13351 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent fdb7081 commit e9f4cfc

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

coregrind/m_ume/elf.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -334,18 +334,21 @@ Int VG_(load_ELF)(Int fd, const HChar* name, /*MOD*/ExeInfo* info)
334334
become legit, which is really bad) and causes problems for
335335
exp-ptrcheck, which assumes all numbers below 1MB are
336336
nonpointers. So, hackily, move it above 1MB. */
337-
/* Later .. is appears ppc32-linux tries to put [vdso] at 1MB,
337+
/* Later .. it appears ppc32-linux tries to put [vdso] at 1MB,
338338
which totally screws things up, because nothing else can go
339-
there. So bump the hacky load addess along by 0x8000, to
340-
0x108000. */
341-
/* Later .. on mips64 we can't use 0x108000, because mapelf will fail. */
342-
#if defined(VGP_mips64_linux)
339+
there. The size of [vdso] is around 2 or 3 pages, so bump
340+
the hacky load addess along by 8 * VKI_PAGE_SIZE to be safe. */
341+
/* Later .. on mips64 we can't use 0x108000, because mapelf will
342+
fail. */
343+
# if defined(VGP_mips64_linux)
343344
if (ebase < 0x100000)
344345
ebase = 0x100000;
345-
#else
346-
if (ebase < 0x108000)
347-
ebase = 0x108000;
348-
#endif
346+
# else
347+
vg_assert(VKI_PAGE_SIZE >= 4096); /* stay sane */
348+
ESZ(Addr) hacky_load_address = 0x100000 + 8 * VKI_PAGE_SIZE;
349+
if (ebase < hacky_load_address)
350+
ebase = hacky_load_address;
351+
# endif
349352
}
350353

351354
info->phnum = e->e.e_phnum;

0 commit comments

Comments
 (0)