1.5.10: problems relocating structures with function pointers

Justin Schoeman justin@expertron.co.za
Wed Jul 21 16:47:00 GMT 2004


I have discovered what may be a bug in the linker/relocater in cygwin 
(or, more likely, I am doing something stupid again).

When I use a structure containing function pointers, and this structure 
is placed in an archive, then the function pointer becomes NULL. As an 
example, compile the attached files as follows:

gcc -O2 -Wall -c inc.c
ar rsvc inc.a inc.c
gcc -O2 -Wall -o test test.c inc.a

Executing test.exe prints 0x0 (the address of the function cointained in 
the structure), and subsequently segfaults.

Relinking with

gcc -O2 -Wall -o test test.c inc.o

produces a binary that works correctly.

It seems that once the object file is archived, the dynamic loader 
losses the capability of correctly assigning the function addresses?

Any help would be greatly appreciated.

TIA,
-justin
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: inc.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040721/df9cf49e/attachment.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.c
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040721/df9cf49e/attachment-0001.c>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cygcheck.out
URL: <http://cygwin.com/pipermail/cygwin/attachments/20040721/df9cf49e/attachment.ksh>
-------------- next part --------------
--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


More information about the Cygwin mailing list