Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Sep 2010 22:27:08 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Jeremie Le Hen <jeremie@le-hen.org>
Cc:        kan@freebsd.org, freebsd-hackers@freebsd.org
Subject:   Re: [PATCH] Add -lssp_nonshared to GCC's LIB_SPEC unconditionally
Message-ID:  <20100920192708.GK2389@deviant.kiev.zoral.com.ua>
In-Reply-To: <20100920162925.GL6864@felucia.tataz.chchile.org>
References:  <20100803150545.GH14016@felucia.tataz.chchile.org> <20100803114651.651e0ea4@kan.dnsalias.net> <20100805191446.GJ14016@felucia.tataz.chchile.org> <20100919081406.GH6864@felucia.tataz.chchile.org> <20100919184146.GE2389@deviant.kiev.zoral.com.ua> <20100920162925.GL6864@felucia.tataz.chchile.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--dyTp/pkqtoagvozp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Sep 20, 2010 at 06:29:25PM +0200, Jeremie Le Hen wrote:
> Kostik,
>=20
> On Sun, Sep 19, 2010 at 09:41:46PM +0300, Kostik Belousov wrote:
> > On Sun, Sep 19, 2010 at 10:14:06AM +0200, Jeremie Le Hen wrote:
> > > Hi Alexander,
> > >=20
> > > On Thu, Aug 05, 2010 at 09:14:46PM +0200, Jeremie Le Hen wrote:
> > > > On Tue, Aug 03, 2010 at 11:46:51AM -0400, Alexander Kabaev wrote:
> > > > >
> > > > > I have no objection, but think we should cave in and investigate =
the
> > > > > possibility of using linker script wrapping libc.so in FreeBSD-9.=
0:
> > > > >=20
> > > > > Below is Linux' counterpart:
> > > > >=20
> > > > > /* GNU ld script
> > > > >    Use the shared library, but some functions are only in
> > > > >    the static library, so try that secondarily.  */
> > > > > OUTPUT_FORMAT(elf32-i386)
> > > > > GROUP ( /lib/libc.so.6 /usr/lib/libc_nonshared.a  AS_NEEDED
> > > > > ( /lib/ld-linux.so.2 ) )
> > > >=20
> > > > Ok.  For now can you commit the proposed modification.  I'll try to=
 make
> > > > a patch with your proposal.
> > >=20
> > > The attached patch does two things: It modifies bsd.lib.mk to support=
 ld
> > > scripts for shared libraries and adds such a script to replace the
> > > /usr/lib/libc.so symlink to /lib/libc.so.X.
> > >=20
> > > Basically, SHLIB_LDSCRIPT is defined in lib/libc/Makefile and points =
to
> > > the file containing the script itself:
> > >     GROUP ( @@SHLIB@@ /usr/lib/libssp_nonshared.a )
> > >=20
> > > During make install, @@SHLIB@@ will be replaced by the real path of t=
he
> > > shared library.
> >=20
> > You did not included $FreeBSD$ tag into libc.so script. I think it woul=
d be
> > useful to have.
>=20
> Sure.  I will send an updated patch a little later.
>=20
> > Could you, please, comment why the script is not installed during the
> > world build stage ? My question is, would the buildworld use the script
> > for linkage ?
>=20
> libc.ld, the generated ldscript in ${.OBJDIR}, is built along with
> libc.so.7 which is built only once (stage 4.2 of buildworld).
>=20
> In order to get buildworld use the ld script, it would require to
> generate it twice: once during stage 4.2 using
> /usr/obj/usr/src/tmp/lib/libc.so.7 and another one afterward using
> /lib/libc.so.7.
>=20
> Besides I didn't see an advantage to do this because when compiling the
> base system, CFLAGS and LDFLAGS are well controlled so -fstack-protector
> will be provided when linking the program.  On the other hand, the patch
> I propose is required for the numerous ports for which we do not control
> linking flags; lang/perl comes into my mind.  If you want to compile it
> with SSP, you have to patch its build infrastructure (see ports/138228).

You make the script only useful for the stack protection. If build process
does not use libc.so script, but installed system does, you
- require to maintain two places where (not much) hypothetical libc
  changes should go;
- make it very puzzling to debug the issues with the build of the usermode.

Please, do this in the consistent manner, so that the script can be adopted
for other uses.

--dyTp/pkqtoagvozp
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (FreeBSD)

iEYEARECAAYFAkyXtYwACgkQC3+MBN1Mb4hIUwCfenawEo+oOW3yd1zCt1wImfEf
qPUAoNy5G06i0ZBp8tdLeaLdWl6ywivp
=qYu3
-----END PGP SIGNATURE-----

--dyTp/pkqtoagvozp--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100920192708.GK2389>