diff options
| author | bellard <bellard> | 2002-09-08 22:46:32 +0000 |
|---|---|---|
| committer | bellard <bellard> | 2002-09-08 22:46:32 +0000 |
| commit | d8ef07df04443465600f94e8c5d769899a2e4d27 (patch) | |
| tree | a3a860c837938f683eab08a40344fb5407815de3 /tcc.c | |
| parent | 10f5d44f43cd6e93a17fb00aa63c79bb13fc0a81 (diff) | |
| download | tinycc-d8ef07df04443465600f94e8c5d769899a2e4d27.tar.gz tinycc-d8ef07df04443465600f94e8c5d769899a2e4d27.tar.bz2 | |
added tcc_relocate() and tcc_get_symbol()
Diffstat (limited to 'tcc.c')
| -rw-r--r-- | tcc.c | 19 |
1 files changed, 13 insertions, 6 deletions
@@ -7070,11 +7070,10 @@ static void sig_error(int signum, siginfo_t *siginf, void *puc) } #endif -/* launch the compiled program with the given arguments */ -int tcc_run(TCCState *s1, int argc, char **argv) +/* do all relocations (needed before using tcc_get_symbol()) */ +void tcc_relocate(TCCState *s1) { Section *s; - int (*prog_main)(int, char **); int i; tcc_add_runtime(s1); @@ -7104,8 +7103,16 @@ int tcc_run(TCCState *s1, int argc, char **argv) if (s->reloc) relocate_section(s1, s); } +} + +/* launch the compiled program with the given arguments */ +int tcc_run(TCCState *s1, int argc, char **argv) +{ + int (*prog_main)(int, char **); + + tcc_relocate(s1); - prog_main = (void *)get_elf_sym_val("main"); + prog_main = tcc_get_symbol(s1, "main"); if (do_debug) { #ifdef WIN32 @@ -7131,11 +7138,11 @@ int tcc_run(TCCState *s1, int argc, char **argv) void **bound_error_func; /* set error function */ - bound_error_func = (void **)get_elf_sym_val("__bound_error_func"); + bound_error_func = (void **)tcc_get_symbol(s1, "__bound_error_func"); *bound_error_func = rt_error; /* XXX: use .init section so that it also work in binary ? */ - bound_init = (void *)get_elf_sym_val("__bound_init"); + bound_init = (void *)tcc_get_symbol(s1, "__bound_init"); bound_init(); } #endif |
