|
From: <sv...@va...> - 2005-07-18 15:52:37
|
Author: tom
Date: 2005-07-18 16:52:30 +0100 (Mon, 18 Jul 2005)
New Revision: 4164
Log:
If the client program is a PIE executable, avoid mapping it at
address zero. Instead do something like what the kernel does and
map it in the middle of the client address space.
Fix for bug #106283 based on patch from Sergey Vlasov.
Modified:
trunk/coregrind/m_ume.c
Modified: trunk/coregrind/m_ume.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_ume.c 2005-07-18 14:10:12 UTC (rev 4163)
+++ trunk/coregrind/m_ume.c 2005-07-18 15:52:30 UTC (rev 4164)
@@ -441,6 +441,12 @@
if (e =3D=3D NULL)
return ENOEXEC;
=20
+ /* The kernel maps position-independent executables at TASK_SIZE*2/3;
+ duplicate this behavior as close as we can. */
+ if (e->e.e_type =3D=3D ET_DYN && ebase =3D=3D 0) {
+ ebase =3D VG_PGROUNDDN(info->exe_base + (info->exe_end - info->exe=
_base) * 2 / 3);
+ }
+
info->phnum =3D e->e.e_phnum;
info->entry =3D e->e.e_entry + ebase;
info->phdr =3D 0;
@@ -513,7 +519,7 @@
}
=20
if (info->phdr =3D=3D 0)
- info->phdr =3D minaddr + e->e.e_phoff;
+ info->phdr =3D minaddr + ebase + e->e.e_phoff;
=20
if (info->exe_base !=3D info->exe_end) {
if (minaddr >=3D maxaddr ||
@@ -560,7 +566,7 @@
free(interp->p);
free(interp);
} else
- entry =3D (void *)e->e.e_entry;
+ entry =3D (void *)(ebase + e->e.e_entry);
=20
info->exe_base =3D minaddr + ebase;
info->exe_end =3D maxaddr + ebase;
|