[Aboriginal] PIE

David Halls dahalls at gmail.com
Tue May 19 00:11:17 PDT 2015


This is what QEMU does:


  if compile_prog "-fPIE -DPIE" "-pie"; then
    QEMU_CFLAGS="-fPIE -DPIE $QEMU_CFLAGS"
    LDFLAGS="-pie $LDFLAGS"
    pie="yes"
    if compile_prog "" "-Wl,-z,relro -Wl,-z,now" ; then
      LDFLAGS="-Wl,-z,relro -Wl,-z,now $LDFLAGS"
    fi
  else
    if test "$pie" = "yes"; then
      error_exit "PIE not available due to missing toolchain support"
    else
      echo "Disabling PIE due to missing toolchain support"
      pie="no"
    fi
  fi

On 19 May 2015 at 07:43, David Halls <dahalls at gmail.com> wrote:
> -pie
>            Produce a position independent executable on targets that support
>            it.  For predictable results, you must also specify the same set of
>            options used for compilation (-fpie, -fPIE, or model suboptions)
>            when you specify this linker option.
>
> Also, it's what QEMU's configure step does to detect whether PIE is
> available :-)
>
> On 19 May 2015 at 07:38, Rob Landley <rob at landley.net> wrote:
>> On Mon, May 18, 2015 at 3:35 PM, David Halls <dahalls at gmail.com> wrote:
>>> ~ # cat wup.c
>>> int main(int argc, char **argv) { return 0; }
>>> ~ # gcc -fPIE -pie wup.c
>>
>> Why does it need both -fPIE and -pie ?
>>
>> (Trying to figure out what changes I need to make to ccwrap parsing.)
>>
>> Rob



More information about the Aboriginal mailing list