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]

Re: function pointer

Hi folks:

 I have a C program fragment as follows:

 int   (*fp)(int a, int b);

int a,b;


A fragment of the assembly translation of the above code is as follows:

  call  *%ebx;

It seems that in the assembly translation the address of
another_function() is pushed into register %ebx first, and then a
indirect call(i.e. call *%ebx) is used to transfer control flow to
another_function(). Is this the standare way that gcc handles function
calls which are invoked through function pointer variable? I would like 
add some assembly instructions right before every this kind of indirect 
funciton call? (i.e. so every fucntion call invoked through function
pointer will be tranlated as follows:

 New added assembly code
 call  *%ebx

Does anyone know how to do this?

Are you doing a gcc port or do you want to include code
from your C program?
In the first case, you could use the define_expand of the
standard pattern names "call", "call_value" etc...
Take a look at
In the second case ... you could add some __asm statements...


Besides, as you know the C source code will be translated into RTL form
first. Then the RTL form will be tranlated into assembly code and the
assembly code will be saved into a temporary file. After all the 
code is generated and saved into the temporary file, what function of 
gcc souce code is called to process the temporary assembly file? If I 
some assembly instructions into the temporary file right before it is
further processed, will this caused any problem?

 Any suggestion is highly appreciated, thanks .

                                V. H. 

Attiva la tua Email gratuita al sito:

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