From patchwork Tue Feb 23 23:39:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 11028 Received: (qmail 52940 invoked by alias); 23 Feb 2016 23:40:10 -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 52829 invoked by uid 89); 23 Feb 2016 23:40:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.1 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=op, og, sk:shared, sk:shared- X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Cc: carlos@redhat.com Subject: [PATCH 06/14] Compile the entire dynamic linker with -fno-stack-protector. Date: Tue, 23 Feb 2016 23:39:29 +0000 Message-Id: <1456270777-9083-7-git-send-email-nix@esperi.org.uk> In-Reply-To: <1456270777-9083-1-git-send-email-nix@esperi.org.uk> References: <1456270777-9083-1-git-send-email-nix@esperi.org.uk> X-DCC-wuwien-Metrics: spindle 1290; Body=2 Fuz1=2 Fuz2=2 From: Nick Alcock Also compile corresponding routines in the static libc.a with the same flag. --- elf/Makefile | 13 +++++++++++++ elf/rtld-Rules | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/elf/Makefile b/elf/Makefile index 63a5355..0cb03b0 100644 --- a/elf/Makefile +++ b/elf/Makefile @@ -50,6 +50,16 @@ CFLAGS-dl-runtime.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-dl-lookup.c = -fexceptions -fasynchronous-unwind-tables CFLAGS-dl-iterate-phdr.c = $(uses-callbacks) +ifeq ($(have-ssp),yes) +# In the dynamic loader, some routines (which include routines called before +# the stack guard is initialized) are compiled without stack protection. +# Do the same when those routines are found in the static library. + +CFLAGS-.o += $(if $(filter $(@F),$(patsubst %,%.o,$(elide-routines.os))),-fno-stack-protector) +CFLAGS-.op += $(if $(filter $(@F),$(patsubst %,%.op,$(elide-routines.os))),-fno-stack-protector) +CFLAGS-.og += $(if $(filter $(@F),$(patsubst %,%.og,$(elide-routines.os))),-fno-stack-protector) +endif + ifeq ($(unwind-find-fde),yes) routines += unwind-dw2-fde-glibc shared-only-routines += unwind-dw2-fde-glibc @@ -468,6 +478,9 @@ libof-ldconfig = ldconfig CFLAGS-dl-cache.c = $(SYSCONF-FLAGS) CFLAGS-cache.c = $(SYSCONF-FLAGS) CFLAGS-rtld.c = $(SYSCONF-FLAGS) +ifeq ($(have-ssp),yes) +CFLAGS-.os += $(if $(filter $(@F),$(patsubst %,%.os,$(all-rtld-routines))),-fno-stack-protector) +endif cpp-srcs-left := $(all-rtld-routines:=.os) lib := rtld diff --git a/elf/rtld-Rules b/elf/rtld-Rules index c1bb506..1d571d3 100644 --- a/elf/rtld-Rules +++ b/elf/rtld-Rules @@ -144,4 +144,8 @@ cpp-srcs-left := $(rtld-modules:%.os=%) lib := rtld include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left)) +ifeq ($(have-ssp),yes) +rtld-CFLAGS := -fno-stack-protector +endif + endif