|
From: <sv...@va...> - 2006-10-17 01:59:34
|
Author: sewardj
Date: 2006-10-17 02:59:30 +0100 (Tue, 17 Oct 2006)
New Revision: 6286
Log:
Merge r6154:
Track SysRes change, and remove unused stuff in header. Perhaps
this should be folded into m_initimg in the fullness of time.
Modified:
trunk/coregrind/m_ume.c
trunk/coregrind/pub_core_ume.h
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 2006-10-17 01:54:54 UTC (rev 6285)
+++ trunk/coregrind/m_ume.c 2006-10-17 01:59:30 UTC (rev 6286)
@@ -30,15 +30,11 @@
*/
=20
=20
-#define _GNU_SOURCE
-#define _FILE_OFFSET_BITS 64
-
-// It seems that on SuSE 9.1 (x86) something in <fcntl.h> messes up stuf=
f
-// acquired indirectly from vki-x86-linux.h. Therefore our headers must=
be
-// included ahead of the glibc ones. This fix is a kludge; the right
-// solution is to entirely remove the glibc dependency.
#include "pub_core_basics.h"
#include "pub_core_vki.h"
+
+#if defined(VGO_linux)
+
#include "pub_core_aspacemgr.h" // various mapping fns
#include "pub_core_debuglog.h"
#include "pub_core_libcbase.h"
@@ -49,9 +45,14 @@
#include "pub_core_libcassert.h" // VG_(exit), vg_assert
#include "pub_core_mallocfree.h" // VG_(malloc), VG_(free)
#include "pub_core_syscall.h" // VG_(strerror)
-#include "pub_core_vkiscnums.h" // mmap-related constants
+#include "pub_core_ume.h" // self
=20
-#include "pub_core_ume.h"
+/* --- !!! --- EXTERNAL HEADERS start --- !!! --- */
+#define _GNU_SOURCE
+#define _FILE_OFFSET_BITS 64
+/* This is for ELF types etc, and also the AT_ constants. */
+#include <elf.h>
+/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */
=20
=20
#if VG_WORDSIZE =3D=3D 8
@@ -73,7 +74,7 @@
{
if (res.isError) {
VG_(printf)("valgrind: mmap(0x%llx, %lld) failed in UME with error=
%d.\n",=20
- (ULong)base, (Long)len, res.val);
+ (ULong)base, (Long)len, res.err);
VG_(exit)(1);
}
}
@@ -119,9 +120,9 @@
e->fd =3D fd;
=20
sres =3D VG_(pread)(fd, &e->e, sizeof(e->e), 0);
- if (sres.isError || sres.val !=3D sizeof(e->e)) {
+ if (sres.isError || sres.res !=3D sizeof(e->e)) {
VG_(printf)("valgrind: %s: can't read ELF header: %s\n",=20
- filename, VG_(strerror)(sres.val));
+ filename, VG_(strerror)(sres.err));
goto bad;
}
=20
@@ -159,9 +160,9 @@
vg_assert(e->p);
=20
sres =3D VG_(pread)(fd, e->p, phsz, e->e.e_phoff);
- if (sres.isError || sres.val !=3D phsz) {
+ if (sres.isError || sres.res !=3D phsz) {
VG_(printf)("valgrind: can't read phdr: %s\n",=20
- VG_(strerror)(sres.val));
+ VG_(strerror)(sres.err));
VG_(free)(e->p);
goto bad;
}
@@ -384,7 +385,7 @@
VG_(printf)("valgrind: m_ume.c: can't open interpreter\n");
VG_(exit)(1);
}
- intfd =3D sres.val;
+ intfd =3D sres.res;
=20
interp =3D readelf(intfd, buf);
if (interp =3D=3D NULL) {
@@ -573,7 +574,7 @@
VG_(close)(fd);
return VKI_EACCES;
} else {
- len =3D res.val;
+ len =3D res.res;
}
=20
vg_assert('#' =3D=3D hdr[0] && '!' =3D=3D hdr[1]);
@@ -641,7 +642,7 @@
if (res.isError) {
return res;
}
- fd =3D res.val;
+ fd =3D res.res;
=20
// Check we have execute permissions
ret =3D VG_(check_executable)((HChar*)exe_name);
@@ -655,11 +656,11 @@
bufsz =3D fsz;
=20
res =3D VG_(pread)(fd, buf, bufsz, 0);
- if (res.isError || res.val !=3D bufsz) {
+ if (res.isError || res.res !=3D bufsz) {
VG_(close)(fd);
return VG_(mk_SysRes_Error)(VKI_EACCES);
}
- bufsz =3D res.val;
+ bufsz =3D res.res;
=20
if (match_ELF(buf, bufsz)) {
res =3D VG_(mk_SysRes_Success)(VG_EXE_FORMAT_ELF);
@@ -692,9 +693,9 @@
=20
res =3D VG_(pre_exec_check)(exe, &fd);
if (res.isError)
- return res.val;
+ return res.err;
=20
- switch (res.val) {
+ switch (res.res) {
case VG_EXE_FORMAT_ELF: ret =3D load_ELF (fd, exe, info); break=
;
case VG_EXE_FORMAT_SCRIPT: ret =3D load_script(fd, exe, info); break=
;
default:
@@ -712,7 +713,7 @@
SysRes res =3D VG_(open)(f, VKI_O_RDONLY, 0);
if (!res.isError) {
Char buf[3] =3D {0,0,0};
- Int fd =3D res.val;
+ Int fd =3D res.res;
Int n =3D VG_(read)(fd, buf, 2);=20
if (n =3D=3D 2 && VG_STREQ("#!", buf))
return True;
@@ -728,7 +729,7 @@
SysRes res =3D VG_(open)(f, VKI_O_RDONLY, 0);
if (!res.isError) {
UChar buf[80];
- Int fd =3D res.val;
+ Int fd =3D res.res;
Int n =3D VG_(read)(fd, buf, 80);=20
Int i;
for (i =3D 0; i < n; i++) {
@@ -833,6 +834,8 @@
return ret;
}
=20
+#endif /* defined(VGO_linux) */
+
/*--------------------------------------------------------------------*/
/*--- end ---*/
/*--------------------------------------------------------------------*/
Modified: trunk/coregrind/pub_core_ume.h
=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/pub_core_ume.h 2006-10-17 01:54:54 UTC (rev 6285)
+++ trunk/coregrind/pub_core_ume.h 2006-10-17 01:59:30 UTC (rev 6286)
@@ -33,42 +33,10 @@
=20
//--------------------------------------------------------------------
// PURPOSE: This module implements user-mode execve, ie. program loading
-// and exec'ing. It is shared between stage1 and stage2.
+// and exec'ing.
//--------------------------------------------------------------------
=20
-#include <elf.h>
-#include <sys/types.h>
-
/*------------------------------------------------------------*/
-/*--- General stuff ---*/
-/*------------------------------------------------------------*/
-
-/* This is only here so it can be shared between stage1 and stage2 */
-
-/* JRS 9 Aug 05: both of these are apparently unused, except by
- memcheck/tests/vgtest_ume.c. */
-//zz extern
-//zz void VG_(foreach_map)(int (*fn)(char *start, char *end,
-//zz const char *perm, off_t offset,
-//zz int maj, int min, int ino, void* extra),
-//zz void* extra);
-//zz=20
-//zz /* Jump to 'dst', but first set the stack pointer to 'stack'. Also=
,
-//zz clear all the integer registers before entering 'dst'. It's
-//zz important that the stack pointer is set to exactly 'stack' and n=
ot
-//zz (eg) stack - apparently_harmless_looking_small_offset. Basicall=
y
-//zz because the code at 'dst' might be wanting to scan the area abov=
e
-//zz 'stack' (viz, the auxv array), and putting spurious words on the
-//zz stack confuses it.
-//zz=20
-//zz This is only exported so that vgtest_ume.c can use it.
-//zz */
-//zz extern
-//zz __attribute__((noreturn))
-//zz void VG_(jump_and_switch_stacks) ( Addr stack, Addr dst );
-
-
-/*------------------------------------------------------------*/
/*--- Loading ELF files ---*/
/*------------------------------------------------------------*/
=20
|