From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 20 13:17:34 2006 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6533816A403 for ; Thu, 20 Apr 2006 13:17:34 +0000 (UTC) (envelope-from tataz@tataz.chchile.org) Received: from smtp4-g19.free.fr (smtp4-g19.free.fr [212.27.42.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id F020243D45 for ; Thu, 20 Apr 2006 13:17:33 +0000 (GMT) (envelope-from tataz@tataz.chchile.org) Received: from tatooine.tataz.chchile.org (tataz.chchile.org [82.233.239.98]) by smtp4-g19.free.fr (Postfix) with ESMTP id 3A2A254974; Thu, 20 Apr 2006 15:17:33 +0200 (CEST) Received: from obiwan.tataz.chchile.org (unknown [192.168.1.25]) by tatooine.tataz.chchile.org (Postfix) with ESMTP id 462919BD8D; Thu, 20 Apr 2006 13:17:32 +0000 (UTC) Received: by obiwan.tataz.chchile.org (Postfix, from userid 1000) id 2E74F405B; Thu, 20 Apr 2006 15:17:32 +0200 (CEST) Date: Thu, 20 Apr 2006 15:17:32 +0200 From: Jeremie Le Hen To: Kostik Belousov Message-ID: <20060420131732.GA68951@obiwan.tataz.chchile.org> References: <20060420114822.GB35261@obiwan.tataz.chchile.org> <20060420124829.GA1446@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060420124829.GA1446@deviant.kiev.zoral.com.ua> User-Agent: Mutt/1.5.11 Cc: freebsd-hackers@freebsd.org Subject: Re: [fbsd] Re: Symbol weirdness with static linking X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Apr 2006 13:17:34 -0000 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 >