Dynamically adding exception handling frames
Dynamically adding exception handling frames
- Subject: Dynamically adding exception handling frames
- From: jacob navia <email@hidden>
- Date: Tue, 28 Jul 2015 16:51:21 +0200
Hi
I am porting a JIT compiler to the Macintosh. This software runs
under windows and Linux. In both systems there is an interface for
adding exception frames dynamically when you add code compiled on
the fly.
Under linux the (not documented) gcc function
__register_frame_info does the trick. Under windows, Microsoft has
added an official API for this, that works without problems.
The Macintosh environment however is really a nightmare. There are
two "recommended" methods if you would believe the published
source code.
Method 1:
/// darwin_register_frame - Since __register_frame does not work
with darwin's
/// libgcc,we provide our own function, which "tricks" libgcc by
modifying the
/// "Dwarf2 object list" key.
void DarwinRegisterFrame(object *ob) {
// Get the key.
LibgccObjectInfo* LOI = (struct LibgccObjectInfo*)
_keymgr_get_and_lock_processwide_ptr(KEYMGR_GCC3_DW2_OBJ_LIST);
...
}
This code is taken from the official Apple open source site. There
is a little problem however...
_keymgr_get_and_lock_processwide_ptr returns ALWAYS ZERO!
I did a loop
179 for (int i=0; i<30000; i++) {
180 void *p=_keymgr_get_and_lock_processwide_ptr(i);
181 if (p) printf("%d %p\n",i,p);
182 }
IT ALWAYS returns zero.
Method 2:
Try to use __register_frame_info anyway. There is a function with
that name in several dynamic librairies.
The problem is that this function does NOTHING! It consists of a
SINGLE return STATEMENT, nothing else. After several days of work
I had the patience to go with gdb in disassembly mode and I saw
that that function does absolutely nothing. It is there to satisfy
the linker and make you loose time.
HOW then, are we supposed to add the frame information into a
running program?
Thanks in advance for any help on this issue.
jacob navia
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden