1/* Symbol version management.
2 Copyright (C) 1995-2022 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/* This file is included from <libc-symbols.h> for !_ISOMAC, and
20 unconditionally from <shlib-compat.h>. */
21
22#ifndef _LIBC_SYMVER_H
23#define _LIBC_SYMVER_H 1
24
25#include <config.h>
26
27/* Use symbol_version_reference to specify the version a symbol
28 reference should link to. Use symbol_version or
29 default_symbol_version for the definition of a versioned symbol.
30 The difference is that the latter is a no-op in non-shared
31 builds.
32
33 _set_symbol_version is similar to symbol_version_reference, except
34 that this macro expects the name and symbol version as a single
35 string or token sequence, with an @ or @@ separator. (A string is
36 used in C mode and a token sequence in assembler mode.)
37 _set_symbol_version only be used for definitions because it may
38 introduce an alias symbol that would not be globally unique for
39 mere references. The _set_symbol_version macro is used to define
40 default_symbol_version and compat_symbol. */
41
42#ifdef __ASSEMBLER__
43# define symbol_version_reference(real, name, version) \
44 .symver real, name##@##version
45#else
46# define symbol_version_reference(real, name, version) \
47 __asm__ (".symver " #real "," #name "@" #version)
48#endif /* !__ASSEMBLER__ */
49
50#if SYMVER_NEEDS_ALIAS
51/* If the assembler cannot support multiple versions for the same
52 symbol, introduce __SInnn_ aliases to which the symbol version is
53 attached. */
54# define __symbol_version_unique_concat(x, y) __SI ## x ## _ ## y
55# define _symbol_version_unique_concat(x, y) \
56 __symbol_version_unique_concat (x, y)
57# define _symbol_version_unique_alias(name) \
58 _symbol_version_unique_concat (name, __COUNTER__)
59# ifdef __ASSEMBLER__
60# define _set_symbol_version_2(real, alias, name_version) \
61 .globl alias ASM_LINE_SEP \
62 .equiv alias, real ASM_LINE_SEP \
63 .symver alias, name_version
64# else
65# define _set_symbol_version_2(real, alias, name_version) \
66 __asm__ (".globl " #alias "\n\t" \
67 ".equiv " #alias ", " #real "\n\t" \
68 ".symver " #alias "," name_version)
69# endif
70# define _set_symbol_version_1(real, alias, name_version) \
71 _set_symbol_version_2 (real, alias, name_version)
72/* REAL must be globally unique, so that the counter also produces
73 globally unique symbols. */
74# define _set_symbol_version(real, name_version) \
75 _set_symbol_version_1 (real, _symbol_version_unique_alias (real), \
76 name_version)
77# else /* !SYMVER_NEEDS_ALIAS */
78# ifdef __ASSEMBLER__
79# define _set_symbol_version(real, name_version) \
80 .symver real, name_version
81# else
82# define _set_symbol_version(real, name_version) \
83 __asm__ (".symver " #real "," name_version)
84# endif
85#endif /* !SYMVER_NEEDS_ALIAS */
86
87
88#endif /* _LIBC_SYMVER_H */
89

source code of glibc/sysdeps/generic/libc-symver.h