mirror of
https://github.com/mirror/tinycc.git
synced 2025-02-28 08:10:25 +08:00
replace a method to force bcheck.o linking
* define __bound_init as external_global_sym insteed of the compiling a tiny program * remove warning about buf[] when CONFIG_TCC_BCHECK is not defined
This commit is contained in:
parent
4bb9dd44f1
commit
e7a60e4d01
13
libtcc.c
13
libtcc.c
@ -434,7 +434,10 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section,
|
|||||||
ElfW(Sym) *esym;
|
ElfW(Sym) *esym;
|
||||||
const char *name;
|
const char *name;
|
||||||
char buf1[256];
|
char buf1[256];
|
||||||
|
|
||||||
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
char buf[32];
|
char buf[32];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (section == NULL)
|
if (section == NULL)
|
||||||
sh_num = SHN_UNDEF;
|
sh_num = SHN_UNDEF;
|
||||||
@ -1397,11 +1400,11 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
|
|||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
if (s->do_bounds_check && (output_type == TCC_OUTPUT_EXE))
|
if (s->do_bounds_check && (output_type == TCC_OUTPUT_EXE))
|
||||||
{
|
{
|
||||||
/* XXX force a bcheck.o linking by compiling a function with a local array.
|
/* force a bcheck.o linking */
|
||||||
Otherwise bcheck.o may be not linked. */
|
addr_t func = TOK___bound_init;
|
||||||
|
Sym *sym = external_global_sym(func, &func_old_type, 0);
|
||||||
if (tcc_compile_string(s, "static void __bound_check_dummy_func(){int v[1];}") == -1)
|
if (!sym->c)
|
||||||
tcc_warning("compiling __bound_check_dummy_func failed");
|
put_extern_sym(sym, NULL, 0, 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
1
tcctok.h
1
tcctok.h
@ -281,6 +281,7 @@
|
|||||||
DEF(TOK___bound_main_arg, "__bound_main_arg")
|
DEF(TOK___bound_main_arg, "__bound_main_arg")
|
||||||
DEF(TOK___bound_local_new, "__bound_local_new")
|
DEF(TOK___bound_local_new, "__bound_local_new")
|
||||||
DEF(TOK___bound_local_delete, "__bound_local_delete")
|
DEF(TOK___bound_local_delete, "__bound_local_delete")
|
||||||
|
DEF(TOK___bound_init, "__bound_init")
|
||||||
# ifdef TCC_TARGET_PE
|
# ifdef TCC_TARGET_PE
|
||||||
DEF(TOK_malloc, "malloc")
|
DEF(TOK_malloc, "malloc")
|
||||||
DEF(TOK_free, "free")
|
DEF(TOK_free, "free")
|
||||||
|
Loading…
Reference in New Issue
Block a user