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: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS shortcircuit=no autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 122A21F5AE for ; Tue, 27 Apr 2021 11:06:44 +0000 (UTC) Received: from localhost ([::1]:48588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lbLYB-0004NH-6K for normalperson@yhbt.net; Tue, 27 Apr 2021 07:06:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbLY4-0004KU-BD for bug-gnulib@gnu.org; Tue, 27 Apr 2021 07:06:39 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24156) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lbLXs-0003DY-Dp for bug-gnulib@gnu.org; Tue, 27 Apr 2021 07:06:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1619521582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KqY9r0DpAzkEKa6/4KFwfOXCnLMLi9QF1Tgb6U21x4Y=; b=LEPXDRhv9dpUB1P65jA86Vlc9SqTNKeDFYyULs8JH0pl3fvOU1dy5QziuGi+Hau+5Ct5Kv dNPuEFxLYg95+TKLzykFbJTunNbYG1pKdp6qTEL3NOmQftQcKi5P0+IJ/Gu3fk/17FkSxP S+BEDW4u5aSTI7quJ5esTVNAr12aiXY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-115-QtWj6GPtNpW6U5dpKlKXfQ-1; Tue, 27 Apr 2021 07:06:18 -0400 X-MC-Unique: QtWj6GPtNpW6U5dpKlKXfQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A485181CAF1; Tue, 27 Apr 2021 11:06:17 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-113-20.ams2.redhat.com [10.36.113.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 43A2860CFB; Tue, 27 Apr 2021 11:06:15 +0000 (UTC) From: Florian Weimer To: Andreas Schwab Subject: Re: Undefined use of weak symbols in gnulib References: <87o8e0p92r.fsf@oldenburg.str.redhat.com> <87fszc8a1z.fsf@igel.home> Date: Tue, 27 Apr 2021 13:06:43 +0200 In-Reply-To: <87fszc8a1z.fsf@igel.home> (Andreas Schwab's message of "Tue, 27 Apr 2021 09:24:08 +0200") Message-ID: <87eeewnfzw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=fweimer@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=216.205.24.124; envelope-from=fweimer@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.218, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: libc-alpha@sourceware.org, bug-gnulib@gnu.org, Florian Weimer via Binutils Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" * Andreas Schwab: > On Apr 27 2021, Florian Weimer via Binutils wrote: > >> I think we can provide an libBrokenGnulib.so preload module which >> defines pthread_mutexattr_gettype to zero (as an absolute address), so >> there is a kludge to keep old binaries working, but this is really >> something that must be fixed in gnulib. > > It is likely that the use of weak pthread symbols is not confined to > gnulib. True. Here's a fairly representative test case, I think. #include #include extern __typeof (pthread_key_create) __pthread_key_create __attribute__ ((w= eak)); extern __typeof (pthread_once) pthread_once __attribute__ ((weak)); void f1 (void) { puts ("f1 called"); } pthread_once_t once_var; void __attribute__ ((weak)) f2 (void) { if (__pthread_key_create !=3D NULL) pthread_once (&once_var, f1); } int main (void) { f2 (); } Building it with =E2=80=9Cgcc -O2 -fpie -pie=E2=80=9D and linking with binu= tils 2.30 does not result in a crash with LD_PRELOAD=3Dlibpthread.so.0. That's because the call-to-address-zero via pthread_once has been stubbed out with NOPs, I think. This is still not correct and will undoubtedly cause problems because pthread_once is usually called for its side effect. With binutils 2.35, the call-to-address-zero is not stubbed out anymore, but there is still no dynamic symbol reference for pthread_once, so there is a crash when running with LD_PRELOAD=3Dlibpthread.so.0. This looks like a pre-existing toolchain issue on POWER, related to the thread I quoted at the start. If we proceed with the glibc libpthread changes as planned, things might turn out unacceptably bad. I did a quick experiment and we cannot work around this using a libpthread.so stub library and compatibility-only symbols in libc.so.6. Unversioned weak symbols bind to the baseline symbol version, as they probably should. Even a __pthread_key_create@GLIBC_2.17 compatibility symbol triggers this issue. I have to think of something else to salvage this. Thanks, Florian