First off, Hi guys!
Got a bit of a puzzler here, for my own edutainment I've written an apache module that loads, compiles and runs C code (think php but C)
Everything is working okay, except that I can't call functions that I add to the function table.
I did have to hack tcc to not load crtn.o as for the life of me I couldn't get tcc to load it (but that shouldn't be an issue? - its not needed for tcc -run)
end of tcc_add_runtime commented out tcc_add_crt(s1, "crtn.o") in tccelf.c (I'm on void Linux btw)
I have a function
typedef void(*fp)(char*);
void foo(char* s) {
ap_rprintf(saved_r, "foo says %s", s);
}
which I can call within the module happily with
footest = tcc_get_symbol(s, "foo");
footest("foo sym test<br>");
either before or after calling the tcc compiled code and it works just fine.
however if I call it in the tcc compiled code I get a seg fault
interestingly if I pass a function pointer as a parameter the function call works fine !
here's the test code that I'm testing (the commented line is the seg faulter)
void foo(char*);
typedef void(*fp)(char*);
int main(fp f) {
f("*** Hello from Cscript ***<br>");
//foo("*** Hello from Cscript ***<br>");
return 123;
}
also if anyone can enlighten me as to why libtcc can't find crtn.o and confirm that its not actually needed (i think in this case?) I'd appreciate it - I did try adding the correct path for my system in tcc.h
# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/lib" CONFIG_LDDIR)
Thanks for taking the time to read this...
All the best
Chris
--
Free source code and tutorials!
Disclaimer:
By sending an email to ANY of my addresses you are agreeing that:
1. I am by definition, "the intended recipient"
2. All information in the email is mine to do with as I see fit and make such financial profit, political mileage, or good joke as it lends itself to. In particular, I may quote it where I please.
3. I may take the contents as representing the views of your company.
4. This overrides any disclaimer or statement of confidentiality that may be included on your message.