Is it possible to "create" functions with a gcc plugin?

Benxi Liu lbxlbxlbxlbxlbx@gmail.com
Wed Jun 7 01:10:00 GMT 2017


I'm using a gcc plugin to do some instrument work during compilation.
Inserting codes in a function is very simple, just like those passes
do in gcc.

But Can I create new functions, and append it to executables? I want
to do the instrument by this way: to create new functions,  add my
codes into them, then instrument some calls to them.

foo:
call to new_function;      //instrument a call

new_function:                 //created function
instrument  codes here

I think the most difficult part is to create functions. Since we can
add arbitrary codes in the functions, it's OK to create "empty
functions" at first.

So is it possible to do so? Any tips?



More information about the Gcc-help mailing list