]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - include/shlib-compat.h
Further harden glibc malloc metadata against 1-byte overflows.
[thirdparty/glibc.git] / include / shlib-compat.h
index a95c1e0806acb2a6e05a7d7334075129d219effb..41eb362f1dee1d7daae41d81790c6b215cb6d26b 100644 (file)
@@ -1,32 +1,27 @@
 /* Macros for managing ABI-compatibility definitions using ELF symbol versions.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000-2017 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 Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   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
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _SHLIB_COMPAT_H
 #define _SHLIB_COMPAT_H        1
 
-#if defined HAVE_ELF && defined DO_VERSIONING
-/* Since there is just one set of .d files generated, we need to
-   include this unconditionally to have the dependency noticed properly.  */
-#include <abi-versions.h>      /* header generated by abi-versions.awk */
-#endif
+# include <abi-versions.h>
 
-#if defined HAVE_ELF && defined PIC && defined DO_VERSIONING
+#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
    e.g. `#if SHLIB_COMPAT (libm, GLIBC_2_0, GLIBC_2_2)' for code introduced
    in the GLIBC_2.0 version and obsoleted in the GLIBC_2.2 version.  */
 
-# define SHLIB_COMPAT(lib, introduced, obsoleted) \
-  (!(ABI_##lib##_##obsoleted - 0) \
-   || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0)))
+# define SHLIB_COMPAT(lib, introduced, obsoleted)                            \
+  _SHLIB_COMPAT (lib, introduced, obsoleted)
+# define _SHLIB_COMPAT(lib, introduced, obsoleted)                           \
+  (IS_IN (lib)                                                               \
+   && (!(ABI_##lib##_##obsoleted - 0)                                        \
+       || ((ABI_##lib##_##introduced - 0) < (ABI_##lib##_##obsoleted - 0))))
 
 /* That header also defines symbols like `VERSION_libm_GLIBC_2_1' to
    the version set name to use for e.g. symbols first introduced into
    libm in the GLIBC_2.1 version.  Definitions of symbols with explicit
    versions should look like:
-       versioned_symbol (libm, new_foo, foo, GLIBC_2_1);
+       versioned_symbol (libm, new_foo, foo, GLIBC_2_1);
    This will define the symbol `foo' with the appropriate default version,
    i.e. either GLIBC_2.1 or the "earliest version" specified in
    shlib-versions if that is newer.  */
 
 # define versioned_symbol(lib, local, symbol, version) \
-  versioned_symbol_1 (local, symbol, VERSION_##lib##_##version)
-# define versioned_symbol_1(local, symbol, name) \
+  versioned_symbol_1 (lib, local, symbol, version)
+# define versioned_symbol_1(lib, local, symbol, version) \
+  versioned_symbol_2 (local, symbol, VERSION_##lib##_##version)
+# define versioned_symbol_2(local, symbol, name) \
   default_symbol_version (local, symbol, name)
 
 # define compat_symbol(lib, local, symbol, version) \
-  compat_symbol_1 (local, symbol, VERSION_##lib##_##version)
-# define compat_symbol_1(local, symbol, name) \
-  symbol_version (local, symbol, name)
+  compat_symbol_reference (lib, local, symbol, version)
 
 #else
 
 
 #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.  */
+#  define libc_sunrpc_symbol(name, aliasname, version) \
+  strong_alias (name, aliasname)
+# else
+/* Export the symbol only for shared-library compatibility.  */
+#  define libc_sunrpc_symbol(name, aliasname, version) \
+  compat_symbol (libc, name, aliasname, version);
+# endif
 
 #endif /* shlib-compat.h */