From patchwork Wed Jun 22 15:18:39 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Weimer X-Patchwork-Id: 639233 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 3rZSt338Kqz9t1F for ; Thu, 23 Jun 2016 01:18:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=A3XVVoNq; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; q=dns; s=default; b= oAbF66htTPx2L7nCjW58/YvE3aVzXtIFhvHiThHSV0LzZlLBYwpvWRXpVAUngNIo ymvD5YxiunJBRJNoZU6EhN5F6xaijEhyYrfGqY60S3WSuPU6smLZ7emkP0Phvkal /nGVyblSPSZZ5nD0ZxDDFX+WSYlK42+x1KpmPoUezTU= 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:date:to:subject:mime-version:content-type :content-transfer-encoding:message-id:from; s=default; bh=tlVX9W N2CvGq3TaffkctegQ6Pjg=; b=A3XVVoNqV8SsriIOFmvNPvRHrlChKTwVDc5HxJ UDXyX2Lh8FQja/J9FU0gDapNLTo55iLKIYO9rnviSTCJVk1XfkQfF1Ekob4RlCXT INZXVIwZ6loeiUgUl85aEfeVX8lAbbjfCtz7jBFtbzMg+RcZUxxqv5h7vHKPQfoR 1Ka8Y= Received: (qmail 38946 invoked by alias); 22 Jun 2016 15:18:45 -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 38924 invoked by uid 89); 22 Jun 2016 15:18:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Date: Wed, 22 Jun 2016 17:18:39 +0200 To: libc-alpha@sourceware.org Subject: [PATCH] Add support for referencing specific symbol versions User-Agent: Heirloom mailx 12.5 7/5/10 MIME-Version: 1.0 Message-Id: <20160622151839.7B42F41C3910C@oldenburg.str.redhat.com> From: fweimer@redhat.com (Florian Weimer) This is needed for writing tests of compat symbols. 2016-06-22 Florian Weimer Support linking against compatibility symbols, for use in tests. * include/libc-symbols.h (symbol_version_reference): New macro. (symbol_version): Use it. * include/shlib-compat.h: Unconditionally include . (compat_symbol): Use compat_symbol_reference. (compat_symbol_1, compat_symbol_2): Remove. (compat_symbol_reference, compat_symbol_reference_1) (compat_symbol_reference_2): New macro. Use symbol_version_reference. diff --git a/include/libc-symbols.h b/include/libc-symbols.h index 4548e09..c2b499a 100644 --- a/include/libc-symbols.h +++ b/include/libc-symbols.h @@ -282,19 +282,28 @@ for linking") past the last element in SET. */ #define symbol_set_end_p(set, ptr) ((ptr) >= (void *const *) &__stop_##set) +/* Use symbol_version_reference to specify the version a symbol + reference should link to. Use symbol_version or + default_symbol_version for the definition of a versioned symbol. + The difference is that the latter is a no-op in non-shared + builds. */ +#ifdef __ASSEMBLER__ +# define symbol_version_reference(real, name, version) \ + .symver real, name##@##version +#else /* !__ASSEMBLER__ */ +# define symbol_version_reference(real, name, version) \ + __asm__ (".symver " #real "," #name "@" #version) +#endif + #ifdef SHARED # define symbol_version(real, name, version) \ - _symbol_version(real, name, version) + symbol_version_reference(real, name, version) # define default_symbol_version(real, name, version) \ _default_symbol_version(real, name, version) # ifdef __ASSEMBLER__ -# define _symbol_version(real, name, version) \ - .symver real, name##@##version # define _default_symbol_version(real, name, version) \ .symver real, name##@##@##version # else -# define _symbol_version(real, name, version) \ - __asm__ (".symver " #real "," #name "@" #version) # define _default_symbol_version(real, name, version) \ __asm__ (".symver " #real "," #name "@@" #version) # endif diff --git a/include/shlib-compat.h b/include/shlib-compat.h index c1c5e2c..025c731 100644 --- a/include/shlib-compat.h +++ b/include/shlib-compat.h @@ -19,10 +19,10 @@ #ifndef _SHLIB_COMPAT_H #define _SHLIB_COMPAT_H 1 -#ifdef SHARED - # include +#ifdef SHARED + /* The file abi-versions.h (generated by scripts/abi-versions.awk) defines symbols like `ABI_libm_GLIBC_2_0' for each version set in the source code for each library. For a version set that is subsumed by a later @@ -62,11 +62,7 @@ default_symbol_version (local, symbol, name) # define compat_symbol(lib, local, symbol, version) \ - compat_symbol_1 (lib, local, symbol, version) -# define compat_symbol_1(lib, local, symbol, version) \ - compat_symbol_2 (local, symbol, VERSION_##lib##_##version) -# define compat_symbol_2(local, symbol, name) \ - symbol_version (local, symbol, name) + compat_symbol_reference (lib, local, symbol, version) #else @@ -82,6 +78,14 @@ #endif +/* Use compat_symbol_reference for a reference to a specific version + of a symbol. Use compat_symbol to define such a symbol. */ +#define compat_symbol_reference(lib, local, symbol, version) \ + compat_symbol_reference_1 (lib, local, symbol, version) +#define compat_symbol_reference_1(lib, local, symbol, version) \ + compat_symbol_reference_2 (local, symbol, VERSION_##lib##_##version) +#define compat_symbol_reference_2(local, symbol, name) \ + symbol_version_reference (local, symbol, name) # ifdef LINK_OBSOLETE_RPC /* Export the symbol for both static and dynamic linking. */