From patchwork Fri Feb 6 20:18:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roland McGrath X-Patchwork-Id: 437451 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 C66D01401AB for ; Sat, 7 Feb 2015 07:19:14 +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:message-id:date; q= dns; s=default; b=XMQn+ihsKbxTRvksa39UD1Nwd6cfJGg/aES53u7NZp3APi CYcnYbOOliKE2DyK85pAIuCVRIFeDyzzzmK87l3jpC8Pqn2DfEUGjqqS8zgWHRGa 2zhKoVUtyKE6BnLuVD03ERz26lAmoCrn2caOo1xxcfaOLMd6OAvFY6adBbv4E= 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:message-id:date; s= default; bh=D6oGcbqNQE7ksv0vukUZEr2nFvo=; b=W9xFVndQq5UY1sxjxxY7 9fYtbzccooaibPqXWw4c0hdzowzt1aeKUWjkYVfjzr25vVXVX0U7ofpH7pjt0xYf 6c6hDIBJtzkmB2VOyG7TEiiG+KLbblVHno3IMPmkrc8DOa2Vh08EBDTZaXw4MZw0 yqjmx0cdEW8iMRwQvF/4R34= Received: (qmail 11092 invoked by alias); 6 Feb 2015 20:18:48 -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 11083 invoked by uid 89); 6 Feb 2015 20:18:47 -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 1/3] Clean up NPTL fork to be compat-only. Message-Id: <20150206201843.AD5922C3A9B@topped-with-meat.com> Date: Fri, 6 Feb 2015 12:18:43 -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=tQnsh02B3uN3L_t_jLQA:9 a=CjuIK1q_8ugA:10 I don't know if there was a historical reason for libpthread to have a fork wrapper, but there is certainly none in the current code. This change makes it compat-only. It's similar to what I did for vfork, but simpler for the no-IFUNC case since it doesn't matter whether the tail call is proper or not. Tested x86_64-linux-gnu. Thanks, Roland * nptl/pt-fork.c: Rewritten. Put everything under [SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)]. Use IFUNC to redirect when possible. * nptl/Versions (libpthread: GLIBC_2.22): New (empty) version set. --- a/nptl/Versions +++ b/nptl/Versions @@ -266,6 +266,9 @@ libpthread { GLIBC_2.20 { } + GLIBC_2.22 { + } + GLIBC_PRIVATE { __pthread_initialize_minimal; __pthread_clock_gettime; __pthread_clock_settime; --- a/nptl/pt-fork.c +++ b/nptl/pt-fork.c @@ -1,4 +1,5 @@ -/* Copyright (C) 2002-2015 Free Software Foundation, Inc. +/* ABI compatibility for 'fork' symbol 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,11 +18,55 @@ . */ #include +#include +/* libpthread once had its own fork, 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 __fork and fork symbols in + libpthread.so; so we define them using IFUNC to redirect to the libc + function. */ -pid_t -__fork (void) +#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22) + +# if HAVE_IFUNC + +static __typeof (fork) * +__attribute__ ((used)) +fork_resolve (void) +{ + return &__libc_fork; +} + +# ifdef HAVE_ASM_SET_DIRECTIVE +# define DEFINE_FORK(name) \ + asm (".set " #name ", fork_resolve\n" \ + ".globl " #name "\n" \ + ".type " #name ", %gnu_indirect_function"); +# else +# define DEFINE_FORK(name) \ + asm (#name " = fork_resolve\n" \ + ".globl " #name "\n" \ + ".type " #name ", %gnu_indirect_function"); +# endif + +# else /* !HAVE_IFUNC */ + +static pid_t __attribute__ ((used)) +fork_compat (void) { return __libc_fork (); } -strong_alias (__fork, fork) + +# define DEFINE_FORK(name) strong_alias (fork_compat, name) + +# endif /* HAVE_IFUNC */ + +DEFINE_FORK (fork_ifunc) +compat_symbol (libpthread, fork_ifunc, fork, GLIBC_2_0); + +DEFINE_FORK (__fork_ifunc) +compat_symbol (libpthread, __fork_ifunc, __fork, GLIBC_2_0); + +#endif