* Jiri Jaburek:

> On 09/12/16 13:42, Jakub Wilk wrote:
>> * Bálint Réczey <bal...@balintreczey.hu>, 2016-09-12, 13:21:
>>>> Reading up on the subject so far, I got the impression that most
>>>> static libraries should be built with PIE, but not necessarily PIC
>>>> (to allow building PIE(xecutable)s, but discourage creating shared
>>>> libraries from those static ones.)
>> How does it discourage creating shlibs?
>> Also, is there a reliable way for a static checker (such as Lintian) to
>> distinguish between -fPIC and -fPIE static libraries?
> There is (kinda),
> https://sourceware.org/ml/libc-alpha/2015-03/msg00605.html

Yes, but we have moved on, and PIE has received optimizations since
then which reduce the cost on platforms with PC-relative loads and
stores.  These optimizations eliminate unneeded redirections, but also
make the resulting objects incompatible with full PIC mode.

Without PIC, ELF dynamic linking allocates global variables referenced
from the main program as if defined in the main program, and patches
all DSOs to reference those global variables.  This mechanism ensures
that the objects which go into the main executable do not need to
determine, at compile time, whether a variable reference ends up
resolving to a definition in a DSO or not.

Reply via email to