add more definitions for __builtin___XXX_chk
authorMatthias Braun <matze@braunis.de>
Tue, 12 Oct 2010 22:17:54 +0000 (22:17 +0000)
committerMatthias Braun <matze@braunis.de>
Tue, 12 Oct 2010 22:17:54 +0000 (22:17 +0000)
[r28113]

builtins.c
builtins.h

index 9c40e08..ef98a9a 100644 (file)
@@ -79,13 +79,19 @@ void create_gnu_builtins(void)
        GNU_BUILTIN(__memcpy_chk,   make_function_type(type_void_ptr, 4, (type_t *[]) { type_void_ptr_restrict, type_const_void_ptr_restrict, type_size_t, type_size_t}, DM_NONE));
        GNU_BUILTIN(memcmp,         make_function_type(type_int, 3, (type_t *[]) { type_const_void_ptr, type_const_void_ptr, type_size_t }, DM_PURE));
        GNU_BUILTIN(memset,         make_function_type(type_void_ptr, 3, (type_t *[]) { type_void_ptr, type_int, type_size_t }, DM_NONE));
+       GNU_BUILTIN(__memset_chk,   make_function_type(type_void_ptr, 4, (type_t *[]) { type_void_ptr, type_int, type_size_t, type_size_t }, DM_NONE));
        GNU_BUILTIN(memmove,        make_function_type(type_void_ptr, 3, (type_t *[]) { type_void_ptr_restrict, type_const_void_ptr_restrict, type_size_t }, DM_NONE));
+       GNU_BUILTIN(__memmove_chk,  make_function_type(type_void_ptr, 4, (type_t *[]) { type_void_ptr_restrict, type_const_void_ptr_restrict, type_size_t, type_size_t }, DM_NONE));
        GNU_BUILTIN(strcat,         make_function_type(type_char_ptr, 2, (type_t *[]) { type_char_ptr_restrict, type_const_char_ptr_restrict }, DM_NONE));
-       GNU_BUILTIN(strcat,         make_function_type(type_char_ptr, 3, (type_t *[]) { type_char_ptr_restrict, type_const_char_ptr_restrict, type_size_t }, DM_NONE));
+       GNU_BUILTIN(__strcat_chk,   make_function_type(type_char_ptr, 3, (type_t *[]) { type_char_ptr_restrict, type_const_char_ptr_restrict, type_size_t }, DM_NONE));
+       GNU_BUILTIN(strncat,        make_function_type(type_char_ptr, 3, (type_t *[]) { type_char_ptr_restrict, type_const_char_ptr_restrict, type_size_t }, DM_NONE));
+       GNU_BUILTIN(__strncat_chk,  make_function_type(type_char_ptr, 4, (type_t *[]) { type_char_ptr_restrict, type_const_char_ptr_restrict, type_size_t, type_size_t }, DM_NONE));
        GNU_BUILTIN(strlen,         make_function_type(type_size_t, 1, (type_t *[]) { type_const_char_ptr }, DM_PURE));
        GNU_BUILTIN(strcmp,         make_function_type(type_int, 2, (type_t *[]) { type_const_char_ptr, type_const_char_ptr }, DM_PURE));
        GNU_BUILTIN(strcpy,         make_function_type(type_char_ptr, 2, (type_t *[]) { type_char_ptr_restrict, type_const_char_ptr_restrict }, DM_NONE));
+       GNU_BUILTIN(__strcpy_chk,   make_function_type(type_char_ptr, 3, (type_t *[]) { type_char_ptr_restrict, type_const_char_ptr_restrict }, DM_NONE));
        GNU_BUILTIN(strncpy,        make_function_type(type_char_ptr, 3, (type_t *[]) { type_char_ptr_restrict, type_char_ptr_restrict, type_size_t }, DM_NONE));
+       GNU_BUILTIN(__strncpy_chk,  make_function_type(type_char_ptr, 4, (type_t *[]) { type_char_ptr_restrict, type_char_ptr_restrict, type_size_t, type_size_t }, DM_NONE));
        GNU_BUILTIN(exit,           make_function_type(type_void, 1, (type_t *[]) { type_int }, DM_NORETURN));
        GNU_BUILTIN(malloc,         make_function_type(type_void_ptr, 1, (type_t *[]) { type_size_t }, DM_MALLOC));
 
