From patchwork Sat Feb 20 10:23:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nix X-Patchwork-Id: 10962 Received: (qmail 17985 invoked by alias); 20 Feb 2016 10:24:53 -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 17860 invoked by uid 89); 20 Feb 2016 10:24:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.7 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy=op, og, UD:os, libc.a X-HELO: mail.esperi.org.uk From: Nix To: libc-alpha@sourceware.org Cc: carlos@redhat.com Subject: [PATCH 06/12] Compile the entire dynamic linker with -fno-stack-protector. Date: Sat, 20 Feb 2016 10:23:40 +0000 Message-Id: <1455963826-21885-7-git-send-email-nix@esperi.org.uk> In-Reply-To: <1455963826-21885-1-git-send-email-nix@esperi.org.uk> References: <1455963826-21885-1-git-send-email-nix@esperi.org.uk> 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