This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Bug report: objc classes linked in wrong order
- To: nicola at brainstorm dot co dot uk
- Subject: Re: Bug report: objc classes linked in wrong order
- From: "H . J . Lu" <hjl at lucon dot org>
- Date: Tue, 9 May 2000 12:07:30 -0700
- Cc: GNU C Library <libc-hacker at sourceware dot cygnus dot com>,egcs at egcs dot cygnus dot com, binutils at sourceware dot cygnus dot com
- References: <Pine.LNX.4.10.10005081510470.23306-101000@lin3.brainstorm.co.uk> <20000509120515.A18429@lucon.org>
On Tue, May 09, 2000 at 12:05:15PM -0700, H . J . Lu wrote:
> On Mon, May 08, 2000 at 05:01:06PM +0100, nicola@brainstorm.co.uk wrote:
> > Hi - I have a bug report.
> >
> > The problem description is as follows:
> >
> > (*) [standard behaviour] if I have two libraries implementing the same
> > function, say
> >
> > void hello (void);
> >
> > and I link an executable with the two libraries, the `hello` from the
> > first library given on the command line gets used. This happens with both
> > static and shared library.
> >
> > (*) if I do the same with an Objective-C class, i.e. I have two libraries
> > implementing the same method of the same class, what happens is:
> >
> > [standard behaviour] if I link an executable with the two libraries, the
> > method of the class from the first library on the command line gets used
> > when the two libraries are static.
> >
> > [the problem] The weird thing is when I link dynamically the two libraries
> > in: then - consistently - the class from the second library on the
> > command line gets used instead of the first as it should have.
> >
> > I was able to isolate the problem and to create a complete test showing
> > the problem, which I enclose in attach.
> >
> > Please notice that I am willing to actively help to fix the bug - only I
> > am not a linker/compiler expert, so I'm pretty stuck and don't know what
> > to look at. But it is quite important to me that the bug gets fixed.
> >
> > --
> >
> > I am using binutils-2.9.1.0.23 and almost everything which comes with
> > RedHat 6.1. I have the bug with both the old and the latest CVS egcs
> > compiler.
> >
> > Thank you for any help.
>
> It is a very interesting problem. I know very little about Objective-C.
> From the asm output, I have an impression that the Objective-C class
> implemenation is registered via the .ctors section. When you link with
>
> # cc -I./ -L/user/hjl/bugs/objc/shared/bug.report/install -o test-shared test.o -ltest1 -ltest2 -lobjc -lpthread
>
> "-ltest1 -ltest2 -lobjc -lpthread -lgcc -lc -lgcc" is passed to the
> linker. The dynamic linker in glibc 2.1 will process the .ctors section
> in the reverse order. That is
>
> 11951: calling init: /lib/libc.so.6
> 11951: calling init: /lib/libpthread.so.0
> 11951: calling init: ./install/libtest2.so.0
> 11951: calling init: ./install/libtest1.so.0
>
> As the result, the implemenation in libtest2 gets register first. For
> the static link, libtest2.a is not even used at all. I don't know for
> sure what the right answer for it is.
>
> BTW, it may have an impact when libgcc.so is introduced. It will be
> interesting to see the order of calling init if it will make a
> difference.
>
>
> H.J.
I forget to include the testcase.
H.J.
‹ Nä9 íYmO9æký+æ j6»K^¤pœ @�èR¨BªÓ©WÁf×éºlÖÑz·9tºûí7ö¾Ä„ í B¹ó#¡uìñÌxÆ3ö˜QöÉJè”'icí±`ÛM»Ójá×vl§-¿¶Ólªo�5»ãØVk»å8k¶ãno»kÐz4�4d"õ€µ˜ù<ò‰X…B«ÅhîÿÁÑþáÛ£G��^·Û¹¿—ùßqÛÛ¥ÿ�¶l;Û®ÓYût¹�ÿ¹ÿ‡T¤,þiH!¸Š½ ó!bñ%M, ä×ãý!��`xt6„Þì¿>}?R_
¤§à'ÔK)¤3Ž|F‰—0*^ÉfŠ’ðâ üᾂOCðˆÐKh =AÐ#)ó-€aH¯€M¦�Ð8U:
oBaBÓ�ÀÇó.?ò„€Ú‰òb
9g)ÌX’€�Ç4‘Ó)6üTä|c˜QµP
ôêg©7Š(ÌBæ‡Àãè
"î%0Q$ã„O”È\L.ùá²gžT�ƒ rô�‹ï‰’áÜ<ŒÇ…Ê$×¶XÆ'šŠB´Á¦äùÈH@6•\5ï4rëNÚ²Ê <Ipq0¢¡÷…ñ,A“ò,
°'{¹í
yÕ*Æ,iá¥+ bJ}6f¨.@iÁ'“Ü_1-ù¡²•®({ðþä¤wòsµGnìTïjJq+Y�$‹ëÒï„àŠðG®CE {Ad,¥VE?ñ.¥W©+zÕ/Š,òÔ!óŸ‚–ÿߢÅÇ,¢.ãžü�g½Sæ<øUþï´Mþ_ ÖɺÊÇœG0A[È„áE˜Ã̼1Ú&Š0!�uBú½×ÃÓÓþùÁéÛw½þìVóêõ è.¦‹)nŸŠ°ß;ùå&•Ì[Iïäl¸ßïߤ*DRPœöHu1��jpöñƒÍ®J!õ"5æíüHÑúë •i˜êãeŸäÕ/¡CÊÓÊŠx·:º¬ y±±¹`…-ØØ<8Ø‚ºu{:õœ‹§q‰¸ÎFÚ¨âq�AÄ¡žL=< 765+l骺¥WWÕý&Uݹª®®ªûµªºwªÚË�%ïýò>@
6n1‘G^Ô'—KÊ-¨ëQØ*Çä‚´©*è"Å..÷ߊuo«¸¢ä5Žªk† rÐâù¾½Ï]9�4z>ê=«DÛÚÝrd‰aûò…ÞâWɸ޿¾–ÂÛ¥ì(¿Èå_¿|ô·T4MC™60‚s�ˆfß‘~ºÙÊè_¹z®¦æW˜ï;ÔSnêu;S7³.`ì$xùwþÆ`¡&¢ì—9â¥%ÿT˜a×-YnŒ.äíkž›K+Cö©Ôgíþ7?ºXÆ=÷?lwªûŸÓq‘¾é6msÿ[ÖYìGY@¡¦?¬²WUÜiX³æÅ.©ÃæÎ‚-À0»$€iÂât›µcax«º²¬&�ßãÚÖù‹ìÑ“ÅS/ÓàhñŸo€G�qoüo7«øwUÿ5[Û&þW�*þiÀ¸þDæ]òÈoœŽ>S?•˜â”&cϯ^Àº�_Ï;yÔ?õÚî‡ÿåû܃Ë�ñÇÿœN§|ÿ—ï>yþÛí–‰ÿU`ýhŒXÜ!¡~È¡¶µªu†¦QÿPåëaÂðÎ
×d
}�fÉôj̲¬kÓäÛ.Îdq\rKæ—ãò�XnL1Ÿ-ò*[Õë
^K¨OƒùƒÃ¸€×ý5[j^ü›áœgé4Kw/¬†V_\è6�UÉ©¢êÂÆµYȇäEJŦˆ¥ÖëÁþà·ówûÃãÝ�…Ž®U¾_A)Q1Ð$æ5Ñ\¢.@j> "‹Ò.acø µ�`Wv]›w¤
c¼²I�牚¿[S^}ç A´c„ÕÔ2‚7‹$Á˜Í£Æê¦‘ßåw‰SœovJYôÞ9K$?'©ø¿Yÿ¹O\ÿuòú¯mòÿ*ðXõŸkê¿g�Åúï¡c_â¾øwí2þ›x´Uý×6ï?+ÁÍø¿½üÃh¼»±¸Ì*•àK9çqŠ¡˜Î>Ê‘ª_¦õ3¡i–Ä`Ë,ñÔf0000000000000000000000000000000000000000x6øŠµsé P