how to code global indirect branches ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hey all,

My goal is to pass a function pointer to a function, and then do the
operation that is pointed to by the function pointer, like the following:
======in kernel.cpp===========

void show()
{
   cout<<"a piece of mystery";
}
=======in wrapper.cpp=========
typedef void (*fpr)();
wrapper(fpr kernel)
{
  (*kernel)(); 
  Check_error();
}

Main()
{
   ...
   fpr kernel = show;
   wrapper(kernel);
   ...
}
=================================
Now, I need to achieve the same goal without using function calls(and
therefore no function pointers). So, I am thinking about indirect jumps. I
tend to define a unique code label within each kernel operator, and then I
can pass the indirect jump's target address to the mymain function, which
can then jump to the right instruction. But I don't know how to do it. It
can be something like the following:

============in kernel.cpp============
void show()
{
LABEL_SHOW:
   cout<<"a piece of mystery";
   goto END_MAIN;
}

=======in wrapper.cpp=========
wrapper(unsigned long  target_address)
{
  goto target_address;
END_MAIN:
  Check_error();
}

Main()
{
   ...
   unsigned long target_address = LEBEL_SHOW;
   wrapper(target_address);
   ...
}
=================================
Can anyone help me? I appreciate it a lot!

Thanks!

Jiayuan






[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux