Re: Strict aliasing and pointers to functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 25 Nov 2006, Perry Smith wrote:

On Nov 25, 2006, at 7:12 PM, av1474@xxxxxxxx wrote:
       *(void **) (char **) (void *) &funcs.dummy = dlsym (NULL, "dummy");

I don't think this has anything to do with the compiler.  dlsym is returning
null.  It did not find dummy.

It may be that dummy is called something else: _dummy or .dummy

Sorry, but you haven't read my message carefully. I presented the transcript
of compiling and running the code, which in part said:

<quote>
safp$ gcc -O2 -Wall -W -pedantic safp.c -o safp -ldl -g -Wl,-E
safp$ ./safp
dummy is 0x10001778
failed 0x10001778
</quote>


It might also be that dummy is not obviously referenced so the linker
optimized it completely away.  Look at the nm output of your code to see if
it is in the final executable.

Or, you can put a call to dummy (and for testing purposes, I'd make dummy
call out to something like printf, just in case), and then see if it works.

Also, in the man page I found via google for dlsym, it does not say that
passing NULL as the first argument is valid.  Maybe its valid on the i386
implementation but not on the PPC implementation.

I ommited call to dlopen (and associated error checking) for brevity,
since it works with NULL handle on both systems just fine. In retrospect
this was a mistake on my part, sorry about that.

--
vale

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux