aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Johnstone <geoff.johnstone@googlemail.com>2008-04-05 02:52:29 -0700
committerJosh Triplett <josh@freedesktop.org>2008-04-05 02:52:29 -0700
commit27be02d4055500ab7a3f8607f9daef044375b155 (patch)
tree65a749bbccef0f6b172026226d9773cd089aebb2
parentebed4963196340cf740bbcac3c3ac448a5b03add (diff)
downloadsparse-27be02d4055500ab7a3f8607f9daef044375b155.tar.gz
sparse-27be02d4055500ab7a3f8607f9daef044375b155.tar.xz
sparse-27be02d4055500ab7a3f8607f9daef044375b155.zip
Add builtin functions for use with __FORTIFY_SOURCE
__FORTIFY_SOURCE=2 converts memcpy() into __builtin___memcpy_chk() etc. The patch adds some/all? of the relevant builtin prototypes. Signed-off-by: Geoff Johnstone <geoff.johnstone@googlemail.com>
-rw-r--r--lib.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 8a417eb..75afdb7 100644
--- a/lib.c
+++ b/lib.c
@@ -640,6 +640,22 @@ void declare_builtin_functions(void)
add_pre_buffer("extern long __builtin_alpha_inslh(long, long);\n");
add_pre_buffer("extern long __builtin_alpha_cmpbge(long, long);\n");
add_pre_buffer("extern long __builtin_labs(long);\n");
+
+ /* And some __FORTIFY_SOURCE ones.. */
+ add_pre_buffer ("extern __SIZE_TYPE__ __builtin_object_size(void *, int);\n");
+ add_pre_buffer ("extern void * __builtin___memcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern void * __builtin___memmove_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern void * __builtin___mempcpy_chk(void *, const void *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern void * __builtin___memset_chk(void *, int, __SIZE_TYPE__, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern int __builtin___sprintf_chk(char *, int, __SIZE_TYPE__, const char *, ...);\n");
+ add_pre_buffer ("extern int __builtin___snprintf_chk(char *, __SIZE_TYPE__, int , __SIZE_TYPE__, const char *, ...);\n");
+ add_pre_buffer ("extern char * __builtin___stpcpy_chk(char *, const char *, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern char * __builtin___strcat_chk(char *, const char *, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern char * __builtin___strcpy_chk(char *, const char *, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern char * __builtin___strncat_chk(char *, const char *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern char * __builtin___strncpy_chk(char *, const char *, __SIZE_TYPE__, __SIZE_TYPE__);\n");
+ add_pre_buffer ("extern int __builtin___vsprintf_chk(char *, int, __SIZE_TYPE__, const char *, __builtin_va_list);\n");
+ add_pre_buffer ("extern int __builtin___vsnprintf_chk(char *, __SIZE_TYPE__, int, __SIZE_TYPE__, const char *, __builtin_va_list ap);\n");
}
void create_builtin_stream(void)