[parisc-linux] more on canonicalize_funcptr_for_compare
John David Anglin
dave@hiauly1.hia.nrc.ca
Wed, 14 May 2003 12:43:33 -0400 (EDT)
> > if ((int) fptr == -1 || (unsigned int) fptr < 4096 || !((int) fptr & 2))
> > return (unsigned int) fptr;
> >
> > so, why doesn't that match the second || case and exit? (gdb
> > disassmbly shows that the code tries to dereference the fptr argument
> > and segfaults)
>
> Even if this were fixed, it seems like a quality of implementation issue.
> Basically, we're saying that if none of these conditions are met, it's
> safe to dereference this pointer, and I'm sure we'll find people stuffing
> other magic values into pointers.
The magic values were arbitrarily chosen to be the same as under hpux.
> I see three options:
>
> 1) Continue with this, accepting that some badly written software won't
> run.
I'm not going to lose sleep on this one. Obviously, using implementation
dependent features of function pointers is not portable.
> 2) Install a signal handler that handles the segfault (we can lose two of
> the tests this way, so it'll be faster in the common case)
>
> 3) Change the ABI. Make it so we always have unique PLabels. Recompile
> anything necessary.
It would be nice to have the 32 and 64 bit ABIs the same in this
respect. However, this requires non trivial changes to the dynamic
loader and linker. I'm not sure what the extra overhead would be.
Function pointer comparisons aren't done very often in user code.
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)