From 004e537d30f54fb6beb4d325458ee3b529a7219e Mon Sep 17 00:00:00 2001 From: cancel Date: Fri, 30 Nov 2018 20:12:58 +0900 Subject: [PATCH] Fix bad LLD codegen from PIE flags in build tool --- tool | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tool b/tool index a6ad94c..15864fe 100755 --- a/tool +++ b/tool @@ -161,7 +161,15 @@ build_target() { add cc_flags -fuse-ld=lld fi if [[ $protections_enabled = 1 ]]; then - add cc_flags -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie -Wl,-pie + add cc_flags -D_FORTIFY_SOURCE=2 -fstack-protector-strong -fpie + if [[ $lld_detected = 1 ]]; then + # LLD seems to need this or it fails at linking. If we also pass -Wl,-pie + # then the built binary will crash before reaching main(). + add cc_flags -Wl,-z,notext + else + # This is the one that works everywhere else.. hmm + add cc_flags -Wl,-pie + fi fi case "$1" in debug)