From patchwork Tue Mar 8 13:50:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 11262 Received: (qmail 33813 invoked by alias); 8 Mar 2016 13:54:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 33757 invoked by uid 89); 8 Mar 2016 13:54:34 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.0 required=5.0 tests=AWL, BAYES_40, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=Hx-spam-relays-external:sk:mail.es, HX-HELO:sk:mail.es, H*r:sk:mail.es, H*RU:sk:mail.es X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Subject: [PATCH 07/18] Compile the entire dynamic linker with -fno-stack-protector. Date: Tue, 8 Mar 2016 13:50:53 +0000 Message-Id: <1457445064-7107-8-git-send-email-nix@esperi.org.uk> In-Reply-To: <1457445064-7107-1-git-send-email-nix@esperi.org.uk> References: <1457445064-7107-1-git-send-email-nix@esperi.org.uk> X-DCC--Metrics: spindle 1282; Body=2 Fuz1=2 Fuz2=2 From: Nick Alcock Also compile corresponding routines in the static libc.a with the same flag. v3: Use $(no-stack-protector). Introduce $(elide-stack-protector) and use it to reduce redundancy. Bring all the elisions together textually. * elf/Makefile (elide-stack-protector): New. (CFLAGS-.os): Use it, eliding $(all-rtld-routines). (CFLAGS-.oX): Likewise, eliding $(elide-routines.os). (rtld-CFLAGS): Likewise. --- elf/Makefile | 13 +++++++++++++ elf/rtld-Rules | 2 ++ 2 files changed, 15 insertions(+) diff --git a/elf/Makefile b/elf/Makefile index 63a5355..0037cca 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -50,6 +50,19 @@ CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-dl-iterate-phdr.c = $(uses-callbacks) +# Compile rtld itself without stack protection. +# Also compile all routines in the static library that are elided from +# the shared libc because they are in ld.so the same way. + +define elide-stack-protector +$(if $(filter $(@F),$(patsubst %,%$(1),$(2))), $(no-stack-protector)) +endef + +CFLAGS-.o += $(call elide-stack-protector,.o,$(elide-routines.os)) +CFLAGS-.op += $(call elide-stack-protector,.op,$(elide-routines.os)) +CFLAGS-.og += $(call elide-stack-protector,.og,$(elide-routines.os)) +CFLAGS-.os += $(call elide-stack-protector,.os,$(all-rtld-routines)) + ifeq ($(unwind-find-fde),yes) routines += unwind-dw2-fde-glibc shared-only-routines += unwind-dw2-fde-glibc diff --git a/elf/rtld-Rules b/elf/rtld-Rules index c1bb506..aff4e3e 100644 --- a/elf/rtld-Rules +++ b/elf/rtld-Rules @@ -144,4 +144,6 @@ cpp-srcs-left := $(rtld-modules:%.os=%) lib := rtld include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) +rtld-CFLAGS := $(no-stack-protector) + endif