This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Help! DW function pointer encoding for PA
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: dave at hiauly1 dot hia dot nrc dot ca (John David Anglin)
- Cc: rth at redhat dot com, gcc at gcc dot gnu dot org
- Date: Thu, 21 Feb 2002 16:16:07 -0500 (EST)
- Subject: 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)