aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
diff options
context:
space:
mode:
authorseyko <seyko2@gmail.com>2015-04-12 04:47:15 +0300
committerseyko <seyko2@gmail.com>2015-04-12 04:47:15 +0300
commite7a60e4d01a46ffb51ad4b963cad6b6f176105cb (patch)
treecdf634828002b187c47ef575f249cbc13e71eedb /libtcc.c
parent4bb9dd44f14f34b20e2718dbe9724998904153d8 (diff)
downloadtinycc-e7a60e4d01a46ffb51ad4b963cad6b6f176105cb.tar.gz
tinycc-e7a60e4d01a46ffb51ad4b963cad6b6f176105cb.tar.bz2
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
Diffstat (limited to 'libtcc.c')
-rw-r--r--libtcc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libtcc.c b/libtcc.c
index 0f1fdd0..bc784e7 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -434,7 +434,10 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section,
ElfW(Sym) *esym;
const char *name;
char buf1[256];
+
+#ifdef CONFIG_TCC_BCHECK
char buf[32];
+#endif
if (section == NULL)
sh_num = SHN_UNDEF;
@@ -1397,11 +1400,11 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
#ifdef CONFIG_TCC_BCHECK
if (s->do_bounds_check && (output_type == TCC_OUTPUT_EXE))
{
- /* XXX force a bcheck.o linking by compiling a function with a local array.
- Otherwise bcheck.o may be not linked. */
-
- if (tcc_compile_string(s, "static void __bound_check_dummy_func(){int v[1];}") == -1)
- tcc_warning("compiling __bound_check_dummy_func failed");
+ /* force a bcheck.o linking */
+ addr_t func = TOK___bound_init;
+ Sym *sym = external_global_sym(func, &func_old_type, 0);
+ if (!sym->c)
+ put_extern_sym(sym, NULL, 0, 0);
}
#endif
return 0;