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 | /* |
njn | c0ae705 | 2005-08-25 22:55:19 +0000 | [diff] [blame] | 7 | This file is part of Valgrind, a dynamic binary instrumentation |
| 8 | framework. |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 9 | |
sewardj | 4d474d0 | 2008-02-11 11:34:59 +0000 | [diff] [blame] | 10 | Copyright (C) 2000-2008 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 | |
njn | c7561b9 | 2005-06-19 01:24:32 +0000 | [diff] [blame] | 45 | #include "pub_core_basics.h" |
njn | 93fe3b2 | 2005-12-21 20:22:52 +0000 | [diff] [blame] | 46 | #include "pub_core_clreq.h" |
njn | 24a6efb | 2005-06-20 03:36:51 +0000 | [diff] [blame] | 47 | #include "pub_core_debuginfo.h" // Needed for pub_core_redir.h |
| 48 | #include "pub_core_redir.h" // For VG_NOTIFY_ON_LOAD |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 49 | |
| 50 | /* --------------------------------------------------------------------- |
| 51 | Hook for running __libc_freeres once the program exits. |
| 52 | ------------------------------------------------------------------ */ |
| 53 | |
njn | 16eeb4e | 2005-06-16 03:56:58 +0000 | [diff] [blame] | 54 | void VG_NOTIFY_ON_LOAD(freeres)( void ); |
| 55 | void VG_NOTIFY_ON_LOAD(freeres)( void ) |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 56 | { |
| 57 | int res; |
sewardj | 745fc45 | 2006-10-17 02:03:11 +0000 | [diff] [blame] | 58 | #if !defined(__UCLIBC__) && !defined(VGO_aix5) |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 59 | extern void __libc_freeres(void); |
| 60 | __libc_freeres(); |
| 61 | #endif |
sewardj | 0ec07f3 | 2006-01-12 12:32:32 +0000 | [diff] [blame] | 62 | VALGRIND_DO_CLIENT_REQUEST(res, 0 /* default */, |
sewardj | 9af10a1 | 2006-02-01 14:59:42 +0000 | [diff] [blame] | 63 | VG_USERREQ__LIBC_FREERES_DONE, |
| 64 | 0, 0, 0, 0, 0); |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 65 | /*NOTREACHED*/ |
| 66 | *(int *)0 = 'x'; |
| 67 | } |
| 68 | |
sewardj | eb3603e | 2006-01-24 01:01:17 +0000 | [diff] [blame] | 69 | |
sewardj | cbdddcf | 2005-03-10 23:23:45 +0000 | [diff] [blame] | 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 | /*--------------------------------------------------------------------*/ |