From patchwork Wed Aug 9 08:55:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 22003 Received: (qmail 85106 invoked by alias); 9 Aug 2017 08:55:19 -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 84539 invoked by uid 89); 9 Aug 2017 08:55:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.suse.de From: Andreas Schwab To: "H.J. Lu" Cc: GNU C Library Subject: Re: [PATCH] Don't use IFUNC resolver for longjmp or system in libpthread (bug 21041) References: X-Yow: It's the land of DONNY AND MARIE as promised in TV GUIDE! Date: Wed, 09 Aug 2017 10:55:14 +0200 In-Reply-To: (H. J. Lu's message of "Tue, 8 Aug 2017 07:57:02 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 I've commited this. Andreas. * nptl/Makefile (tests) [$(build-shared) = yes]: Add tst-compat-forwarder. (modules-names): Add tst-compat-forwarder-mod. ($(objpfx)tst-compat-forwarder): Depend on $(objpfx)tst-compat-forwarder-mod.so. * nptl/tst-compat-forwarder.c: New file. * nptl/tst-compat-forwarder-mod.c: New file. diff --git a/nptl/Makefile b/nptl/Makefile index 128a52eadc..9925f0f745 100644 --- a/nptl/Makefile +++ b/nptl/Makefile @@ -367,7 +367,7 @@ tests += tst-cancelx2 tst-cancelx3 tst-cancelx4 tst-cancelx5 \ tst-cleanupx0 tst-cleanupx1 tst-cleanupx2 tst-cleanupx3 tst-cleanupx4 \ tst-oncex3 tst-oncex4 ifeq ($(build-shared),yes) -tests += tst-atfork2 tst-tls4 tst-_res1 tst-fini1 +tests += tst-atfork2 tst-tls4 tst-_res1 tst-fini1 tst-compat-forwarder tests-internal += tst-tls3 tst-tls3-malloc tst-tls5 tst-stackguard1 tests-nolibpthread += tst-fini1 ifeq ($(have-z-execstack),yes) @@ -379,7 +379,7 @@ modules-names = tst-atfork2mod tst-tls3mod tst-tls4moda tst-tls4modb \ tst-tls5mod tst-tls5moda tst-tls5modb tst-tls5modc \ tst-tls5modd tst-tls5mode tst-tls5modf tst-stack4mod \ tst-_res1mod1 tst-_res1mod2 tst-execstack-mod tst-fini1mod \ - tst-join7mod + tst-join7mod tst-compat-forwarder-mod extra-test-objs += $(addsuffix .os,$(strip $(modules-names))) \ tst-cleanup4aux.o tst-cleanupx4aux.o test-extras += tst-cleanup4aux tst-cleanupx4aux @@ -718,6 +718,8 @@ $(objpfx)tst-oddstacklimit.out: $(objpfx)tst-oddstacklimit $(objpfx)tst-basic1 $(evaluate-test) endif +$(objpfx)tst-compat-forwarder: $(objpfx)tst-compat-forwarder-mod.so + # The tests here better do not run in parallel ifneq ($(filter %tests,$(MAKECMDGOALS)),) .NOTPARALLEL: diff --git a/nptl/tst-compat-forwarder-mod.c b/nptl/tst-compat-forwarder-mod.c new file mode 100644 index 0000000000..823bfa22de --- /dev/null +++ b/nptl/tst-compat-forwarder-mod.c @@ -0,0 +1,28 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Call the function system through a statically initialized pointer. */ + +#include + +int (*system_function) (const char *) = system; + +void +call_system (void) +{ + system_function (NULL); +} diff --git a/nptl/tst-compat-forwarder.c b/nptl/tst-compat-forwarder.c new file mode 100644 index 0000000000..f96806b7fe --- /dev/null +++ b/nptl/tst-compat-forwarder.c @@ -0,0 +1,35 @@ +/* Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Test that the compat forwaders in libpthread work correctly. */ + +#include + +extern void call_system (void); + +int +do_test (void) +{ + /* Calling the system function from a shared library that is not linked + against libpthread, when the main program is linked against + libpthread, should not crash. */ + call_system (); + + return 0; +} + +#include