Always create position independent executables

Ian Lance Taylor ian@airs.com
Mon May 2 18:54:00 GMT 2005


Simon Richter <Simon.Richter@hogyros.de> writes:

> I have a MMU-less platform (ARM uClinux) and would like to have ld
> create position independent executables by default. I figured that
> probably the easiest way to do so would be to set link_info.pie = TRUE
> from before_parse, however noone else appears to be doing that, and I'm
> pretty confident this is not the first MMU-less architecture using ELF. :-)
> 
> My current approach would be to add a new emulation armelf_uclinux /
> armelfb_uclinux that would always use -pie by setting link_info.pie and
> modifying genscripts.sh to accept a new parameter to not build non-PIE
> executable link scripts if a variable GENERATE_PIE_SCRIPT_ONLY is set
> (obviously, I'd leave relocatable links alone). Is that good, or am I
> completely wrong here?

Most people handle these issues in the compiler.  Just have the
compiler pass -pie when invoking the linker.

Adding a new emulation tends to be somewhat error-prone over time, as
people do not update all the existing emulations.  But you can do it
if you really want to.

Ian



More information about the Binutils mailing list