diff mbox

[RFC,1/3] build: LDFLAGS pass -pie flag explicitly to ld

Message ID 20170718104008.9624-2-npiggin@gmail.com
State Accepted
Headers show

Commit Message

Nicholas Piggin July 18, 2017, 10:40 a.m. UTC
When building with some toolchains, the gcc -pie option does not
enable the linker pie without explicitly passing it to ld,
resulting in a non-PIE binary that silently fails (due to
relocation failure). This was observed with the powerpc64le
cross compiler for Debian.

Pass -Wl,-pie explicitly, which allows the powerpc64le toolchain
to create a position independnet binary that boots.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 Makefile.main | 1 +
 1 file changed, 1 insertion(+)
diff mbox

Patch

diff --git a/Makefile.main b/Makefile.main
index 438dcb27..c421cbc6 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -106,6 +106,7 @@  CFLAGS += $(call try-cflag,$(CC),-Wjump-misses-init) \
 CFLAGS += $(CWARNS) $(OPTS) $(DBG)
 
 LDFLAGS := -m64 -static -nostdlib -pie 
+LDFLAGS += -Wl,-pie
 LDFLAGS += -Wl,-Ttext-segment,$(LD_TEXT) -Wl,-N -Wl,--build-id=none
 LDFLAGS += -Wl,--no-multi-toc
 LDFLAGS += -mbig-endian -Wl,--oformat,elf64-powerpc