diff --git a/lib/crypt-des-obsolete.c b/lib/crypt-des-obsolete.c index 66aa534b..e92f8af8 100644 --- a/lib/crypt-des-obsolete.c +++ b/lib/crypt-des-obsolete.c @@ -121,6 +121,7 @@ do_setkey_r (const char *key, struct des_ctx *ctx) #endif #if INCLUDE_setkey_r +xcrypt_symbol void setkey_r (ARG_UNUSED (const char *key), ARG_UNUSED (struct crypt_data *data)) { @@ -148,6 +149,7 @@ do_encrypt_r (char *block, int edflag, struct des_ctx *ctx) #endif #if INCLUDE_encrypt_r +xcrypt_symbol void encrypt_r (char *block, ARG_UNUSED (int edflag), ARG_UNUSED (struct crypt_data *data)) @@ -180,6 +182,7 @@ static struct des_ctx nr_encrypt_ctx; #endif #if INCLUDE_setkey +xcrypt_symbol void setkey (ARG_UNUSED (const char *key)) { @@ -194,6 +197,7 @@ SYMVER_setkey; #endif #if INCLUDE_encrypt +xcrypt_symbol void encrypt (char *block, ARG_UNUSED (int edflag)) { diff --git a/lib/crypt-gensalt-static.c b/lib/crypt-gensalt-static.c index 6f1ff433..8c0d481f 100644 --- a/lib/crypt-gensalt-static.c +++ b/lib/crypt-gensalt-static.c @@ -22,6 +22,7 @@ will not have the state objects in its data segment. */ #if INCLUDE_crypt_gensalt +xcrypt_symbol char * crypt_gensalt (const char *prefix, unsigned long count, const char *rbytes, int nrbytes) @@ -36,6 +37,7 @@ SYMVER_crypt_gensalt; /* For code compatibility with older versions (v3.1.1 and earlier). */ #if INCLUDE_crypt_gensalt && INCLUDE_xcrypt_gensalt +xcrypt_symbol strong_alias (crypt_gensalt, xcrypt_gensalt); SYMVER_xcrypt_gensalt; #endif diff --git a/lib/crypt-port.h b/lib/crypt-port.h index bec36aca..ff99bc2a 100644 --- a/lib/crypt-port.h +++ b/lib/crypt-port.h @@ -161,6 +161,22 @@ _crypt_strcpy_or_abort (void *, const size_t, const void *); /* Define ALIASNAME as a strong alias for NAME. */ #define strong_alias(name, aliasname) _strong_alias(name, aliasname) +/* Define a symbol to be external visible. */ +#if (defined __GNUC__ && __GNUC__ >= 5) && !defined __clang__ + +# define xcrypt_symbol \ + __attribute__((visibility("default"), externally_visible)) + +#elif defined __GNUC__ && __GNUC__ >= 3 + +# define xcrypt_symbol \ + __attribute__((visibility("default"))) + +#else + +# define xcrypt_symbol + +#endif /* Darwin (Mach-O) doesn't support alias attributes or symbol versioning. It does, however, support symbol aliasing at the object file level. */ #ifdef __APPLE__ diff --git a/lib/crypt-static.c b/lib/crypt-static.c index 12ece0c1..9f40c122 100644 --- a/lib/crypt-static.c +++ b/lib/crypt-static.c @@ -24,6 +24,7 @@ will not have the state objects in its data segment. */ #if INCLUDE_crypt || INCLUDE_fcrypt +xcrypt_symbol char * crypt (const char *key, const char *setting) { @@ -38,6 +39,7 @@ SYMVER_crypt; #if INCLUDE_fcrypt #if ENABLE_OBSOLETE_API_ENOSYS +xcrypt_symbol char * fcrypt (ARG_UNUSED (const char *key), ARG_UNUSED (const char *setting)) { @@ -54,6 +56,7 @@ fcrypt (ARG_UNUSED (const char *key), ARG_UNUSED (const char *setting)) #endif } #else +xcrypt_symbol strong_alias (crypt, fcrypt); #endif SYMVER_fcrypt; @@ -61,6 +64,7 @@ SYMVER_fcrypt; /* For code compatibility with older versions (v3.1.1 and earlier). */ #if INCLUDE_crypt && INCLUDE_xcrypt +xcrypt_symbol strong_alias (crypt, xcrypt); SYMVER_xcrypt; #endif diff --git a/lib/crypt.c b/lib/crypt.c index b03b4222..9e9fa1fc 100644 --- a/lib/crypt.c +++ b/lib/crypt.c @@ -145,6 +145,7 @@ do_crypt (const char *phrase, const char *setting, struct crypt_data *data) } #if INCLUDE_crypt_rn +xcrypt_symbol char * crypt_rn (const char *phrase, const char *setting, void *data, int size) { @@ -163,6 +164,7 @@ SYMVER_crypt_rn; #endif #if INCLUDE_crypt_ra +xcrypt_symbol char * crypt_ra (const char *phrase, const char *setting, void **data, int *size) { @@ -191,6 +193,7 @@ SYMVER_crypt_ra; #endif #if INCLUDE_crypt_r +xcrypt_symbol char * crypt_r (const char *phrase, const char *setting, struct crypt_data *data) { @@ -207,11 +210,13 @@ SYMVER_crypt_r; /* For code compatibility with older versions (v3.1.1 and earlier). */ #if INCLUDE_crypt_r && INCLUDE_xcrypt_r +xcrypt_symbol strong_alias (crypt_r, xcrypt_r); SYMVER_xcrypt_r; #endif #if INCLUDE_crypt_gensalt_rn +xcrypt_symbol char * crypt_gensalt_rn (const char *prefix, unsigned long count, const char *rbytes, int nrbytes, char *output, @@ -279,17 +284,20 @@ SYMVER_crypt_gensalt_rn; /* For code compatibility with older versions (v3.1.1 and earlier). */ #if INCLUDE_crypt_gensalt_rn && INCLUDE_crypt_gensalt_r +xcrypt_symbol strong_alias (crypt_gensalt_rn, crypt_gensalt_r); SYMVER_crypt_gensalt_r; #endif /* For code compatibility with older versions (v3.1.1 and earlier). */ #if INCLUDE_crypt_gensalt_rn && INCLUDE_xcrypt_gensalt_r +xcrypt_symbol strong_alias (crypt_gensalt_rn, xcrypt_gensalt_r); SYMVER_xcrypt_gensalt_r; #endif #if INCLUDE_crypt_gensalt_ra +xcrypt_symbol char * crypt_gensalt_ra (const char *prefix, unsigned long count, const char *rbytes, int nrbytes) @@ -310,6 +318,7 @@ SYMVER_crypt_gensalt_ra; #if INCLUDE_crypt_checksalt static_assert(CRYPT_SALT_OK == 0, "CRYPT_SALT_OK does not equal zero"); +xcrypt_symbol int crypt_checksalt (const char *setting) { @@ -329,6 +338,7 @@ SYMVER_crypt_checksalt; #endif #if INCLUDE_crypt_preferred_method +xcrypt_symbol const char * crypt_preferred_method (void) {