Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jul 2010 14:22:34 +0300
From:      Kostik Belousov <kostikbel@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Using lex in a shared library
Message-ID:  <20100703112234.GE13238@deviant.kiev.zoral.com.ua>
In-Reply-To: <20100703100811.GA1605@britannica.bec.de>
References:  <AANLkTilp0zvMRbw96cifhIzmT4YbNVkxgOFZFa_nvl2m@mail.gmail.com> <AANLkTimGsM7Ibaryx6e3gLSy5xpkpYxQmE3w5gAwlXXD@mail.gmail.com> <AANLkTikWqJgfETncKV3pEZ8JgxzcAsALFGtSk_dYNxbl@mail.gmail.com> <4C2E7BCD.4020609@delphij.net> <20100703100811.GA1605@britannica.bec.de>

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

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

On Sat, Jul 03, 2010 at 12:08:11PM +0200, Joerg Sonnenberger wrote:
> On Fri, Jul 02, 2010 at 04:52:45PM -0700, Xin LI wrote:
> > I think that amd64 requires a static library be compiled with -fPIC if
> > it's being linked into shared object.  This should not be done for
> > normal static libraries, though, as this could give some performance
> > penalty when it's not needed (i.e. a static binary).
>=20
> More precisely, AMD64 disallows absolute references in the text segment.
> The performance penalty for PIC on AMD64 is minimal as it can do
> RIP-relative addressing.
Even more precisely, amd64 does not disallow such references, it only
disallows the 32bit signed relocations. The reasoning is that shared
object may be loaded at arbitrary location at the process address space,
and correct relocation might be larger then can be fi in 32 signed bit.

The solution is either use PIC, thus going through PLT, or use big
(or whatever is called) memory model when compiling, that makes
all relocations 64 bit, with obvious performance penalty.

--GLnf9Go3l6tdAkV+
Content-Type: application/pgp-signature
Content-Disposition: inline

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

iEYEARECAAYFAkwvHXoACgkQC3+MBN1Mb4jAqACeMxEbv/42NYE8UarvlhBIEAYy
MfgAoK5ggZopU0CeNGx63FNP+119/KmC
=OMow
-----END PGP SIGNATURE-----

--GLnf9Go3l6tdAkV+--



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