is casting of function descriptor assignments for ia64 ONLY a good idea?

Keith Owens kaos@sgi.com
Thu Jan 3 05:30:00 GMT 2002


On Thu, 3 Jan 2002 10:25:23 +0100, 
Martin Kahlert <martin.kahlert@infineon.com> wrote:
>Hi Keith,
>
>On Thu, Jan 03, 2002 at 07:35:30PM +1100, Keith Owens wrote:
>> Not just ia64, powerpc 64 as well.  You are assuming that all pointers
>> are the same format when that is not guaranteed by the C standard.  On
>> most architectures they are the same, you can convert a function
>> pointer to a void pointer and back again but it is not defined
>> behaviour.
>
>O.k., but how should i do it correctly?
>e.g. dlsym gives a void* (i assume, that's true in all OSes).
>Is it o.k. to cast this pointer to a function?
>If i assign the result of dlsym to a function pointer,
>is the cast down automagically (the way it works e.g. for double --> int)?

If dlsym returns the address of the function code on ia64/ppc64 then
you are out of luck, the address of the function code is unusuable
without the corresponding global pointer.  OTOH, if dlsym returns a
pointer to the function descriptor then casting the result to a
function pointer is safe.  It all depends on how dlsym was coded on
ia64/ppc.  Suck it and see what return value you get from dlsym for a
function name on ia64.



More information about the Gcc-bugs mailing list