blob: b6254bc83c10014f09d54f8bf543a2489898cfd9 [file] [log] [blame]
njn16eeb4e2005-06-16 03:56:58 +00001
sewardjcbdddcf2005-03-10 23:23:45 +00002/*--------------------------------------------------------------------*/
njn16eeb4e2005-06-16 03:56:58 +00003/*--- Client-space code for the core. vg_preloaded.c ---*/
sewardjcbdddcf2005-03-10 23:23:45 +00004/*--------------------------------------------------------------------*/
5
6/*
njnc0ae7052005-08-25 22:55:19 +00007 This file is part of Valgrind, a dynamic binary instrumentation
8 framework.
sewardjcbdddcf2005-03-10 23:23:45 +00009
njn53612422005-03-12 16:22:54 +000010 Copyright (C) 2000-2005 Julian Seward
sewardjcbdddcf2005-03-10 23:23:45 +000011 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/* ---------------------------------------------------------------------
njn16eeb4e2005-06-16 03:56:58 +000033 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.
sewardjcbdddcf2005-03-10 23:23:45 +000043 ------------------------------------------------------------------ */
44
45#include "valgrind.h"
njn12771092005-06-18 02:18:04 +000046#include "coregrind.h"
47
njnc7561b92005-06-19 01:24:32 +000048#include "pub_core_basics.h"
njn24a6efb2005-06-20 03:36:51 +000049#include "pub_core_debuginfo.h" // Needed for pub_core_redir.h
50#include "pub_core_redir.h" // For VG_NOTIFY_ON_LOAD
sewardjcbdddcf2005-03-10 23:23:45 +000051
52/* ---------------------------------------------------------------------
53 Hook for running __libc_freeres once the program exits.
54 ------------------------------------------------------------------ */
55
njn16eeb4e2005-06-16 03:56:58 +000056void VG_NOTIFY_ON_LOAD(freeres)( void );
57void VG_NOTIFY_ON_LOAD(freeres)( void )
sewardjcbdddcf2005-03-10 23:23:45 +000058{
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/*--------------------------------------------------------------------*/
njn16eeb4e2005-06-16 03:56:58 +000071/*--- end ---*/
sewardjcbdddcf2005-03-10 23:23:45 +000072/*--------------------------------------------------------------------*/
73