Skip to content

Commit

Permalink
crypt-port: Add the bits for compiling with link-time optimization.
Browse files Browse the repository at this point in the history
GCC 10.2 and LLVM/Clang 10 offer initial support for building
libraries, that are using symbol versioning features, with LTO.

To make use of this with GCC 10.2, the exported versioned symbols
need to be declared explicitly with __attribute__((symver (...))).

LLVM/Clang 10 supports symbol versioning with LTO out of the box
without any changes needed.

Fixes #24.
  • Loading branch information
besser82 committed Aug 14, 2020
1 parent eca7aff commit 82651d7
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/crypt-port.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,36 @@ _crypt_strcpy_or_abort (void *, const size_t, const void *);
__asm__(".set _" #aliasname ", _" #name); \
extern __typeof(name) aliasname __THROW

# define _symver_ref(extstr, intname, version) \
symver_set(extstr, intname, version, "@")

# define symver_set(extstr, intname, version, mode) \
__asm__(".globl _" extstr); \
__asm__(".set _" extstr ", _" #intname)

#elif defined __GNUC__ && (__GNUC__ > 10 || \
(__GNUC__ == 10 && __GNUC_MINOR__ >= 2))

# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __THROW __attribute__ ((alias (#name)))

# define _symver_ref(extstr, intname, version) \
__asm__ (".symver " #intname "," extstr "@" #version)

/* Set the symbol version for EXTNAME, which uses INTNAME as its
implementation. */
# define symver_set(extstr, intname, version, mode) \
extern __typeof (intname) intname __THROW \
__attribute__((symver (extstr mode #version)))

#elif defined __GNUC__ && __GNUC__ >= 3

# define _strong_alias(name, aliasname) \
extern __typeof (name) aliasname __THROW __attribute__ ((alias (#name)))

# define _symver_ref(extstr, intname, version) \
symver_set(extstr, intname, version, "@")

/* Set the symbol version for EXTNAME, which uses INTNAME as its
implementation. */
# define symver_set(extstr, intname, version, mode) \
Expand Down Expand Up @@ -241,7 +262,7 @@ _crypt_strcpy_or_abort (void *, const size_t, const void *);
to _define_ them. */

#define symver_ref(extstr, intname, version) \
symver_set(extstr, intname, version, "@")
_symver_ref(extstr, intname, version)

/* Define configuration macros used during compile-time by the
GOST R 34.11-2012 "Streebog" hash function. */
Expand Down

0 comments on commit 82651d7

Please sign in to comment.