From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 9EECE1F5A2 for ; Sat, 8 Feb 2020 19:01:15 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=bc/cLELpkJ3yoseZ LZ9mmv9IVqzzqo8lKVEix7n3EFOF11c2Vldn5p16CB/RcV999Z7eyyBV+/R1vWhH moNU5EawEbqZZLrFngWdx9wSXg3BkXT7sfI8OPnlzibxLLbyXPPiTPiczAcz0lDY jTu9Vj5DvFlbmnlbEVtbtxLKPzo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:in-reply-to:references :message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=8Jbv7/fw1vLz1CIpxCWv42 xgdZw=; b=ViLZy8SyPzm0Zmz+QOIKZbTPZeLfW1GyDaPt6+6yUFaHKyFqweV3UF 2AoP61JS7sL1GU94qTvpC0GGQ+83LhtubN3keMyxtxgdkQITa0tQIcdFo2hUgpI+ RI9e/ioSo5w2aC1pLuVv5qNToNv/r32TqUira6HUE+B2bWVgZYG58= Received: (qmail 65692 invoked by alias); 8 Feb 2020 19:01:05 -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 Received: (qmail 65626 invoked by uid 89); 8 Feb 2020 19:00:58 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: us-smtp-delivery-1.mimecast.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1581188455; 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=Q6++1TBZIWhxBuvIDVRKiA0zzqwY89NlcgM7HqWoYlQ=; b=GWPPWaqz4JbNyqZsF2Q7CuYoX8mYUYw8AdxspTkc1WEIsTVoLpSuljAodv7qmTMkMrGdtx 6g6CCrQmXf7RemP9uxn9lb7SeOp00XMrWbKJoXP+4dM9ynnqfe8isaYSeN2Qsdj7Eogfy6 en5PaQSkyriES7kgWtPN9Vc0VcepyIM= From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH 1/4] elf: Introduce the rtld-stubbed-symbols makefile variable In-Reply-To: References: Message-Id: <3e85b3e4993068ae16d283c548c17823106f132a.1581182210.git.fweimer@redhat.com> Date: Sat, 08 Feb 2020 20:00:49 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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. --- 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:%=3D$(obj= pfx)%.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. =20 -# If the compiler can do SSP, build the mapfile with dummy __stack_chk_fai= l -# 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 =3D + +# The GCC arguments that implement $(rtld-stubbed-symbols). +rtld-stubbed-symbols-args =3D \ + $(patsubst %,-Wl$(comma)--defsym=3D%=3D0, $(rtld-stubbed-symbols)) =20 ifeq ($(have-ssp),yes) -dummy-stack-chk-fail :=3D -Wl,--defsym=3D'__stack_chk_fail=3D0' \ -=09=09=09-Wl,--defsym=3D'__stack_chk_fail_local=3D0' -else -dummy-stack-chk-fail :=3D +# rtld is not built with the stack protector, so these references will +# go away in the rebuilds. +rtld-stubbed-symbols +=3D __stack_chk_fail __stack_chk_fail_local endif =20 $(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a =09@-rm -f $@T -=09$(reloc-link) -o $@.o $(dummy-stack-chk-fail) \ +=09$(reloc-link) -o $@.o $(rtld-stubbed-symbols-args) \ =09=09'-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T =09rm -f $@.o =09mv -f $@T $@ --=20 2.24.1