This is the mail archive of the gcc@gcc.gnu.org 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: Help! DW function pointer encoding for PA


> I'll have to look more carefully at the ia64.  I think I see what
> ia64_expand_call is doing to handle the function descriptor vs FDE
> issue:

It appears that the PA has a serious problem in its handling of function
descriptors.  This small test program demonstrates the problem:

int f (int (*func)(void)) { func(); }
int main (void);
int (*i)(void) = &main;
int main() { f (i); f (main); }

This is the assembly output showing how the plabels for the two calls
in main are treated:

	addil LR'i-$global$,%r27
	ldw RR'i-$global$(%r1),%r26
	.CALL ARGW0=GR
	bl f,%r2
	nop
	ldil LR'L$C0000,%r19
	ldw RR'L$C0000(%r19),%r26
	.CALL ARGW0=GR
	bl f,%r2
	nop

As can be seen, the call using  plabel "i" is handled correctly.  However,
for the plabel L$C0000 used in the second call, we are in fact loading the
address of the function from the descriptor rather than the address of the
descriptor.  Thus, indirect calls where the pic register changes value won't
work.  I don't know how this went unnoticed for so long.

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)


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