From patchwork Thu Mar 18 20:06:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 42670 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 60F673848037; Thu, 18 Mar 2021 20:07:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 60F673848037 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1616098022; bh=M1tNz4Y2+x+5uTGGipEWYwmor4a5xrCnYwoZT23fh2Y=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=KMbhV2or9ZrLz/+NItODqNrbQTdKM1HlAwnQUNEzvY6nTxymNs2RnyRZq7w9ATIcU ugy33cr1CEFj3mZMWXsmnzDS7OFTU572LOpYwaBc2ftKeOzWoBHN9UGMLHbxo7a4lz afGzhHTXdY6jVi7bzpWisNB0okFx7wKksJ7s3suc= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id D98783848011 for ; Thu, 18 Mar 2021 20:06:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D98783848011 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-422-wjUEF5NAM5ymr4A6_0CFfw-1; Thu, 18 Mar 2021 16:06:45 -0400 X-MC-Unique: wjUEF5NAM5ymr4A6_0CFfw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45EF11007476 for ; Thu, 18 Mar 2021 20:06:44 +0000 (UTC) Received: from oldenburg.str.redhat.com (ovpn-115-121.ams2.redhat.com [10.36.115.121]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9EA785D9D0 for ; Thu, 18 Mar 2021 20:06:43 +0000 (UTC) To: libc-alpha@sourceware.org Subject: [RFC 0/2] Transparent multi-version symbol support Message-Id: Date: Thu, 18 Mar 2021 21:06:52 +0100 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-6.5 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Florian Weimer via Libc-alpha From: Florian Weimer Reply-To: Florian Weimer Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" This turned out to be way harder than it should be. Older binutils does not support multiple .symver directives for the same first symbol, so we have various kludges like (from time/clock_settime.c): | versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17); | | /* clock_settime moved to libc in version 2.17; | old binaries may expect the symbol version it had in librt. */ | #if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_17) | strong_alias (__clock_settime, __clock_settime_2); | compat_symbol (libc, __clock_settime_2, clock_settime, GLIBC_2_2); | #endif I think I have found a way to do this with assembler hacks, so that it applies to function and data symbols alike. With this, the above snipper becomes: | versioned_symbol (libc, __clock_settime, clock_settime, GLIBC_2_17); | | /* clock_settime moved to libc in version 2.17; | old binaries may expect the symbol version it had in librt. */ | #if SHLIB_COMPAT (libc, GLIBC_2_2, GLIBC_2_17) | compat_symbol (libc, __clock_settime, clock_settime, GLIBC_2_2); | #endif So the explicit aliases are gone. Built with build-many-glibcs.py with binutils 2.36 and 2.34. Tested on i686-linux-gnu and x86_64-linux-gnu with binutils 2.34 and 2.35. The object files aren't unchanged due to the __malloc_initialize_hook change (and presumably others, I haven't looked closely). Thanks, Florian Florian Weimer (2): Change how the symbol_version_reference macro is defined Fold compat_symbol_unique functionality into compat_symbol config.h.in | 4 ++ configure | 28 +++++++++++ configure.ac | 21 +++++++++ include/libc-symbols.h | 21 +++------ include/shlib-compat.h | 55 +++++++--------------- locale/lc-ctype.c | 14 +++--- malloc/malloc.c | 2 +- nptl/libpthread-compat.c | 16 +++---- sysdeps/generic/libc-symver.h | 88 +++++++++++++++++++++++++++++++++++ sysdeps/ia64/libc-symver.h | 33 +++++++++++++ time/clock_getcpuclockid.c | 3 +- time/clock_getres.c | 3 +- time/clock_gettime.c | 3 +- time/clock_nanosleep.c | 3 +- time/clock_settime.c | 3 +- 15 files changed, 219 insertions(+), 78 deletions(-) create mode 100644 sysdeps/generic/libc-symver.h create mode 100644 sysdeps/ia64/libc-symver.h