From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 38C3B3833022 for ; Tue, 27 Apr 2021 06:58:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 38C3B3833022 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-524-TxwNa1zjPyqP2FR-eNBmZA-1; Tue, 27 Apr 2021 02:58:12 -0400 X-MC-Unique: TxwNa1zjPyqP2FR-eNBmZA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E3DE91275; Tue, 27 Apr 2021 06:58:11 +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 C06511001901; Tue, 27 Apr 2021 06:58:09 +0000 (UTC) From: Florian Weimer To: Paul Eggert Cc: libc-alpha@sourceware.org, binutils@sourceware.org, bug-gnulib@gnu.org Subject: Re: Undefined use of weak symbols in gnulib References: <87o8e0p92r.fsf@oldenburg.str.redhat.com> Date: Tue, 27 Apr 2021 08:58:36 +0200 In-Reply-To: (Paul Eggert's message of "Mon, 26 Apr 2021 23:50:26 -0700") Message-ID: <87czugp61v.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.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Apr 2021 06:58:18 -0000 * Paul Eggert: > On 4/26/21 10:53 PM, Florian Weimer via Libc-alpha wrote: >> This will become an urgent issue with glibc 2.34, which defines >> pthread_mutexattr_gettype unconditionally. Certain gnulib modules will >> stop working until the binaries are relinked. > > Thanks for mentioning this. But in what sense will the modules stop > working? I'm a little lost. > > glibc 2.34 also defines pthread_once unconditionally, right? So why > doesn't code like this: > > if (pthread_mutexattr_gettype != NULL) > pthread_once (control, callback); > > continue to work in 2.34? The link editor does not emitted a relocation referencing the pthread_once symbol. The function address in the GOT is always zero. It does not matter if a pthread_once symbol exists at run time because their is no reference to it. Relinking the executable will of course fix this and generate a reference to the pthread_once symbol, but relinking is required. For example, bison 3.7.4 built against glibc 2.33 has these pthread* symbol references in its dynamic symbol table on powerpc64le-linux-gnu: 58: 0000000000000000 0 FUNC WEAK DEFAULT UNDEF pthread_mutex_init@GLIBC_2.17 (2) 117: 0000000000000000 0 FUNC WEAK DEFAULT UNDEF pthread_mutex_lock@GLIBC_2.17 (2) 118: 0000000000000000 0 NOTYPE WEAK DEFAULT UNDEF pthread_mutexattr_gettype 120: 0000000000000000 0 FUNC WEAK DEFAULT UNDEF pthread_mutex_unlock@GLIBC_2.17 (2) pthread_once is just not there. Thanks, Florian