This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
I'm porting some code that does a kind of JIT to translate a user script into a dynamically created function for execution, but am having trouble porting this to GCC and the way it implementes exceptions.
Lets say I've got int doPUT() { throw IOException; }
int doGET() { throw IOException }
and I want to magic up a function by writing (intel x86) instructions into memory that does the same as if I'd done
int magic() { doPUT(); doGET(); return 0; }
I then want to call my magic function as in
int main() { // magic up my function in memory containing calls to doGET and doPUT. try { // call my magic'd function } catch (IOException) { // Report the exception } }
If I do this I get std::terminate called from __cxa_throw. Researching this it seems that I somehow need to register some exception handling tables to correspond to the "magic" function to enable the exception handler to allow the exception to propagate through.
I'd welcome any pointers to where I might be able to get some information on this. I've looked at the C++ ABI documentation which helps a bit, and I've found some information on the format that the tables need to be in (and indeed I've looked at the assembler generated by the gcc compiler if I code up "magic" and compile it directly), but I don't yet see quite how to put it all together.
I imagine that GCJ has do to this ind of thing?
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |