mirror of
https://github.com/frida/tinycc
synced 2024-11-24 00:29:38 +03:00
Fix bounds checking
i386-gen.c: - Fix large stack size alloca code. The returned value of alloca was not used corectly. libtcc.c: - Use __SIZE_TYPE__ for __builtin_offsetof tccpp.c: - Fix __MAYBE_REDIR and abort builtins. tests/tests2/Makefile - Run 117_gcc_test also with bound checking enabled This found the above problems.
This commit is contained in:
parent
49e2d06921
commit
20fa63488a
@ -424,7 +424,8 @@ ST_FUNC void gfunc_call(int nb_args)
|
||||
vpush_global_sym(&func_old_type, TOK_alloca);
|
||||
gcall_or_jmp(0);
|
||||
vtop--;
|
||||
o(0x58585a);
|
||||
o(0x585a58);
|
||||
oad(0xec81, 8); /* sub $8, %esp */
|
||||
} else
|
||||
#endif
|
||||
oad(0xec81, size); /* sub $xxx, %esp */
|
||||
|
2
libtcc.c
2
libtcc.c
@ -980,7 +980,7 @@ LIBTCCAPI TCCState *tcc_new(void)
|
||||
tcc_define_symbol(s, "__BYTE_ORDER__", "__ORDER_LITTLE_ENDIAN__");
|
||||
tcc_define_symbol(s, "__INT_MAX__", "0x7fffffff");
|
||||
tcc_define_symbol(s, "__LONG_LONG_MAX__", "0x7fffffffffffffffLL");
|
||||
tcc_define_symbol(s, "__builtin_offsetof(type,field)", "((unsigned long) &((type *)0)->field)");
|
||||
tcc_define_symbol(s, "__builtin_offsetof(type,field)", "((__SIZE_TYPE__) &((type *)0)->field)");
|
||||
return s;
|
||||
}
|
||||
|
||||
|
8
tccpp.c
8
tccpp.c
@ -3675,13 +3675,14 @@ static void tcc_predefs(CString *cstr)
|
||||
"#endif\n"
|
||||
/* TCC BBUILTIN AND BOUNDS ALIASES */
|
||||
"#ifdef __BOUNDS_CHECKING_ON\n"
|
||||
"#define __BUILTIN(ret,name,params) ret __builtin_##name params __attribute__((alias(\"__bound_\"#name)));\n"
|
||||
"#define __BUILTINBC(ret,name,params) ret __builtin_##name params __attribute__((alias(\"__bound_\"#name)));\n"
|
||||
"#define __BOUND(ret,name,params) ret name params __attribute__((alias(\"__bound_\"#name)));\n"
|
||||
"#else\n"
|
||||
"#define __BUILTIN(ret,name,params) ret __builtin_##name params __attribute__((alias(#name)));\n"
|
||||
"#define __BUILTINBC(ret,name,params) ret __builtin_##name params __attribute__((alias(#name)));\n"
|
||||
"#define __BOUND(ret,name,params)\n"
|
||||
"#endif\n"
|
||||
"#define __BOTH(ret,name,params) __BUILTIN(ret,name,params)__BOUND(ret,name,params)\n"
|
||||
"#define __BOTH(ret,name,params) __BUILTINBC(ret,name,params)__BOUND(ret,name,params)\n"
|
||||
"#define __BUILTIN(ret,name,params) ret __builtin_##name params __attribute__((alias(\"\"#name)));\n"
|
||||
"__BOTH(void*,memcpy,(void*,const void*,__SIZE_TYPE__))\n"
|
||||
"__BOTH(void*,memmove,(void*,const void*,__SIZE_TYPE__))\n"
|
||||
"__BOTH(void*,memset,(void*,int,__SIZE_TYPE__))\n"
|
||||
@ -3720,6 +3721,7 @@ static void tcc_predefs(CString *cstr)
|
||||
"__BOUND(void*,mmap,())\n"
|
||||
"__BOUND(void*,munmap,())\n"
|
||||
#endif
|
||||
"#undef __BUILTINBC\n"
|
||||
"#undef __BUILTIN\n"
|
||||
"#undef __BOUND\n"
|
||||
"#undef __BOTH\n"
|
||||
|
@ -97,6 +97,8 @@ GEN-ALWAYS =
|
||||
115_bound_setjmp.test: FLAGS += -b
|
||||
116_bound_setjmp2.test: FLAGS += -b
|
||||
|
||||
117_gcc_test.test: FLAGS += $(T2) && $(TCC) -b
|
||||
|
||||
# Filter source directory in warnings/errors (out-of-tree builds)
|
||||
FILTER = 2>&1 | sed -e 's,$(SRC)/,,g'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user