2005-04-08 00:51:01 +02:00
|
|
|
/* Implementation header for mudflap runtime library.
|
|
|
|
Mudflap: narrow-pointer bounds-checking by tree rewriting.
|
2013-02-03 18:48:05 +01:00
|
|
|
Copyright (C) 2002-2013 Free Software Foundation, Inc.
|
2005-04-08 00:51:01 +02:00
|
|
|
Contributed by Frank Ch. Eigler <fche@redhat.com>
|
|
|
|
and Graydon Hoare <graydon@redhat.com>
|
|
|
|
|
|
|
|
This file is part of GCC.
|
|
|
|
|
|
|
|
GCC 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
|
2009-04-09 17:00:19 +02:00
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
2005-04-08 00:51:01 +02:00
|
|
|
version.
|
|
|
|
|
|
|
|
GCC 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.
|
|
|
|
|
2009-04-09 17:00:19 +02:00
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2005-04-08 00:51:01 +02:00
|
|
|
|
2004-05-13 08:41:07 +02:00
|
|
|
/* Public libmudflap declarations -*- C -*- */
|
|
|
|
|
|
|
|
#ifndef MF_RUNTIME_H
|
|
|
|
#define MF_RUNTIME_H
|
|
|
|
|
2005-01-02 23:24:50 +01:00
|
|
|
typedef void *__mf_ptr_t;
|
|
|
|
typedef unsigned int __mf_uintptr_t __attribute__ ((__mode__ (__pointer__)));
|
|
|
|
typedef __SIZE_TYPE__ __mf_size_t;
|
2004-05-13 08:41:07 +02:00
|
|
|
|
2004-07-05 20:12:47 +02:00
|
|
|
/* Global declarations used by instrumentation. When _MUDFLAP is
|
|
|
|
defined, these have been auto-declared by the compiler and we
|
|
|
|
should not declare them again (ideally we *would* declare them
|
|
|
|
again, to verify that the compiler's declarations match the
|
|
|
|
library's, but the C++ front end has no mechanism for allowing
|
|
|
|
the re-definition of a structure type). */
|
|
|
|
#ifndef _MUDFLAP
|
2005-01-02 23:24:50 +01:00
|
|
|
struct __mf_cache { __mf_uintptr_t low; __mf_uintptr_t high; };
|
2004-05-13 08:41:07 +02:00
|
|
|
extern struct __mf_cache __mf_lookup_cache [];
|
2005-01-02 23:24:50 +01:00
|
|
|
extern __mf_uintptr_t __mf_lc_mask;
|
2004-05-13 08:41:07 +02:00
|
|
|
extern unsigned char __mf_lc_shift;
|
2004-07-05 20:12:47 +02:00
|
|
|
#endif
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
/* Multithreading support. */
|
|
|
|
#ifdef _MUDFLAPTH
|
|
|
|
/* extern pthread_mutex_t __mf_biglock; */
|
2006-06-21 18:35:27 +02:00
|
|
|
#ifndef _REENTRANT
|
2004-05-13 08:41:07 +02:00
|
|
|
#define _REENTRANT
|
2006-06-21 18:35:27 +02:00
|
|
|
#endif
|
|
|
|
#ifndef _THREAD_SAFE
|
2004-05-13 08:41:07 +02:00
|
|
|
#define _THREAD_SAFE
|
|
|
|
#endif
|
2006-06-21 18:35:27 +02:00
|
|
|
#endif
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
/* Codes to describe the type of access to check: __mf_check arg 3 */
|
|
|
|
|
|
|
|
#define __MF_CHECK_READ 0
|
|
|
|
#define __MF_CHECK_WRITE 1
|
|
|
|
|
|
|
|
|
|
|
|
/* Codes to describe a region of memory being registered: __mf_*register arg 3 */
|
|
|
|
|
|
|
|
#define __MF_TYPE_NOACCESS 0
|
|
|
|
#define __MF_TYPE_HEAP 1
|
|
|
|
#define __MF_TYPE_HEAP_I 2
|
|
|
|
#define __MF_TYPE_STACK 3
|
|
|
|
#define __MF_TYPE_STATIC 4
|
|
|
|
#define __MF_TYPE_GUESS 5
|
|
|
|
|
|
|
|
|
|
|
|
/* The public mudflap API */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2005-01-02 23:24:50 +01:00
|
|
|
extern void __mf_check (void *ptr, __mf_size_t sz, int type, const char *location)
|
2004-05-13 08:41:07 +02:00
|
|
|
__attribute((nothrow));
|
2005-03-22 03:14:33 +01:00
|
|
|
extern void __mf_register (void *ptr, __mf_size_t sz, int type, const char *name)
|
2004-05-13 08:41:07 +02:00
|
|
|
__attribute((nothrow));
|
2005-01-02 23:24:50 +01:00
|
|
|
extern void __mf_unregister (void *ptr, __mf_size_t sz, int type)
|
2004-06-24 23:12:18 +02:00
|
|
|
__attribute((nothrow));
|
2005-01-02 23:24:50 +01:00
|
|
|
extern unsigned __mf_watch (void *ptr, __mf_size_t sz);
|
|
|
|
extern unsigned __mf_unwatch (void *ptr, __mf_size_t sz);
|
2004-05-13 08:41:07 +02:00
|
|
|
extern void __mf_report ();
|
|
|
|
extern int __mf_set_options (const char *opts);
|
|
|
|
|
|
|
|
|
|
|
|
/* Redirect some standard library functions to libmudflap. These are
|
|
|
|
done by simple #define rather than linker wrapping, since only
|
|
|
|
instrumented modules are meant to be affected. */
|
|
|
|
|
2005-03-22 03:14:33 +01:00
|
|
|
#ifdef _MUDFLAP
|
|
|
|
#pragma redefine_extname memcpy __mfwrap_memcpy
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname memmove __mfwrap_memmove
|
2005-03-22 03:14:33 +01:00
|
|
|
#pragma redefine_extname memset __mfwrap_memset
|
|
|
|
#pragma redefine_extname memcmp __mfwrap_memcmp
|
|
|
|
#pragma redefine_extname memchr __mfwrap_memchr
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname memrchr __mfwrap_memrchr
|
2005-03-22 03:14:33 +01:00
|
|
|
#pragma redefine_extname strcpy __mfwrap_strcpy
|
|
|
|
#pragma redefine_extname strncpy __mfwrap_strncpy
|
|
|
|
#pragma redefine_extname strcat __mfwrap_strcat
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname strncat __mfwrap_strncat
|
2005-03-22 03:14:33 +01:00
|
|
|
#pragma redefine_extname strcmp __mfwrap_strcmp
|
|
|
|
#pragma redefine_extname strcasecmp __mfwrap_strcasecmp
|
|
|
|
#pragma redefine_extname strncmp __mfwrap_strncmp
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname strncasecmp __mfwrap_strncasecmp
|
2005-03-22 03:14:33 +01:00
|
|
|
#pragma redefine_extname strdup __mfwrap_strdup
|
|
|
|
#pragma redefine_extname strndup __mfwrap_strndup
|
|
|
|
#pragma redefine_extname strchr __mfwrap_strchr
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname strrchr __mfwrap_strrchr
|
2005-03-22 03:14:33 +01:00
|
|
|
#pragma redefine_extname strstr __mfwrap_strstr
|
|
|
|
#pragma redefine_extname memmem __mfwrap_memmem
|
|
|
|
#pragma redefine_extname strlen __mfwrap_strlen
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname strnlen __mfwrap_strnlen
|
2005-03-22 03:14:33 +01:00
|
|
|
#pragma redefine_extname bzero __mfwrap_bzero
|
|
|
|
#pragma redefine_extname bcopy __mfwrap_bcopy
|
|
|
|
#pragma redefine_extname bcmp __mfwrap_bcmp
|
|
|
|
#pragma redefine_extname index __mfwrap_index
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname rindex __mfwrap_rindex
|
|
|
|
#pragma redefine_extname asctime __mfwrap_asctime
|
|
|
|
#pragma redefine_extname ctime __mfwrap_ctime
|
|
|
|
#pragma redefine_extname gmtime __mfwrap_gmtime
|
|
|
|
#pragma redefine_extname localtime __mfwrap_localtime
|
|
|
|
#pragma redefine_extname time __mfwrap_time
|
|
|
|
#pragma redefine_extname strerror __mfwrap_strerror
|
|
|
|
#pragma redefine_extname fopen __mfwrap_fopen
|
configure.ac: Check for more headers, functions.
2004-10-12 Frank Ch. Eigler <fche@redhat.com>
* configure.ac: Check for more headers, functions.
* mf-hooks2.c (mkbuffer, unmkbuffer): New helper functions for
tracking overridden FILE buffers.
(fopen, setvbuf): New/revised hook functions for buffer overriding.
(setbuf,setlinebuf,fdopen,freopen,fopen64,freopen64,fclose): Ditto.
(fflush): Accept given NULL stream (means "all streams").
* mf-runtime.h.in:
* mf-runtime.c (__mfu_check): Accept accesses that span adjacent
HEAP/GUESS objects.
(LOOKUP_CACHE_SIZE_MAX): Raise to 64K entries tentatively.
(__mf_adapt_cache): Use them all.
* testsuite/libmudflap.c/pass35-frag.c: Update warning message.
* testsuite/libmudflap.c++/ctors.exp: Ditto.
* testsuite/libmudflap.c/{pass51,pass52}-frag.c: New tests.
* configure, config.h.in: Regenerated.
From-SVN: r88996
2004-10-13 20:27:16 +02:00
|
|
|
#pragma redefine_extname fdopen __mfwrap_fdopen
|
|
|
|
#pragma redefine_extname freopen __mfwrap_freopen
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname fclose __mfwrap_fclose
|
|
|
|
#pragma redefine_extname fread __mfwrap_fread
|
|
|
|
#pragma redefine_extname fwrite __mfwrap_fwrite
|
|
|
|
#pragma redefine_extname fgetc __mfwrap_fgetc
|
|
|
|
#pragma redefine_extname fgets __mfwrap_fgets
|
|
|
|
#pragma redefine_extname getc __mfwrap_getc
|
|
|
|
#pragma redefine_extname gets __mfwrap_gets
|
|
|
|
#pragma redefine_extname ungetc __mfwrap_ungetc
|
|
|
|
#pragma redefine_extname fputc __mfwrap_fputc
|
|
|
|
#pragma redefine_extname fputs __mfwrap_fputs
|
|
|
|
#pragma redefine_extname putc __mfwrap_putc
|
|
|
|
#pragma redefine_extname puts __mfwrap_puts
|
|
|
|
#pragma redefine_extname clearerr __mfwrap_clearerr
|
|
|
|
#pragma redefine_extname feof __mfwrap_feof
|
|
|
|
#pragma redefine_extname ferror __mfwrap_ferror
|
|
|
|
#pragma redefine_extname fileno __mfwrap_fileno
|
|
|
|
#pragma redefine_extname printf __mfwrap_printf
|
|
|
|
#pragma redefine_extname fprintf __mfwrap_fprintf
|
|
|
|
#pragma redefine_extname sprintf __mfwrap_sprintf
|
|
|
|
#pragma redefine_extname snprintf __mfwrap_snprintf
|
|
|
|
#pragma redefine_extname vprintf __mfwrap_vprintf
|
|
|
|
#pragma redefine_extname vfprintf __mfwrap_vfprintf
|
|
|
|
#pragma redefine_extname vsprintf __mfwrap_vsprintf
|
|
|
|
#pragma redefine_extname vsnprintf __mfwrap_vsnprintf
|
|
|
|
#pragma redefine_extname access __mfwrap_access
|
|
|
|
#pragma redefine_extname remove __mfwrap_remove
|
|
|
|
#pragma redefine_extname fflush __mfwrap_fflush
|
|
|
|
#pragma redefine_extname fseek __mfwrap_fseek
|
|
|
|
#pragma redefine_extname ftell __mfwrap_ftell
|
|
|
|
#pragma redefine_extname rewind __mfwrap_rewind
|
|
|
|
#pragma redefine_extname fgetpos __mfwrap_fgetpos
|
|
|
|
#pragma redefine_extname fsetpos __mfwrap_fsetpos
|
|
|
|
#pragma redefine_extname stat __mfwrap_stat
|
|
|
|
#pragma redefine_extname fstat __mfwrap_fstat
|
|
|
|
#pragma redefine_extname lstat __mfwrap_lstat
|
|
|
|
#pragma redefine_extname mkfifo __mfwrap_mkfifo
|
|
|
|
#pragma redefine_extname setvbuf __mfwrap_setvbuf
|
|
|
|
#pragma redefine_extname setbuf __mfwrap_setbuf
|
configure.ac: Check for more headers, functions.
2004-10-12 Frank Ch. Eigler <fche@redhat.com>
* configure.ac: Check for more headers, functions.
* mf-hooks2.c (mkbuffer, unmkbuffer): New helper functions for
tracking overridden FILE buffers.
(fopen, setvbuf): New/revised hook functions for buffer overriding.
(setbuf,setlinebuf,fdopen,freopen,fopen64,freopen64,fclose): Ditto.
(fflush): Accept given NULL stream (means "all streams").
* mf-runtime.h.in:
* mf-runtime.c (__mfu_check): Accept accesses that span adjacent
HEAP/GUESS objects.
(LOOKUP_CACHE_SIZE_MAX): Raise to 64K entries tentatively.
(__mf_adapt_cache): Use them all.
* testsuite/libmudflap.c/pass35-frag.c: Update warning message.
* testsuite/libmudflap.c++/ctors.exp: Ditto.
* testsuite/libmudflap.c/{pass51,pass52}-frag.c: New tests.
* configure, config.h.in: Regenerated.
From-SVN: r88996
2004-10-13 20:27:16 +02:00
|
|
|
#pragma redefine_extname setbuffer __mfwrap_setbuffer
|
|
|
|
#pragma redefine_extname setlinebuf __mfwrap_setlinebuf
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname opendir __mfwrap_opendir
|
|
|
|
#pragma redefine_extname closedir __mfwrap_closedir
|
|
|
|
#pragma redefine_extname readdir __mfwrap_readdir
|
|
|
|
#pragma redefine_extname recv __mfwrap_recv
|
|
|
|
#pragma redefine_extname recvfrom __mfwrap_recvfrom
|
|
|
|
#pragma redefine_extname recvmsg __mfwrap_recvmsg
|
|
|
|
#pragma redefine_extname send __mfwrap_send
|
|
|
|
#pragma redefine_extname sendto __mfwrap_sendto
|
|
|
|
#pragma redefine_extname sendmsg __mfwrap_sendmsg
|
|
|
|
#pragma redefine_extname setsockopt __mfwrap_setsockopt
|
|
|
|
#pragma redefine_extname getsockopt __mfwrap_getsockopt
|
|
|
|
#pragma redefine_extname accept __mfwrap_accept
|
|
|
|
#pragma redefine_extname bind __mfwrap_bind
|
|
|
|
#pragma redefine_extname connect __mfwrap_connect
|
|
|
|
#pragma redefine_extname gethostname __mfwrap_gethostname
|
|
|
|
#pragma redefine_extname sethostname __mfwrap_sethostname
|
|
|
|
#pragma redefine_extname gethostbyname __mfwrap_gethostbyname
|
|
|
|
#pragma redefine_extname wait __mfwrap_wait
|
|
|
|
#pragma redefine_extname waitpid __mfwrap_waitpid
|
|
|
|
#pragma redefine_extname popen __mfwrap_popen
|
|
|
|
#pragma redefine_extname pclose __mfwrap_pclose
|
|
|
|
#pragma redefine_extname execve __mfwrap_execve
|
|
|
|
#pragma redefine_extname execv __mfwrap_execv
|
|
|
|
#pragma redefine_extname execvp __mfwrap_execvp
|
|
|
|
#pragma redefine_extname system __mfwrap_system
|
|
|
|
#pragma redefine_extname dlopen __mfwrap_dlopen
|
|
|
|
#pragma redefine_extname dlerror __mfwrap_dlerror
|
|
|
|
#pragma redefine_extname dlsym __mfwrap_dlsym
|
|
|
|
#pragma redefine_extname dlclose __mfwrap_dlclose
|
|
|
|
#pragma redefine_extname fopen64 __mfwrap_fopen64
|
configure.ac: Check for more headers, functions.
2004-10-12 Frank Ch. Eigler <fche@redhat.com>
* configure.ac: Check for more headers, functions.
* mf-hooks2.c (mkbuffer, unmkbuffer): New helper functions for
tracking overridden FILE buffers.
(fopen, setvbuf): New/revised hook functions for buffer overriding.
(setbuf,setlinebuf,fdopen,freopen,fopen64,freopen64,fclose): Ditto.
(fflush): Accept given NULL stream (means "all streams").
* mf-runtime.h.in:
* mf-runtime.c (__mfu_check): Accept accesses that span adjacent
HEAP/GUESS objects.
(LOOKUP_CACHE_SIZE_MAX): Raise to 64K entries tentatively.
(__mf_adapt_cache): Use them all.
* testsuite/libmudflap.c/pass35-frag.c: Update warning message.
* testsuite/libmudflap.c++/ctors.exp: Ditto.
* testsuite/libmudflap.c/{pass51,pass52}-frag.c: New tests.
* configure, config.h.in: Regenerated.
From-SVN: r88996
2004-10-13 20:27:16 +02:00
|
|
|
#pragma redefine_extname freopen64 __mfwrap_freopen64
|
2004-05-13 08:41:07 +02:00
|
|
|
#pragma redefine_extname stat64 __mfwrap_stat64
|
|
|
|
#pragma redefine_extname fseeko64 __mfwrap_fseeko64
|
|
|
|
#pragma redefine_extname ftello64 __mfwrap_ftello64
|
|
|
|
#pragma redefine_extname semop __mfwrap_semop
|
|
|
|
#pragma redefine_extname semctl __mfwrap_semctl
|
|
|
|
#pragma redefine_extname shmctl __mfwrap_shmctl
|
|
|
|
#pragma redefine_extname shmat __mfwrap_shmat
|
|
|
|
#pragma redefine_extname shmdt __mfwrap_shmdt
|
2004-06-09 21:04:56 +02:00
|
|
|
#pragma redefine_extname __ctype_b_loc __mfwrap___ctype_b_loc
|
|
|
|
#pragma redefine_extname __ctype_toupper_loc __mfwrap___ctype_toupper_loc
|
|
|
|
#pragma redefine_extname __ctype_tolower_loc __mfwrap___ctype_tolower_loc
|
configure.ac: Look for pwd.h, grp.h, netdb.h headers and functions.
2004-09-07 Frank Ch. Eigler <fche@redhat.com>
* configure.ac: Look for pwd.h, grp.h, netdb.h headers and functions.
* mf-hooks2.c (strerror): Unregister previous string returned by
previous strerror.
(getlogin,cuserid,getpwnam,getpwuid,getgrnam,getgrgid): New wrappers.
(getservent,getservbyname,getservbyport,gai_strerror): Ditto.
* mf-runtime.h.in: Add redefine_extname pragmas for them all.
* mf-runtime.c (__mf_describe_object): Clarify object life status.
* testsuite/libmudflap.c/pass48-frag.c, pass49-frag.c, fail32-frag.c:
New tests.
* configure, config.h.in: Regenerated.
From-SVN: r87160
2004-09-07 23:52:52 +02:00
|
|
|
#pragma redefine_extname getlogin __mfwrap_getlogin
|
|
|
|
#pragma redefine_extname cuserid __mfwrap_cuserid
|
|
|
|
#pragma redefine_extname getpwnam __mfwrap_getpwnam
|
|
|
|
#pragma redefine_extname getpwuid __mfwrap_getpwuid
|
|
|
|
#pragma redefine_extname getgrnam __mfwrap_getgrnam
|
|
|
|
#pragma redefine_extname getgrgid __mfwrap_getgrgid
|
|
|
|
#pragma redefine_extname getservent __mfwrap_getservent
|
|
|
|
#pragma redefine_extname getservbyname __mfwrap_getservbyname
|
|
|
|
#pragma redefine_extname getservbyport __mfwrap_getservbyport
|
|
|
|
#pragma redefine_extname gai_strerror __mfwrap_gai_strerror
|
2004-10-04 19:33:54 +02:00
|
|
|
#pragma redefine_extname getmntent __mfwrap_getmntent
|
|
|
|
#pragma redefine_extname inet_ntoa __mfwrap_inet_ntoa
|
|
|
|
#pragma redefine_extname getprotoent __mfwrap_getprotoent
|
|
|
|
#pragma redefine_extname getprotobyname __mfwrap_getprotobyname
|
|
|
|
#pragma redefine_extname getprotobynumber __mfwrap_getprotobynumber
|
2004-05-13 08:41:07 +02:00
|
|
|
|
|
|
|
/* Disable glibc macros. */
|
|
|
|
#define __NO_STRING_INLINES
|
|
|
|
|
|
|
|
#endif /* _MUDFLAP */
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* MF_RUNTIME_H */
|