@@ -98,22 +104,37 @@ void create_gnu_builtins(void)
 static const char *get_builtin_replacement_name(builtin_kind_t kind)
 {
        switch (kind) {
-       case bk_gnu_builtin_abort:        return "abort";
-       case bk_gnu_builtin_abs:          return "abs";
-       case bk_gnu_builtin_labs:         return "labs";
-       case bk_gnu_builtin_llabs:        return "llabs";
-       case bk_gnu_builtin_exit:         return "exit";
-       case bk_gnu_builtin_malloc:       return "malloc";
-       case bk_gnu_builtin_memcmp:       return "memcmp";
-       case bk_gnu_builtin_memcpy:       return "memcpy";
-       case bk_gnu_builtin___memcpy_chk: return "memcpy";
-       case bk_gnu_builtin_memset:       return "memset";
-       case bk_gnu_builtin_memmove:      return "memmove";
-       case bk_gnu_builtin_strlen:       return "strlen";
-       case bk_gnu_builtin_strcmp:       return "strcmp";
-       case bk_gnu_builtin_strcpy:       return "strcpy";
-       case bk_gnu_builtin_strcat:       return "strcat";
-       case bk_gnu_builtin_strncat:      return "strncat";
+       case bk_gnu_builtin___memcpy_chk:    return "memcpy";
+       case bk_gnu_builtin___memmove_chk:   return "memmove";
+       case bk_gnu_builtin___memset_chk:    return "memset";
+       case bk_gnu_builtin___snprintf_chk:  return "snprintf";
+       case bk_gnu_builtin___sprintf_chk:   return "sprintf";
+       case bk_gnu_builtin___strcat_chk:    return "strcat";
+       case bk_gnu_builtin___strcpy_chk:    return "strcpy";
+       case bk_gnu_builtin___strncat_chk:   return "strncat";
+       case bk_gnu_builtin___strncpy_chk:   return "strncpy";
+       case bk_gnu_builtin___vsnprintf_chk: return "vsnprintf";
+       case bk_gnu_builtin___vsprintf_chk:  return "vsprintf";
+       case bk_gnu_builtin_abort:           return "abort";
+       case bk_gnu_builtin_abs:             return "abs";
+       case bk_gnu_builtin_exit:            return "exit";
+       case bk_gnu_builtin_labs:            return "labs";
+       case bk_gnu_builtin_llabs:           return "llabs";
+       case bk_gnu_builtin_malloc:          return "malloc";
+       case bk_gnu_builtin_memcmp:          return "memcmp";
+       case bk_gnu_builtin_memcpy:          return "memcpy";
+       case bk_gnu_builtin_memmove:         return "memmove";
+       case bk_gnu_builtin_memset:          return "memset";
+       case bk_gnu_builtin_snprintf:        return "snprintf";
+       case bk_gnu_builtin_sprintf:         return "sprintf";
+       case bk_gnu_builtin_strcat:          return "strcat";
+       case bk_gnu_builtin_strcmp:          return "strcmp";
+       case bk_gnu_builtin_strcpy:          return "strcpy";
+       case bk_gnu_builtin_strlen:          return "strlen";
+       case bk_gnu_builtin_strncat:         return "strncat";
+       case bk_gnu_builtin_strncpy:         return "strncpy";
+       case bk_gnu_builtin_vsnprintf:       return "vsnprintf";
+       case bk_gnu_builtin_vsprintf:        return "vsprintf";
 
        default:
                break;
@@ -124,7 +145,19 @@ static const char *get_builtin_replacement_name(builtin_kind_t kind)
 int get_builtin_chk_arg_pos(builtin_kind_t kind)
 {
        switch (kind) {
-       case bk_gnu_builtin___memcpy_chk: return 3;
+       case bk_gnu_builtin___sprintf_chk:
+       case bk_gnu_builtin___strcat_chk:
+       case bk_gnu_builtin___strcpy_chk:
+       case bk_gnu_builtin___vsprintf_chk:
+               return 2;
+       case bk_gnu_builtin___memcpy_chk:
+       case bk_gnu_builtin___memmove_chk:
+       case bk_gnu_builtin___memset_chk:
+       case bk_gnu_builtin___snprintf_chk:
+       case bk_gnu_builtin___strncat_chk:
+       case bk_gnu_builtin___strncpy_chk:
+       case bk_gnu_builtin___vsnprintf_chk:
+               return 3;
        default:
                break;
        }
index a246538..ab3fc17 100644 (file)
  */
 typedef enum builtin_kind_t {
        bk_none = 0,
+
+       bk_gnu_builtin___memcpy_chk,
+       bk_gnu_builtin___memmove_chk,
+       bk_gnu_builtin___memset_chk,
+       bk_gnu_builtin___snprintf_chk,
+       bk_gnu_builtin___sprintf_chk,
+       bk_gnu_builtin___strcat_chk,
+       bk_gnu_builtin___strcpy_chk,
+       bk_gnu_builtin___strncat_chk,
+       bk_gnu_builtin___strncpy_chk,
+       bk_gnu_builtin___vsnprintf_chk,
+       bk_gnu_builtin___vsprintf_chk,
+       bk_gnu_builtin_abort,
+       bk_gnu_builtin_abs,
        bk_gnu_builtin_alloca,
+       bk_gnu_builtin_clz,
+       bk_gnu_builtin_ctz,
+       bk_gnu_builtin_exit,
+       bk_gnu_builtin_expect,
+       bk_gnu_builtin_ffs,
+       bk_gnu_builtin_frame_address,
        bk_gnu_builtin_huge_val,
        bk_gnu_builtin_huge_valf,
        bk_gnu_builtin_huge_vall,
        bk_gnu_builtin_inf,
        bk_gnu_builtin_inff,
        bk_gnu_builtin_infl,
-       bk_gnu_builtin_nan,
-       bk_gnu_builtin_nanf,
-       bk_gnu_builtin_nanl,
-       bk_gnu_builtin_va_end,
-       bk_gnu_builtin_expect,
-       bk_gnu_builtin_return_address,
-       bk_gnu_builtin_frame_address,
-       bk_gnu_builtin_ffs,
-       bk_gnu_builtin_clz,
-       bk_gnu_builtin_ctz,
-       bk_gnu_builtin_popcount,
-       bk_gnu_builtin_parity,
-       bk_gnu_builtin_prefetch,
-       bk_gnu_builtin_trap,
-       bk_gnu_builtin_object_size,
-       bk_gnu_builtin_abort,
-       bk_gnu_builtin_abs,
        bk_gnu_builtin_labs,
        bk_gnu_builtin_llabs,
-       bk_gnu_builtin_exit,
        bk_gnu_builtin_malloc,
        bk_gnu_builtin_memcmp,
        bk_gnu_builtin_memcpy,
-       bk_gnu_builtin___memcpy_chk,
        bk_gnu_builtin_memmove,
        bk_gnu_builtin_memset,
-       bk_gnu_builtin_strlen,
+       bk_gnu_builtin_nan,
+       bk_gnu_builtin_nanf,
+       bk_gnu_builtin_nanl,
+       bk_gnu_builtin_object_size,
+       bk_gnu_builtin_parity,
+       bk_gnu_builtin_popcount,
+       bk_gnu_builtin_prefetch,
+       bk_gnu_builtin_return_address,
+       bk_gnu_builtin_snprintf,
+       bk_gnu_builtin_sprintf,
+       bk_gnu_builtin_strcat,
        bk_gnu_builtin_strcmp,
        bk_gnu_builtin_strcpy,
-       bk_gnu_builtin_strncpy,
-       bk_gnu_builtin_strcat,
+       bk_gnu_builtin_strlen,
        bk_gnu_builtin_strncat,
+       bk_gnu_builtin_strncpy,
+       bk_gnu_builtin_trap,
+       bk_gnu_builtin_va_end,
+       bk_gnu_builtin_vsnprintf,
+       bk_gnu_builtin_vsprintf,
 
-       bk_ms_rotl,
-       bk_ms_rotr,
-       bk_ms_rotl64,
-       bk_ms_rotr64,
-       bk_ms_byteswap_ushort,
-       bk_ms_byteswap_ulong,
-       bk_ms_byteswap_uint64,
-
-       bk_ms__debugbreak,
-       bk_ms_ReturnAddress,
        bk_ms_AddressOfReturnAddress,
-       bk_ms__popcount,
-       bk_ms_enable,
-       bk_ms_disable,
-       bk_ms__inbyte,
-       bk_ms__inword,
-       bk_ms__indword,
-       bk_ms__outbyte,
-       bk_ms__outword,
-       bk_ms__outdword,
-       bk_ms__ud2,
        bk_ms_BitScanForward,
        bk_ms_BitScanReverse,
        bk_ms_InterlockedExchange,
        bk_ms_InterlockedExchange64,
+       bk_ms_ReturnAddress,
+       bk_ms__debugbreak,
+       bk_ms__inbyte,
+       bk_ms__indword,
+       bk_ms__inword,
+       bk_ms__outbyte,
+       bk_ms__outdword,
+       bk_ms__outword,
+       bk_ms__popcount,
        bk_ms__readeflags,
+       bk_ms__ud2,
        bk_ms__writeeflags,
+       bk_ms_byteswap_uint64,
+       bk_ms_byteswap_ulong,
+       bk_ms_byteswap_ushort,
+       bk_ms_disable,
+       bk_ms_enable,
+       bk_ms_rotl,
+       bk_ms_rotl64,
+       bk_ms_rotr,
+       bk_ms_rotr64,
 } builtin_kind_t;
 
 /**