Skip to content

Commit

Permalink
Drop use of visibility=hidden
Browse files Browse the repository at this point in the history
The version-script file already controls what is exported so this flag is
basically unnecessary now. It requires to sprinkle a bunch of attributes on
all exported function via the DSO_PUBLIC and other SYMVER macros.

Removing it makes it simpler to deal with exported symbols, leaving
control only to the version.lds file.

Signed-off-by: Simo Sorce <simo@redhat.com>
Signed-off-by: Stephan Mueller <smueller@chronox.de>
  • Loading branch information
simo5 authored and smuellerDD committed Jul 14, 2021
1 parent 71d80bc commit 3e9a149
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 56 deletions.
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ else
libkcapi_la_SOURCES +=
endif

libkcapi_la_CPPFLAGS = $(COMMON_CPPFLAGS) -fvisibility=hidden
libkcapi_la_CPPFLAGS = $(COMMON_CPPFLAGS)
libkcapi_la_LDFLAGS = $(COMMON_LDFLAGS) -Wl,--version-script,$(top_srcdir)/lib/version.lds -version-number `echo $(VERSION) | sed 's/\./:/g'`

SCAN_FILES = $(libkcapi_la_SOURCES)
Expand Down
17 changes: 2 additions & 15 deletions lib/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -347,32 +347,19 @@ static inline int io_getevents(__attribute__((unused)) aio_context_t ctx,
* Auxiliary macros
************************************************************/

#if __GNUC__ >= 4
# define DSO_PUBLIC __attribute__ ((visibility ("default")))

#if __GNUC__ >= 10
# define IMPL_SYMVER(name, version) \
__attribute__ ((visibility ("default"))) \
__attribute__((__symver__("kcapi_" #name "@@LIBKCAPI_" version)))

# define ORIG_SYMVER(name, version) \
__attribute__ ((visibility ("default"))) \
__attribute__((__symver__("kcapi_" #name "@LIBKCAPI_" version)))

#else
# define IMPL_SYMVER(name, version) \
__asm__(".global impl_" #name ";"\
".symver impl_" #name ",kcapi_" #name "@@LIBKCAPI_" version);\
__attribute__ ((visibility ("default")))
__asm__(".symver impl_" #name ",kcapi_" #name "@@LIBKCAPI_" version);

# define ORIG_SYMVER(name, version) \
__asm__(".global orig_" #name ";"\
".symver orig_" #name ",kcapi_" #name "@LIBKCAPI_" version);\
__attribute__ ((visibility ("default")))
#endif

#else
# error "Compiler version too old"
__asm__(".symver orig_" #name ",kcapi_" #name "@LIBKCAPI_" version);
#endif

#ifdef __cplusplus
Expand Down
8 changes: 0 additions & 8 deletions lib/kcapi-aead.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,23 @@
#include "internal.h"
#include "kcapi.h"

DSO_PUBLIC
int kcapi_aead_init(struct kcapi_handle **handle, const char *ciphername,
uint32_t flags)
{
return _kcapi_handle_init(handle, "aead", ciphername, flags);
}

DSO_PUBLIC
void kcapi_aead_destroy(struct kcapi_handle *handle)
{
_kcapi_handle_destroy(handle);
}

DSO_PUBLIC
int kcapi_aead_setkey(struct kcapi_handle *handle,
const uint8_t *key, uint32_t keylen)
{
return _kcapi_common_setkey(handle, key, keylen);
}

DSO_PUBLIC
int kcapi_aead_settaglen(struct kcapi_handle *handle, uint32_t taglen)
{
struct kcapi_handle_tfm *tfm = handle->tfm;
Expand Down Expand Up @@ -504,23 +500,20 @@ int32_t orig_aead_stream_op(struct kcapi_handle *handle,
return (int32_t)impl_aead_stream_op(handle, iov, iovlen);
}

DSO_PUBLIC
uint32_t kcapi_aead_ivsize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;

return tfm->info.ivsize;
}

DSO_PUBLIC
uint32_t kcapi_aead_blocksize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;

return tfm->info.blocksize;
}

DSO_PUBLIC
uint32_t kcapi_aead_authsize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;
Expand Down Expand Up @@ -619,7 +612,6 @@ uint32_t orig_aead_outbuflen_dec(struct kcapi_handle *handle,
taglen);
}

DSO_PUBLIC
int kcapi_aead_ccm_nonce_to_iv(const uint8_t *nonce, uint32_t noncelen,
uint8_t **iv, uint32_t *ivlen)
{
Expand Down
4 changes: 0 additions & 4 deletions lib/kcapi-asym.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,27 +21,23 @@
#include "internal.h"
#include "kcapi.h"

DSO_PUBLIC
int kcapi_akcipher_init(struct kcapi_handle **handle, const char *ciphername,
uint32_t flags)
{
return _kcapi_handle_init(handle, "akcipher", ciphername, flags);
}

DSO_PUBLIC
void kcapi_akcipher_destroy(struct kcapi_handle *handle)
{
_kcapi_handle_destroy(handle);
}

DSO_PUBLIC
int kcapi_akcipher_setkey(struct kcapi_handle *handle,
const uint8_t *key, uint32_t keylen)
{
return _kcapi_common_setkey(handle, key, keylen);
}

DSO_PUBLIC
int kcapi_akcipher_setpubkey(struct kcapi_handle *handle,
const uint8_t *key, uint32_t keylen)
{
Expand Down
1 change: 0 additions & 1 deletion lib/kcapi-kdf.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ static inline uint64_t kcapi_get_time(void)
return 0;
}

DSO_PUBLIC
uint32_t kcapi_pbkdf_iteration_count(const char *hashname, uint64_t timeshresh)
{
#define LOW_ITERATION_COUNT (UINT32_C(1<<16))
Expand Down
1 change: 0 additions & 1 deletion lib/kcapi-kernel-if.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,6 @@ int _kcapi_handle_init(struct kcapi_handle **caller, const char *type,
return ret;
}

DSO_PUBLIC
int kcapi_handle_reinit(struct kcapi_handle **newhandle,
struct kcapi_handle *existing, uint32_t flags)
{
Expand Down
5 changes: 0 additions & 5 deletions lib/kcapi-kpp.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "internal.h"
#include "kcapi.h"

DSO_PUBLIC
int kcapi_kpp_init(struct kcapi_handle **handle, const char *ciphername,
uint32_t flags)
{
Expand All @@ -33,13 +32,11 @@ int kcapi_kpp_init(struct kcapi_handle **handle, const char *ciphername,
return 0;
}

DSO_PUBLIC
void kcapi_kpp_destroy(struct kcapi_handle *handle)
{
_kcapi_handle_destroy(handle);
}

DSO_PUBLIC
int kcapi_kpp_dh_setparam_pkcs3(struct kcapi_handle *handle,
const uint8_t *pkcs3, uint32_t pkcs3len)
{
Expand All @@ -51,7 +48,6 @@ int kcapi_kpp_dh_setparam_pkcs3(struct kcapi_handle *handle,
return (ret >= 0) ? ret : -errno;
}

DSO_PUBLIC
int kcapi_kpp_ecdh_setcurve(struct kcapi_handle *handle,
unsigned long curve_id)
{
Expand All @@ -65,7 +61,6 @@ int kcapi_kpp_ecdh_setcurve(struct kcapi_handle *handle,
return (ret >= 0) ? ret : -errno;
}

DSO_PUBLIC
int kcapi_kpp_setkey(struct kcapi_handle *handle,
const uint8_t *key, uint32_t keylen)
{
Expand Down
6 changes: 0 additions & 6 deletions lib/kcapi-md.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@
#include "internal.h"
#include "kcapi.h"

DSO_PUBLIC
int kcapi_md_init(struct kcapi_handle **handle, const char *ciphername,
uint32_t flags)
{
return _kcapi_handle_init(handle, "hash", ciphername, flags);
}

DSO_PUBLIC
void kcapi_md_destroy(struct kcapi_handle *handle)
{
_kcapi_handle_destroy(handle);
}

DSO_PUBLIC
int kcapi_md_setkey(struct kcapi_handle *handle,
const uint8_t *key, uint32_t keylen)
{
Expand Down Expand Up @@ -69,7 +66,6 @@ static inline ssize_t _kcapi_md_update(struct kcapi_handle *handle,
return 0;
}

DSO_PUBLIC
ssize_t kcapi_md_update(struct kcapi_handle *handle,
const uint8_t *buffer, size_t len)
{
Expand Down Expand Up @@ -133,15 +129,13 @@ int32_t orig_md_digest(struct kcapi_handle *handle,
return (int32_t)impl_md_digest(handle, in, inlen, out, outlen);
}

DSO_PUBLIC
uint32_t kcapi_md_digestsize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;

return tfm->info.hash_digestsize;
}

DSO_PUBLIC
uint32_t kcapi_md_blocksize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;
Expand Down
4 changes: 0 additions & 4 deletions lib/kcapi-rng.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@
#include "internal.h"
#include "kcapi.h"

DSO_PUBLIC
int kcapi_rng_init(struct kcapi_handle **handle, const char *ciphername,
uint32_t flags)
{
return _kcapi_handle_init(handle, "rng", ciphername, flags);
}

DSO_PUBLIC
void kcapi_rng_destroy(struct kcapi_handle *handle)
{
_kcapi_handle_destroy(handle);
}

DSO_PUBLIC
int kcapi_rng_seed(struct kcapi_handle *handle, uint8_t *seed,
uint32_t seedlen)
{
Expand Down Expand Up @@ -81,7 +78,6 @@ int32_t orig_rng_generate(struct kcapi_handle *handle,
return (int32_t)impl_rng_generate(handle, buffer, len);
}

DSO_PUBLIC
uint32_t kcapi_rng_seedsize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;
Expand Down
5 changes: 0 additions & 5 deletions lib/kcapi-sym.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@
#include "internal.h"
#include "kcapi.h"

DSO_PUBLIC
int kcapi_cipher_init(struct kcapi_handle **handle, const char *ciphername,
uint32_t flags)
{
return _kcapi_handle_init(handle, "skcipher", ciphername, flags);
}

DSO_PUBLIC
void kcapi_cipher_destroy(struct kcapi_handle *handle)
{
_kcapi_handle_destroy(handle);
}

DSO_PUBLIC
int kcapi_cipher_setkey(struct kcapi_handle *handle,
const uint8_t *key, uint32_t keylen)
{
Expand Down Expand Up @@ -282,15 +279,13 @@ int32_t orig_cipher_stream_op(struct kcapi_handle *handle,
return (int32_t)impl_cipher_stream_op(handle, iov, iovlen);
}

DSO_PUBLIC
uint32_t kcapi_cipher_ivsize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;

return tfm->info.ivsize;
}

DSO_PUBLIC
uint32_t kcapi_cipher_blocksize(struct kcapi_handle *handle)
{
struct kcapi_handle_tfm *tfm = handle->tfm;
Expand Down
6 changes: 0 additions & 6 deletions lib/kcapi-utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
#include "internal.h"
#include "kcapi.h"

DSO_PUBLIC
void kcapi_set_verbosity(enum kcapi_verbosity level)
{
kcapi_verbosity_level = level;
}

DSO_PUBLIC
void kcapi_versionstring(char *buf, uint32_t buflen)
{
snprintf(buf, buflen, "libkcapi%s%d.%d.%.f",
Expand All @@ -36,7 +34,6 @@ void kcapi_versionstring(char *buf, uint32_t buflen)
KCAPI_MAJVERSION, KCAPI_MINVERSION, (double)KCAPI_PATCHLEVEL);
}

DSO_PUBLIC
uint32_t kcapi_version(void)
{
uint32_t version = 0;
Expand All @@ -48,7 +45,6 @@ uint32_t kcapi_version(void)
return version;
}

DSO_PUBLIC
int kcapi_pad_iv(struct kcapi_handle *handle,
const uint8_t *iv, uint32_t ivlen,
uint8_t **newiv, uint32_t *newivlen)
Expand All @@ -72,7 +68,6 @@ int kcapi_pad_iv(struct kcapi_handle *handle,
return 0;
}

DSO_PUBLIC
int kcapi_set_maxsplicesize(struct kcapi_handle *handle, unsigned int size)
{
int ret;
Expand Down Expand Up @@ -106,7 +101,6 @@ int kcapi_set_maxsplicesize(struct kcapi_handle *handle, unsigned int size)
return ret;
}

DSO_PUBLIC
int kcapi_get_maxsplicesize(struct kcapi_handle *handle)
{
unsigned int pagesize = (unsigned int)sysconf(_SC_PAGESIZE);
Expand Down

0 comments on commit 3e9a149

Please sign in to comment.