This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

how to override static function

Note: This was originally posted on 5th June 2009 at http://forums.arm.com

I find we can override a function Using $Super$$ and $Sub$$ to overide symbol definitions from the pdf ADS_LinkerGuide_A.pdf.But When I use this way to override a static function defined in a library, ads linker can't find the $Super$$func symbol, but I find when the function is global in a library, ads linker succeed.
How can I override the static function in a library!

extern void ExtraFunc(void);
extern void $Super$$foo(void):
/* this function will be linked instead of the original foo() */
void $Sub$$foo(void)
{
ExtraFunc(); /* does some extra setup work */
$Super$$foo(); /*
}
Parents
  • Note: This was originally posted on 23rd June 2009 at http://forums.arm.com

    Do we have some ways to override the local static function?
    And we can never override the static function in library, Is it right?


    Patch it in library...

    First :: extract the library contents and disassemble the object files, so
    you have a near complete understanding of what is going on !?!

    Second :: write some test program that uses it. Then dissassemble/debug the module...
    The static function address is relative to that of the exported function you called.
    Then put MAGIC marker to store the function address that you supplied into some safe
    part of that static function. And change the entrance of that static function to jump to that
    address marked with MAGIC markers.

    Third :: After you linked the executable. Find your new function address and put it in the binary
    with some hex editor. You will find the location by the help of MAGIC markers.

    This thing is easy to tell, hard to do. In fact , I did not do such a thing , but it seems logical...
Reply
  • Note: This was originally posted on 23rd June 2009 at http://forums.arm.com

    Do we have some ways to override the local static function?
    And we can never override the static function in library, Is it right?


    Patch it in library...

    First :: extract the library contents and disassemble the object files, so
    you have a near complete understanding of what is going on !?!

    Second :: write some test program that uses it. Then dissassemble/debug the module...
    The static function address is relative to that of the exported function you called.
    Then put MAGIC marker to store the function address that you supplied into some safe
    part of that static function. And change the entrance of that static function to jump to that
    address marked with MAGIC markers.

    Third :: After you linked the executable. Find your new function address and put it in the binary
    with some hex editor. You will find the location by the help of MAGIC markers.

    This thing is easy to tell, hard to do. In fact , I did not do such a thing , but it seems logical...
Children
No data