| 1 |
148 |
jeremybenn |
/* Macros for managing ABI-compatibility definitions using ELF symbol versions.
|
| 2 |
|
|
Copyright (C) 2000 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, write to the Free
|
| 17 |
|
|
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
| 18 |
|
|
02111-1307 USA. */
|
| 19 |
|
|
|
| 20 |
|
|
#ifndef _SHLIB_COMPAT_H
|
| 21 |
|
|
#define _SHLIB_COMPAT_H 1
|
| 22 |
|
|
|
| 23 |
|
|
#if defined HAVE_ELF && defined DO_VERSIONING
|
| 24 |
|
|
/* Since there is just one set of .d files generated, we need to
|
| 25 |
|
|
include this unconditionally to have the dependency noticed properly. */
|
| 26 |
|
|
#include <abi-versions.h> /* header generated by abi-versions.awk */
|
| 27 |
|
|
#endif
|
| 28 |
|
|
|
| 29 |
|
|
#if defined HAVE_ELF && defined SHARED && defined DO_VERSIONING
|
| 30 |
|
|
|
| 31 |
|
|
/* The file abi-versions.h (generated by scripts/abi-versions.awk) defines
|
| 32 |
|
|
symbols like `ABI_libm_GLIBC_2_0' for each version set in the source
|
| 33 |
|
|
code for each library. For a version set that is subsumed by a later
|
| 34 |
|
|
version set, the definition gives the subsuming set, i.e. if GLIBC_2_0
|
| 35 |
|
|
is subsumed by GLIBC_2_1, then ABI_libm_GLIBC_2_0 == ABI_libm_GLIBC_2_1.
|
| 36 |
|
|
Each version set that is to be distinctly defined in the output has an
|
| 37 |
|
|
unique positive integer value, increasing with newer versions. Thus,
|
| 38 |
|
|
evaluating two ABI_* symbols reduces to integer values that differ only
|
| 39 |
|
|
when the two version sets named are in fact two different ABIs we are
|
| 40 |
|
|
supporting. If these do not differ, then there is no need to compile in
|
| 41 |
|
|
extra code to support this version set where it has been superseded by a
|
| 42 |
|
|
newer version. The compatibility code should be conditionalized with
|
| 43 |
|
|
e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
|
| 44 |
|
|
in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version. */
|
| 45 |
|
|
|
| 46 |
|
|
# define SHLIB_COMPAT(lib, introduced, obsoleted) \
|
| 47 |
|
|
(!(ABI_##lib##_##obsoleted - 0) \
|
| 48 |
|
|
|| ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0)))
|
| 49 |
|
|
|
| 50 |
|
|
/* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
|
| 51 |
|
|
the version set name to use for e.g. symbols first introduced into
|
| 52 |
|
|
libm in the GLIBC_2.1 version. Definitions of symbols with explicit
|
| 53 |
|
|
versions should look like:
|
| 54 |
|
|
versioned_symbol (libm, new_foo, foo, GLIBC_2_1);
|
| 55 |
|
|
This will define the symbol `foo' with the appropriate default version,
|
| 56 |
|
|
i.e. either GLIBC_2.1 or the "earliest version" specified in
|
| 57 |
|
|
shlib-versions if that is newer. */
|
| 58 |
|
|
|
| 59 |
|
|
# define versioned_symbol(lib, local, symbol, version) \
|
| 60 |
|
|
versioned_symbol_1 (local, symbol, VERSION_##lib##_##version)
|
| 61 |
|
|
# define versioned_symbol_1(local, symbol, name) \
|
| 62 |
|
|
default_symbol_version (local, symbol, name)
|
| 63 |
|
|
|
| 64 |
|
|
# define compat_symbol(lib, local, symbol, version) \
|
| 65 |
|
|
compat_symbol_1 (local, symbol, VERSION_##lib##_##version)
|
| 66 |
|
|
# define compat_symbol_1(local, symbol, name) \
|
| 67 |
|
|
symbol_version (local, symbol, name)
|
| 68 |
|
|
|
| 69 |
|
|
#else
|
| 70 |
|
|
|
| 71 |
|
|
/* Not compiling ELF shared libraries at all, so never any old versions. */
|
| 72 |
|
|
# define SHLIB_COMPAT(lib, introduced, obsoleted) 0
|
| 73 |
|
|
|
| 74 |
|
|
/* No versions to worry about, just make this the global definition. */
|
| 75 |
|
|
# define versioned_symbol(lib, local, symbol, version) \
|
| 76 |
|
|
weak_alias (local, symbol)
|
| 77 |
|
|
|
| 78 |
|
|
/* This should not appear outside `#if SHLIB_COMPAT (...)'. */
|
| 79 |
|
|
# define compat_symbol(lib, local, symbol, version) ...
|
| 80 |
|
|
|
| 81 |
|
|
#endif
|
| 82 |
|
|
|
| 83 |
|
|
|
| 84 |
|
|
#endif /* shlib-compat.h */
|