]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Add WITH_PIE knob to build Position Independent Executables
authorEd Maste <emaste@FreeBSD.org>
Thu, 26 Sep 2019 16:05:57 +0000 (16:05 +0000)
committerEd Maste <emaste@FreeBSD.org>
Thu, 26 Sep 2019 16:05:57 +0000 (16:05 +0000)
commit0d5bda912521220c1a2061f9177dbaa6ff2f9c13
tree8c596270fd97ad57f9f0c62ed513c109b16f551e
parentf759141fc2b2f4a87d63367919f4c4db557ddfc9
Add WITH_PIE knob to build Position Independent Executables

MFC r344179: Add WITH_PIE knob to build Position Independent Executables

Building binaries as PIE allows the executable itself to be loaded at a
random address when ASLR is enabled (not just its shared libraries).

With this change PIE objects have a .pieo extension and INTERNALLIB
libraries libXXX_pie.a.

MK_PIE is disabled for some kerberos5 tools, Clang, and Subversion, as
they explicitly reference .a libraries in their Makefiles.  These can
be addressed on an individual basis later.  MK_PIE is also disabled for
rtld-elf because it is already position-independent using bespoke
Makefile rules.

Currently only dynamically linked binaries will be built as PIE.

MFC r344181: Fix Makefile conditional after r344179

MFC r344182: Use make's :tl instead of checking "no" and "NO"

MFC r344189: Fixup bsd.prog.mk after r344182

MFC r344211: wlandebug: disable PIE to fix build failure

libifconfig is built as a static-only PRIVATELIB (and there is no _pie.a
version) so disable PIE in libifconfig's consumer.

r345489: Fix GNU objdump build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

r345490: Apply WITH_PIE changes to other binutils components

Followon to r345489, explicitly specified bare .a libraries need
${PIE_SUFFIX} (although these still built).

r345778: Fix gdb/kgdb build under WITH_PIE

Explicitly specified bare .a libraries need ${PIE_SUFFIX}.

Sponsored by: The FreeBSD Foundation
20 files changed:
gnu/usr.bin/binutils/as/Makefile
gnu/usr.bin/binutils/ld/Makefile
gnu/usr.bin/binutils/objcopy/Makefile
gnu/usr.bin/binutils/objdump/Makefile
gnu/usr.bin/gdb/gdb/Makefile
gnu/usr.bin/gdb/kgdb/Makefile
kerberos5/tools/asn1_compile/Makefile
kerberos5/tools/slc/Makefile
lib/clang/Makefile.inc
libexec/rtld-elf/Makefile
share/mk/bsd.lib.mk
share/mk/bsd.opts.mk
share/mk/bsd.prog.mk
share/mk/src.libnames.mk
stand/i386/Makefile.inc
tools/build/options/WITHOUT_PIE [new file with mode: 0644]
tools/build/options/WITH_PIE [new file with mode: 0644]
usr.bin/clang/Makefile.inc
usr.bin/svn/Makefile.inc
usr.sbin/wlandebug/Makefile