From patchwork Fri Feb 6 20:19:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 437452 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id F2D561401AB for ; Sat, 7 Feb 2015 07:20:30 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:content-type :content-transfer-encoding:from:to:subject:in-reply-to :references:message-id:date; q=dns; s=default; b=KY0qFooOICTzju2 riC+IbKPdF5FEvVYwMShl7ws11A8cvny0HA1gbPFBz/ahVsgbaOg1H2GCbyhkx6R 1Ti7U0FXhKzoDzXGTPb/L8AabyXuMuOTjr7gjxLO1UftOrwMi2eTNQnEMIBMCNWu ltAfHpKfMk9cMfJlXXcg0624InDE= 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:mime-version:content-type :content-transfer-encoding:from:to:subject:in-reply-to :references:message-id:date; s=default; bh=yuLicIoY5Ndwk9fqj5Csy UdzYNI=; b=BiXkdhUcgeLqWZoc1TBQp0+mKNwBC/Lv4aK8oy0yoYrgoBhdMBIvo 3jTcwCgEXoIYmvC6GuCxlVpKcz0osWO95GmRINZaui3bvMgG3EtKVCa/ZKAlmwJd ewJgH/GCuJNIXher69WOHMkZf3oDm1mGNrzn+folj+CC1dn3cLHva0= Received: (qmail 12021 invoked by alias); 6 Feb 2015 20:19:30 -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 12002 invoked by uid 89); 6 Feb 2015 20:19:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00 autolearn=ham version=3.3.2 X-HELO: topped-with-meat.com MIME-Version: 1.0 From: Roland McGrath To: "GNU C. Library" Subject: [COMMITTED PATCH 2/3] Clean up NPTL longjmp to be compat-only. In-Reply-To: Roland McGrath's message of Friday, 6 February 2015 12:18:43 -0800 <20150206201843.AD5922C3A9B@topped-with-meat.com> References: <20150206201843.AD5922C3A9B@topped-with-meat.com> Message-Id: <20150206201926.EB1F52C3A9B@topped-with-meat.com> Date: Fri, 6 Feb 2015 12:19:26 -0800 (PST) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=SvUDtp+0 c=1 sm=1 tr=0 a=WkljmVdYkabdwxfqvArNOQ==:117 a=14OXPxybAAAA:8 a=kj9zAlcOel0A:10 a=hOe2yjtxAAAA:8 a=20KFwNOVAAAA:8 a=mDV3o1hIAAAA:8 a=7II67sOAXuIzT_6cHIAA:9 a=CjuIK1q_8ugA:10 I don't know if there was a historical reason for libpthread to have a longjmp wrapper, but there is certainly none in the current code. This change makes it compat-only. Tested x86_64-linux-gnu. Thanks, Roland * nptl/pt-longjmp.c: Rewritten. Put everything under [SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)]. Use IFUNC to redirect when possible. --- a/nptl/pt-longjmp.c +++ b/nptl/pt-longjmp.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. +/* ABI compatibility for 'longjmp' and 'siglongjmp' symbols in libpthread ABI. + Copyright (C) 2002-2015 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2002. @@ -17,12 +18,55 @@ . */ #include -#include -#include "pthreadP.h" +#include -void -longjmp (jmp_buf env, int val) +/* libpthread once had its own longjmp (and siglongjmp alias), though there + was no apparent reason for it. There is no use in having a separate + symbol in libpthread, but the historical ABI requires it. For static + linking, there is no need to provide anything here--the libc version + will be linked in. For shared library ABI compatibility, there must be + longjmp and siglongjmp symbols in libpthread.so; so we define them using + IFUNC to redirect to the libc function. */ + +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) + +# if HAVE_IFUNC + +static __typeof (longjmp) * +__attribute__ ((used)) +longjmp_resolve (void) +{ + return &__libc_longjmp; +} + +# ifdef HAVE_ASM_SET_DIRECTIVE +# define DEFINE_LONGJMP(name) \ + asm (".set " #name ", longjmp_resolve\n" \ + ".globl " #name "\n" \ + ".type " #name ", %gnu_indirect_function"); +# else +# define DEFINE_LONGJMP(name) \ + asm (#name " = longjmp_resolve\n" \ + ".globl " #name "\n" \ + ".type " #name ", %gnu_indirect_function"); +# endif + +# else /* !HAVE_IFUNC */ + +static void __attribute__ ((noreturn, used)) +longjmp_compat (jmp_buf env, int val) { __libc_longjmp (env, val); } -weak_alias (longjmp, siglongjmp) + +# define DEFINE_LONGJMP(name) strong_alias (longjmp_compat, name) + +# endif /* HAVE_IFUNC */ + +DEFINE_LONGJMP (longjmp_ifunc) +compat_symbol (libpthread, longjmp_ifunc, longjmp, GLIBC_2_0); + +DEFINE_LONGJMP (siglongjmp_ifunc) +compat_symbol (libpthread, siglongjmp_ifunc, siglongjmp, GLIBC_2_0); + +#endif