>From 6bcf15f23050aa6f6caf670deeb309183a78976c Mon Sep 17 00:00:00 2001 From: Sean Conner Date: Thu, 9 Aug 2012 00:01:31 -0400 Subject: [PATCH] Make tcc_relocate_ex() a public function, not a private function. I have code that relies upon the stock TCC 0.9.25 API, which differs from this version of TCC. I don't want to lose the features in the existing codebase I have (a TCC interface to Lua, where Lua tracks the memory usage of the compiled code itself) so promote tcc_relocate_ex() (which implements the old 0.9.25 API) to an entry point. This solves the issue for me, but it appears that my code will not work under SE Linux. I'm not terribly concerned about that as this point, but it is something that could use some investigation. Signed-off-by: Sean Conner --- libtcc.h | 1 + tccrun.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libtcc.h b/libtcc.h index 35a5889..152dc6b 100644 --- a/libtcc.h +++ b/libtcc.h @@ -94,6 +94,7 @@ LIBTCCAPI int tcc_run(TCCState *s, int argc, char **argv); /* Do all relocations (needed before using tcc_get_symbol()) Returns -1 on error. */ LIBTCCAPI int tcc_relocate(TCCState *s1); +LIBTCCAPI int tcc_relocate_ex(TCCState *s1,void *ptr); /* return symbol value or NULL if not found */ LIBTCCAPI void *tcc_get_symbol(TCCState *s, const char *name); diff --git a/tccrun.c b/tccrun.c index 41081cc..7b04303 100644 --- a/tccrun.c +++ b/tccrun.c @@ -37,7 +37,6 @@ static void set_pages_executable(void *ptr, unsigned long length); static void set_exception_handler(void); static int rt_get_caller_pc(uplong *paddr, ucontext_t *uc, int level); static void rt_error(ucontext_t *uc, const char *fmt, ...); -static int tcc_relocate_ex(TCCState *s1, void *ptr); #ifdef _WIN64 static void win64_add_function_table(TCCState *s1); @@ -119,13 +118,14 @@ LIBTCCAPI int tcc_run(TCCState *s1, int argc, char **argv) /* relocate code. Return -1 on error, required size if ptr is NULL, otherwise copy code into buffer passed by the caller */ -static int tcc_relocate_ex(TCCState *s1, void *ptr) +LIBTCCAPI int tcc_relocate_ex(TCCState *s1, void *ptr) { Section *s; unsigned long offset, length; uplong mem; int i; + s1->runtime_mem = NULL; if (0 == s1->runtime_added) { s1->runtime_added = 1; s1->nb_errors = 0; -- 1.7.1