Re: [fbsd] Re: Symbol weirdness with static linking



Hi, Kostik,

On Thu, Apr 20, 2006 at 03:48:29PM +0300, Kostik Belousov wrote:
It seems that you rebuilt world with CFLAGS -fstack-protector,
since your libc has references to the symbols like __stack_smash_handler.
As result, when linking with sequence -lgcc -lssp -lc -lgcc -lssp,
and no references from the main object,
references from libc causes objects from _second_ instance of -lssp to
be pulled into the link. Since libraries are scanned sequentially,
this object from libssp has no way to get required dependencies
from libc.

What makes syslog(3) special is that corresponding object from libc,
syslog.o, requires __stack_smash_handler, while objects for mentioned
syscalls do not.

Probably, another -lc after -lssp will change the situation. But
I'm not sure would it be enough or not.

You got the point. If I add another -lc after the second -lssp,
this solves the problem :

/usr/bin/ld -V -Bstatic -o echo /usr/obj/usr/src/tmp/usr/lib/crt1.o /usr/obj/usr/src/tmp//usr/lib/crti.o /usr/obj/usr/src/tmp/usr/lib/crtbegin.o -L/usr/obj/usr/src/tmp/usr/lib echo.o -lgcc -lssp -lc /usr/obj/usr/src/tmp/usr/lib/crtend.o /usr/obj/usr/src/tmp/usr/lib/crtn.o

Another way to solve this is to group libraries using "-(" and "-)" ld(1)
options :

/usr/bin/ld -V -Bstatic -o echo /usr/obj/usr/src/tmp/usr/lib/crt1.o /usr/obj/usr/src/tmp/usr/lib/crti.o /usr/obj/usr/src/tmp/usr/lib/crtbegin.o -L/usr/obj/usr/src/tmp/usr/lib echo.o -lgcc -lssp -\( -lc -lgcc -lssp -\) /usr/obj/usr/src/tmp/usr/lib/crtend.o /usr/obj/usr/src/tmp/usr/lib/crtn.o

Thank you for your answer.
Best regards,
--
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Symbol weirdness with static linking
    ... references whenever it has to protect a function. ... When libssp is linked dynamically, ... while there are other calls to libc functions in libssp ... Since libraries are scanned sequentially, ...
    (freebsd-hackers)
  • Re: [fbsd] Re: [fbsd] Re: Symbol weirdness with static linking
    ... references from libc causes objects from _second_ instance of -lssp to ... undefined symbols implies the second libssp to be pulled in which in ... archive than "sigfillset" but this is not the case. ...
    (freebsd-hackers)
  • Re: [fbsd] Re: Symbol weirdness with static linking
    ... references from libc causes objects from _second_ instance of -lssp to ... undefined symbols implies the second libssp to be pulled in which in ... archive than "sigfillset" but this is not the case. ...
    (freebsd-hackers)
  • Re: [fbsd] Re: Where is thr_getscheduler
    ... References to symbols in libthr.so.2 are satisfied by default ... libc symbols is absent in the shared libraries. ... In this post Warner Losh states that doing so would solve some ...
    (freebsd-current)
  • chroot() and dlopen()
    ... Should dlopenbe able to work when chroot() into another directory, ... I'm wondering if the references ... The executable will be dynamically linked with libc and other libraries ...
    (comp.unix.programmer)