From: Julian Seward Date: Tue, 17 Oct 2006 01:59:30 +0000 (+0000) Subject: Merge r6154: X-Git-Tag: svn/VALGRIND_3_3_0~590 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2f14c710639a406d2c74d3abcb2f7e1fd7e0a0c;p=thirdparty%2Fvalgrind.git Merge r6154: Track SysRes change, and remove unused stuff in header. Perhaps this should be folded into m_initimg in the fullness of time. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6286 --- diff --git a/coregrind/m_ume.c b/coregrind/m_ume.c index 8151267baf..5a1f74bccd 100644 --- a/coregrind/m_ume.c +++ b/coregrind/m_ume.c @@ -30,15 +30,11 @@ */ -#define _GNU_SOURCE -#define _FILE_OFFSET_BITS 64 - -// It seems that on SuSE 9.1 (x86) something in messes up stuff -// 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 -#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 +/* --- !!! --- EXTERNAL HEADERS end --- !!! --- */ #if VG_WORDSIZE == 8 @@ -73,7 +74,7 @@ static void check_mmap(SysRes res, Addr base, SizeT len) { if (res.isError) { VG_(printf)("valgrind: mmap(0x%llx, %lld) failed in UME with error %d.\n", - (ULong)base, (Long)len, res.val); + (ULong)base, (Long)len, res.err); VG_(exit)(1); } } @@ -119,9 +120,9 @@ struct elfinfo *readelf(Int fd, const char *filename) e->fd = fd; sres = VG_(pread)(fd, &e->e, sizeof(e->e), 0); - if (sres.isError || sres.val != sizeof(e->e)) { + if (sres.isError || sres.res != sizeof(e->e)) { VG_(printf)("valgrind: %s: can't read ELF header: %s\n", - filename, VG_(strerror)(sres.val)); + filename, VG_(strerror)(sres.err)); goto bad; } @@ -159,9 +160,9 @@ struct elfinfo *readelf(Int fd, const char *filename) vg_assert(e->p); sres = VG_(pread)(fd, e->p, phsz, e->e.e_phoff); - if (sres.isError || sres.val != phsz) { + if (sres.isError || sres.res != phsz) { VG_(printf)("valgrind: can't read phdr: %s\n", - VG_(strerror)(sres.val)); + VG_(strerror)(sres.err)); VG_(free)(e->p); goto bad; } @@ -384,7 +385,7 @@ static Int load_ELF(Int fd, const HChar* name, /*MOD*/ExeInfo* info) VG_(printf)("valgrind: m_ume.c: can't open interpreter\n"); VG_(exit)(1); } - intfd = sres.val; + intfd = sres.res; interp = readelf(intfd, buf); if (interp == NULL) { @@ -573,7 +574,7 @@ static Int load_script(Int fd, const HChar* name, ExeInfo* info) VG_(close)(fd); return VKI_EACCES; } else { - len = res.val; + len = res.res; } vg_assert('#' == hdr[0] && '!' == hdr[1]); @@ -641,7 +642,7 @@ SysRes VG_(pre_exec_check)(const HChar* exe_name, Int* out_fd) if (res.isError) { return res; } - fd = res.val; + fd = res.res; // Check we have execute permissions ret = VG_(check_executable)((HChar*)exe_name); @@ -655,11 +656,11 @@ SysRes VG_(pre_exec_check)(const HChar* exe_name, Int* out_fd) bufsz = fsz; res = VG_(pread)(fd, buf, bufsz, 0); - if (res.isError || res.val != bufsz) { + if (res.isError || res.res != bufsz) { VG_(close)(fd); return VG_(mk_SysRes_Error)(VKI_EACCES); } - bufsz = res.val; + bufsz = res.res; if (match_ELF(buf, bufsz)) { res = VG_(mk_SysRes_Success)(VG_EXE_FORMAT_ELF); @@ -692,9 +693,9 @@ static Int do_exec_inner(const HChar *exe, ExeInfo* info) res = VG_(pre_exec_check)(exe, &fd); if (res.isError) - return res.val; + return res.err; - switch (res.val) { + switch (res.res) { case VG_EXE_FORMAT_ELF: ret = load_ELF (fd, exe, info); break; case VG_EXE_FORMAT_SCRIPT: ret = load_script(fd, exe, info); break; default: @@ -712,7 +713,7 @@ static Bool is_hash_bang_file(Char* f) SysRes res = VG_(open)(f, VKI_O_RDONLY, 0); if (!res.isError) { Char buf[3] = {0,0,0}; - Int fd = res.val; + Int fd = res.res; Int n = VG_(read)(fd, buf, 2); if (n == 2 && VG_STREQ("#!", buf)) return True; @@ -728,7 +729,7 @@ static Bool is_binary_file(Char* f) SysRes res = VG_(open)(f, VKI_O_RDONLY, 0); if (!res.isError) { UChar buf[80]; - Int fd = res.val; + Int fd = res.res; Int n = VG_(read)(fd, buf, 80); Int i; for (i = 0; i < n; i++) { @@ -833,6 +834,8 @@ Int VG_(do_exec)(const HChar* exe_name, ExeInfo* info) return ret; } +#endif /* defined(VGO_linux) */ + /*--------------------------------------------------------------------*/ /*--- end ---*/ /*--------------------------------------------------------------------*/ diff --git a/coregrind/pub_core_ume.h b/coregrind/pub_core_ume.h index 1b637561d7..5d1546401e 100644 --- a/coregrind/pub_core_ume.h +++ b/coregrind/pub_core_ume.h @@ -33,41 +33,9 @@ //-------------------------------------------------------------------- // PURPOSE: This module implements user-mode execve, ie. program loading -// and exec'ing. It is shared between stage1 and stage2. +// and exec'ing. //-------------------------------------------------------------------- -#include -#include - -/*------------------------------------------------------------*/ -/*--- 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 -//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 not -//zz (eg) stack - apparently_harmless_looking_small_offset. Basically -//zz because the code at 'dst' might be wanting to scan the area above -//zz 'stack' (viz, the auxv array), and putting spurious words on the -//zz stack confuses it. -//zz -//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 ---*/ /*------------------------------------------------------------*/