From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 62221 invoked by alias); 14 Feb 2020 22:36:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 62213 invoked by uid 89); 14 Feb 2020 22:36:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-19.0 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581719793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DV5hIatT9GhSo9fYbKX/ue3TggC40IWfQ+IUaNKJ1go=; b=dWSQ/2UAIjViOUTuyD5m4kuIAyvYozBQGeS6huTL9EAtWvcoa4lIfwlXb6siNZTcFDIYf0 CaUMGoLWFUi0Bx6GoGyCz4qYQkBwiOKxwrCtJ93+3tmzwt4elj2YJnWRGixIzISI+2tT8i UMZTvhVDTm8k/zTi6jZ0Co5/krHtnBY= Return-Path: Subject: Re: [PATCH 1/4] elf: Introduce the rtld-stubbed-symbols makefile variable To: Florian Weimer , libc-alpha@sourceware.org References: <3e85b3e4993068ae16d283c548c17823106f132a.1581182210.git.fweimer@redhat.com> From: Carlos O'Donell Message-ID: <1d569ea5-e1ad-79c3-87f4-6c321fa2336c@redhat.com> Date: Fri, 14 Feb 2020 22:36:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <3e85b3e4993068ae16d283c548c17823106f132a.1581182210.git.fweimer@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg00694.txt.bz2 On 2/8/20 2:00 PM, Florian Weimer wrote: > This generalizes a mechanism used for stack-protector support, so > that it can be applied to other symbols if required. > > Tested on i686-linux-gnu without the stack protector, and on > x86_64-linux-gnu with stack-protector-strong. OK for master. Reviewed-by: Carlos O'Donell > --- > elf/Makefile | 22 +++++++++++++--------- > 1 file changed, 13 insertions(+), 9 deletions(-) > > diff --git a/elf/Makefile b/elf/Makefile > index 632a4d8b0f..60c8082d06 100644 > --- a/elf/Makefile > +++ b/elf/Makefile > @@ -482,21 +482,25 @@ $(objpfx)dl-allobjs.os: $(all-rtld-routines:%=$(objpfx)%.os) > # are compiled with special flags, and puts these modules into rtld-libc.a > # for us. Then we do the real link using rtld-libc.a instead of libc_pic.a. > > -# If the compiler can do SSP, build the mapfile with dummy __stack_chk_fail > -# and __stack_chk_fail_local symbols defined, to prevent the real things > -# being dragged into rtld even though rtld is never built with stack- > -# protection. > +# These symbols need to be stubbed out during symbol discovery because > +# their implementation is provided differently in rtld, and the symbol > +# discovery mechanism is not compatible with the libc implementation > +# when compiled for libc. > +rtld-stubbed-symbols = > + > +# The GCC arguments that implement $(rtld-stubbed-symbols). > +rtld-stubbed-symbols-args = \ > + $(patsubst %,-Wl$(comma)--defsym=%=0, $(rtld-stubbed-symbols)) > > ifeq ($(have-ssp),yes) > -dummy-stack-chk-fail := -Wl,--defsym='__stack_chk_fail=0' \ > - -Wl,--defsym='__stack_chk_fail_local=0' > -else > -dummy-stack-chk-fail := > +# rtld is not built with the stack protector, so these references will > +# go away in the rebuilds. > +rtld-stubbed-symbols += __stack_chk_fail __stack_chk_fail_local > endif > > $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a > @-rm -f $@T > - $(reloc-link) -o $@.o $(dummy-stack-chk-fail) \ > + $(reloc-link) -o $@.o $(rtld-stubbed-symbols-args) \ > '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T > rm -f $@.o > mv -f $@T $@ > -- Cheers, Carlos.