This is the mail archive of the 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]

Re: How to insert dynamic code? (continued)

jacob navia writes:
 > Hi
 > Context:
 > I am writing a JIT and need to register the frame information about
 > the generated program within the context of a larger C++ program
 > compiled with g++. Stack layout is like this:
 >         catch established by C++
 >         JITTED code generated dynamically
 >         JITTED code
 >         JITTED code calls a C++ routine
 >         C++ routine calls other C++ routines
 >         C++ routine makes a THROW
 > The throw must go past the JITTED code to the established C++ catch.
 > Problem.
 > The stack unwinder stops with END_OF_STACK at the Jitted code. Why?
 > Following the code with the debugger I see that the unwider looks
 > for the next frame using the structures established by the dynamic loader,
 > specifically in the function "__dl_iterate_phdr" in the file
 > "dl-iteratephdr.c" in the glibc.
 > So, this means:
 > 1) I am cooked and what I want to do is impossible. This means I will 
 > probably
 >    get cooked at work for proposing something stupid like this :-)
 > 2) There is an API or a way of adding at run time a routine to the lists
 >    of loaded objects in the same way as the dynamic loader does.
 > PLEEEEEEZE do not answer with:
 > "Just look at the code of the dynamic loader!"
 > because I have several megabytes of code to understand already!!!!!!!!!
 > I am so near the end that it would be a shame to stop now. My byte
 > codes for the DWARF interpreter LOAD into the interpreter
 > successfully, and they are executed OK, what has costed me several
 > weeks of efforts, wading through MBs of code and missing/wrong
 > specs.
 > I just would like to know a way of registering (and deregistering
 > obviously) code that starts at address X and is Y bytes long. JUst
 > that.

The way you do not reply to mails replying to your questions doesn't
encourage people to help you.  Please try harder to answer.

I suspect that the gcc unwinder is relying on __dl_iterate_phdr to
scan the loaded libraries and isn't using the region that you have

But this is odd, becasue when I look at _Unwind_Find_FDE in
unwind-dw2-fde-glibc.c, I see:

  ret = _Unwind_Find_registered_FDE (pc, bases);


  if (dl_iterate_phdr (_Unwind_IteratePhdrCallback, &data) < 0)
    return NULL;

So, it looks to me as though we do call _Unwind_Find_registered_FDE
first.  If you have registered your EH data, it should be found.

So, what happens when _Unwind_Find_registered_FDE is called?  Does it
find the EH data you have registered?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]