This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: PR ld/16428: Disallow -shared/-pie, -shared/-static, -pie/-static


On Tue, 14 Jan 2014, H.J. Lu wrote:

> When there is -static, -dynamic-linker won't passed to ld.  -static,
> -shared, -pie should be mutually exclusive for GCC driver.

A static PIE shouldn't specify an interpreter; it should handle all 
dynamic relocation processing itself.  Thus, it's correct not to specify 
-dynamic-linker when building a static PIE.

ld.so itself is a static PIE - it specifies no PT_INTERP or DT_NEEDED, and 
is position-independent.  The concept of an arbitrary program meeting 
those conditions, including a copy of the relevant parts of the dynamic 
linker to relocate itself, is perfectly meaningful; it just so happens 
that glibc, and the associated GCC specs, don't support it, but I'm not 
aware of any fundamental problem with supporting it in ld given 
appropriate startup code and static libc built as PIC.  (I don't know how 
useful more general static PIE support would be.)

(-shared and -pie do seem mutually exclusive, as the first says what's 
being linked operates as a library and the second says it operates as an 
executable - although of course the same ET_DYN can operate as both.)

-- 
Joseph S. Myers
joseph@codesourcery.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]