about summary refs log tree commit diff
path: root/sysdeps/generic/libc-symver.h
blob: 7dd4762a7046d64cf73d2da7f0f2c50234f5ef14 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/* Symbol version management.
   Copyright (C) 1995-2024 Free Software Foundation, Inc.
   This file is part of the GNU C Library.

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, see
   <https://www.gnu.org/licenses/>.  */

/* This file is included from <libc-symbols.h> for !_ISOMAC, and
   unconditionally from <shlib-compat.h>.  */

#ifndef _LIBC_SYMVER_H
#define _LIBC_SYMVER_H 1

#include <config.h>

/* 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.

   _set_symbol_version is similar to symbol_version_reference, except
   that this macro expects the name and symbol version as a single
   string or token sequence, with an @ or @@ separator.  (A string is
   used in C mode and a token sequence in assembler mode.)
   _set_symbol_version only be used for definitions because it may
   introduce an alias symbol that would not be globally unique for
   mere references.  The _set_symbol_version macro is used to define
   default_symbol_version and compat_symbol.  */

#ifdef __ASSEMBLER__
# define symbol_version_reference(real, name, version) \
     .symver real, name##@##version
#else
# define symbol_version_reference(real, name, version) \
  __asm__ (".symver " #real "," #name "@" #version)
#endif  /* !__ASSEMBLER__ */

#if SYMVER_NEEDS_ALIAS
/* If the assembler cannot support multiple versions for the same
   symbol, introduce __SInnn_ aliases to which the symbol version is
   attached.  */
# define __symbol_version_unique_concat(x, y) __SI ## x ## _ ## y
# define _symbol_version_unique_concat(x, y) \
  __symbol_version_unique_concat (x, y)
# define _symbol_version_unique_alias(name) \
  _symbol_version_unique_concat (name, __COUNTER__)
# ifdef __ASSEMBLER__
#  define _set_symbol_version_2(real, alias, name_version) \
  .globl alias ASM_LINE_SEP                                \
  .equiv alias, real ASM_LINE_SEP                          \
  .symver alias, name_version
# else
#  define _set_symbol_version_2(real, alias, name_version) \
  __asm__ (".globl " #alias "\n\t"                         \
           ".equiv " #alias ", " #real "\n\t"              \
           ".symver " #alias "," name_version)
# endif
# define _set_symbol_version_1(real, alias, name_version) \
  _set_symbol_version_2 (real, alias, name_version)
/* REAL must be globally unique, so that the counter also produces
   globally unique symbols.  */
# define _set_symbol_version(real, name_version)                   \
  _set_symbol_version_1 (real, _symbol_version_unique_alias (real), \
                               name_version)
# else  /* !SYMVER_NEEDS_ALIAS */
# ifdef __ASSEMBLER__
#  define _set_symbol_version(real, name_version) \
  .symver real, name_version
# else
#  define _set_symbol_version(real, name_version) \
  __asm__ (".symver " #real "," name_version)
# endif
#endif  /* !SYMVER_NEEDS_ALIAS */


#endif /* _LIBC_SYMVER_H */