mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-07 12:44:45 +00:00
It compiles, but aborts immediately if you try to run it.
I didn't include ldt.c; I'm not sure how the LDT is used on AMD64. It can be
added later if necessary.
While doing this, did some 64-bit cleanness fixes:
- Added necessary intermediate casts to ULong to avoid warnings when converting
ThreadId to void* and vice versa, in vg_scheduler.c.
- Fixed VALGRIND_NON_SIMD_CALL[0123] to use 'long' as the return type.
- Fixed VALGRIND_PRINTF{,BACKTRACE} to use unsigned longs instead of unsigned
ints, as needed.
- Converted some offsets in vg_symtab2.h from "Int" to "OffT".
- Made strlen, strncat, etc, use SizeT instead of 'unsigned int' for the length
parameter.
- Couple of other minor things.
I had to insert some "#ifdef __amd64__" and "#ifndef __amd64__" guards in
places. In particular, in vg_mylibc.c, some of our syscall wrappers aren't
appropriate for AMD64 because the syscall numbering is a bit different in
places. This difference will have to be abstracted out somehow.
Also rewrote the sys_fcntl and sys_fcntl64 wrappers, as required for AMD64.
Also moved the ipc wrapper into x86, since it's not applicable for
AMD64. However, it is applicable (I think) for ARM, so it would be nice
to work out a way to share syscall wrappers between some, but not all,
archs. Hmm. Also now using the real IPC constants rather than magic
numbers in the wrapper.
Other non-AMD64-related fixes:
- ARM: fixed syscall table by accounting for the fact that syscall
numbers don't start at 0, but rather at 0x900000.
- Converted a few places to use ThreadId instead of 'int' or 'Int' for
thread IDs.
- Added both AMD64 and ARM (which I'd forgotten) entries to valgrind.spec.in.
- Tweaked comments in various places.
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@3136
110 lines
4.3 KiB
C
110 lines
4.3 KiB
C
|
|
/*--------------------------------------------------------------------*/
|
|
/*--- Platform-specific stuff for the core. ---*/
|
|
/*--- amd64-linux/core_platform.h ---*/
|
|
/*--------------------------------------------------------------------*/
|
|
|
|
/*
|
|
This file is part of Valgrind, an extensible x86 protected-mode
|
|
emulator for monitoring program execution on x86-Unixes.
|
|
|
|
Copyright (C) 2000-2004 Nicholas Nethercote
|
|
njn25@cam.ac.uk
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU General Public License as
|
|
published by the Free Software Foundation; either version 2 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
|
02111-1307, USA.
|
|
|
|
The GNU General Public License is contained in the file COPYING.
|
|
*/
|
|
|
|
#ifndef __AMD64_LINUX_CORE_PLATFORM_H
|
|
#define __AMD64_LINUX_CORE_PLATFORM_H
|
|
|
|
//#include "core_platform_asm.h" // platform-specific asm stuff
|
|
//#include "platform_arch.h" // platform-specific tool stuff
|
|
|
|
/* ---------------------------------------------------------------------
|
|
Dealing with registers
|
|
------------------------------------------------------------------ */
|
|
|
|
// Accessors for the ThreadArchState
|
|
#define PLATFORM_SYSCALL_NUM guest_RAX
|
|
#define PLATFORM_SYSCALL_ARG1 guest_RDI
|
|
#define PLATFORM_SYSCALL_ARG2 guest_RSI
|
|
#define PLATFORM_SYSCALL_ARG3 guest_RDX
|
|
#define PLATFORM_SYSCALL_ARG4 guest_R10
|
|
#define PLATFORM_SYSCALL_ARG5 guest_R8
|
|
#define PLATFORM_SYSCALL_ARG6 guest_R9
|
|
#define PLATFORM_SYSCALL_RET guest_RAX
|
|
|
|
// Setting a syscall result
|
|
#define PLATFORM_SET_SYSCALL_RESULT(regs, val) \
|
|
((regs).vex.guest_RAX = (val))
|
|
|
|
// Setting thread regs and shadow regs from within the core
|
|
#define SET_SYSCALL_RETVAL(zztid, zzval) \
|
|
SET_THREAD_REG(zztid, zzval, SYSCALL_RET, post_reg_write, \
|
|
Vg_CoreSysCall, zztid, O_SYSCALL_RET, sizeof(UWord))
|
|
|
|
/* ---------------------------------------------------------------------
|
|
Exports of vg_ldt.c
|
|
------------------------------------------------------------------ */
|
|
|
|
// XXX: eventually all these should be x86-private, and not visible to the
|
|
// core (except maybe do_useseg()?)
|
|
|
|
#if 0
|
|
/* Simulate the modify_ldt syscall. */
|
|
extern Int VG_(sys_modify_ldt) ( ThreadId tid,
|
|
Int func, void* ptr, UInt bytecount );
|
|
|
|
/* Simulate the {get,set}_thread_area syscalls. */
|
|
extern Int VG_(sys_set_thread_area) ( ThreadId tid,
|
|
vki_modify_ldt_t* info );
|
|
extern Int VG_(sys_get_thread_area) ( ThreadId tid,
|
|
vki_modify_ldt_t* info );
|
|
|
|
/* Called from generated code. Given a segment selector and a virtual
|
|
address, return a linear address, and do limit checks too. */
|
|
extern Addr VG_(do_useseg) ( UInt seg_selector, Addr virtual_addr );
|
|
#endif
|
|
|
|
/* ---------------------------------------------------------------------
|
|
ucontext stuff
|
|
------------------------------------------------------------------ */
|
|
|
|
#define UCONTEXT_INSTR_PTR(uc) ((uc)->uc_mcontext.rip)
|
|
#define UCONTEXT_STACK_PTR(uc) ((uc)->uc_mcontext.rsp)
|
|
#define UCONTEXT_FRAME_PTR(uc) ((uc)->uc_mcontext.rbp)
|
|
#define UCONTEXT_SYSCALL_NUM(uc) ((uc)->uc_mcontext.rax)
|
|
|
|
/* ---------------------------------------------------------------------
|
|
mmap() stuff
|
|
------------------------------------------------------------------ */
|
|
|
|
#define PLATFORM_DO_MMAP(ret, start, length, prot, flags, fd, offset) { \
|
|
I_die_here; \
|
|
} while (0)
|
|
|
|
#define PLATFORM_GET_MMAP_ARGS(tst, a1, a2, a3, a4, a5, a6) do {\
|
|
I_die_here; \
|
|
} while (0)
|
|
|
|
#endif // __AMD64_LINUX_CORE_PLATFORM_H
|
|
|
|
/*--------------------------------------------------------------------*/
|
|
/*--- end ---*/
|
|
/*--------------------------------------------------------------------*/
|