njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 1 | |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 2 | /*--------------------------------------------------------------------*/ |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 3 | /*--- Client-space code for the core. vg_preloaded.c ---*/ |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 4 | /*--------------------------------------------------------------------*/ |
| 5 | |
| 6 | /* |
| 7 | This file is part of Valgrind, an extensible x86 protected-mode |
| 8 | emulator for monitoring program execution on x86-Unixes. |
| 9 | |
njn | 5361242 | 2005-03-12 16:22:54 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2005 Julian Seward |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 11 | jseward@acm.org |
| 12 | |
| 13 | This program is free software; you can redistribute it and/or |
| 14 | modify it under the terms of the GNU General Public License as |
| 15 | published by the Free Software Foundation; either version 2 of the |
| 16 | License, or (at your option) any later version. |
| 17 | |
| 18 | This program is distributed in the hope that it will be useful, but |
| 19 | WITHOUT ANY WARRANTY; without even the implied warranty of |
| 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 21 | General Public License for more details. |
| 22 | |
| 23 | You should have received a copy of the GNU General Public License |
| 24 | along with this program; if not, write to the Free Software |
| 25 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 26 | 02111-1307, USA. |
| 27 | |
| 28 | The GNU General Public License is contained in the file COPYING. |
| 29 | */ |
| 30 | |
| 31 | |
| 32 | /* --------------------------------------------------------------------- |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 33 | ALL THE CODE IN THIS FILE RUNS ON THE SIMULATED CPU. |
| 34 | |
| 35 | These functions are not called directly - they're the targets of code |
| 36 | redirection or load notifications (see pub_core_redir.h for info). |
| 37 | They're named weirdly so that the intercept code can find them when the |
| 38 | shared object is initially loaded. |
| 39 | |
| 40 | Note that this filename has the "vg_" prefix because it can appear |
| 41 | in stack traces, and the "vg_" makes it a little clearer that it |
| 42 | originates from Valgrind. |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 43 | ------------------------------------------------------------------ */ |
| 44 | |
| 45 | #include "valgrind.h" |
njn | 1277109 | 2005-06-18 02:18:04 +0000 | [diff] [blame] | 46 | #include "coregrind.h" |
| 47 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame^] | 48 | #include "pub_core_basics.h" |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 49 | #include "pub_core_debuginfo.h" // needed for pub_core_redir.h :( |
| 50 | #include "pub_core_redir.h" |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 51 | |
| 52 | /* --------------------------------------------------------------------- |
| 53 | Hook for running __libc_freeres once the program exits. |
| 54 | ------------------------------------------------------------------ */ |
| 55 | |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 56 | void VG_NOTIFY_ON_LOAD(freeres)( void ); |
| 57 | void VG_NOTIFY_ON_LOAD(freeres)( void ) |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 58 | { |
| 59 | int res; |
| 60 | #ifndef __UCLIBC__ |
| 61 | extern void __libc_freeres(void); |
| 62 | __libc_freeres(); |
| 63 | #endif |
| 64 | VALGRIND_MAGIC_SEQUENCE(res, 0 /* default */, |
| 65 | VG_USERREQ__LIBC_FREERES_DONE, 0, 0, 0, 0); |
| 66 | /*NOTREACHED*/ |
| 67 | *(int *)0 = 'x'; |
| 68 | } |
| 69 | |
| 70 | /*--------------------------------------------------------------------*/ |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 71 | /*--- end ---*/ |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 72 | /*--------------------------------------------------------------------*/ |
| 73 | |