PATCH: PR ld/16428: Disallow -shared/-pie, -shared/-static, -pie/-static
Joseph S. Myers
joseph@codesourcery.com
Tue Jan 14 19:37:00 GMT 2014
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
More information about the Binutils
mailing list