summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2010-08-09 20:05:22 +0200
committerMiloslav Trmač <mitr@redhat.com>2010-08-24 20:58:32 +0200
commit22aabeef3cb9344614cc9b58e9e97208df04e711 (patch)
treea6ad50c347395252015d0d648ab25cd69e2b09ba
parentc8ccfedd9bfd53274800d39f58ed335db97caf1a (diff)
downloadcryptodev-linux-22aabeef3cb9344614cc9b58e9e97208df04e711.tar.gz
cryptodev-linux-22aabeef3cb9344614cc9b58e9e97208df04e711.tar.xz
cryptodev-linux-22aabeef3cb9344614cc9b58e9e97208df04e711.zip
Avoid unnecessary internal relocations
Use __attribute__((visibility("hidden"))) for __ncr_file_descriptor to take advantage of PIC addressing instead of going through the dynamic linker. Add an internal alias for ncr_global_init() for the same reason. Add an internal header file to consolidate the "extern" references in the process.
-rw-r--r--userspace/Makefile2
-rw-r--r--userspace/ncrypto_fd.c9
-rw-r--r--userspace/ncrypto_internal.h8
-rw-r--r--userspace/ncrypto_key.c5
-rw-r--r--userspace/ncrypto_masterkey.c3
-rw-r--r--userspace/ncrypto_session.c3
6 files changed, 21 insertions, 9 deletions
diff --git a/userspace/Makefile b/userspace/Makefile
index 9431327..a2757a4 100644
--- a/userspace/Makefile
+++ b/userspace/Makefile
@@ -17,7 +17,7 @@ libcryptodev.so: ${libobj}
ln -sf libcryptodev.so.0.0 libcryptodev.so.0
ln -sf libcryptodev.so.0.0 libcryptodev.so
-$(libobj): linux/ncr.h
+$(libobj): linux/ncr.h ncrypto_internal.h
linux/ncr.h: ../ncr.h
mkdir -p linux
diff --git a/userspace/ncrypto_fd.c b/userspace/ncrypto_fd.c
index 7e6741d..f4dee3e 100644
--- a/userspace/ncrypto_fd.c
+++ b/userspace/ncrypto_fd.c
@@ -5,13 +5,14 @@
#include <unistd.h>
#include <linux/ncr.h>
#include "ncrypto.h"
+#include "ncrypto_internal.h"
int __ncr_file_descriptor = -1;
static int open_count = 0;
static pthread_mutex_t open_lock = PTHREAD_MUTEX_INITIALIZER;
int
-ncr_global_init(unsigned int flags)
+__ncr_global_init()
{
int rv = 0;
@@ -25,6 +26,12 @@ ncr_global_init(unsigned int flags)
return rv;
}
+int
+ncr_global_init(unsigned int flags)
+{
+ return __ncr_global_init();
+}
+
void
ncr_global_deinit(void)
{
diff --git a/userspace/ncrypto_internal.h b/userspace/ncrypto_internal.h
new file mode 100644
index 0000000..29b2d8a
--- /dev/null
+++ b/userspace/ncrypto_internal.h
@@ -0,0 +1,8 @@
+#ifndef NCRYPTO_INTERNAL_H__
+#define NCRYPTO_INTERNAL_H__
+
+extern int __ncr_file_descriptor __attribute__((visibility ("hidden")));
+
+extern int __ncr_global_init(void) __attribute__((visibility ("hidden")));
+
+#endif
diff --git a/userspace/ncrypto_key.c b/userspace/ncrypto_key.c
index 5321c78..9201d43 100644
--- a/userspace/ncrypto_key.c
+++ b/userspace/ncrypto_key.c
@@ -5,13 +5,12 @@
#include <errno.h>
#include <linux/ncr.h>
#include "ncrypto.h"
-
-extern int __ncr_file_descriptor;
+#include "ncrypto_internal.h"
int
ncr_key_init(ncr_key_t *key)
{
- if ((__ncr_file_descriptor < 0) && (ncr_global_init(0) < 0))
+ if ((__ncr_file_descriptor < 0) && (__ncr_global_init() < 0))
return -1;
if (ioctl(__ncr_file_descriptor, NCRIO_KEY_INIT, key) < 0)
diff --git a/userspace/ncrypto_masterkey.c b/userspace/ncrypto_masterkey.c
index 5910ac0..68c79ee 100644
--- a/userspace/ncrypto_masterkey.c
+++ b/userspace/ncrypto_masterkey.c
@@ -5,8 +5,7 @@
#include <errno.h>
#include <linux/ncr.h>
#include "ncrypto.h"
-
-extern int __ncr_file_descriptor;
+#include "ncrypto_internal.h"
int
ncr_masterkey_set(void *key, size_t key_size)
diff --git a/userspace/ncrypto_session.c b/userspace/ncrypto_session.c
index e14dba2..03ede25 100644
--- a/userspace/ncrypto_session.c
+++ b/userspace/ncrypto_session.c
@@ -5,8 +5,7 @@
#include <errno.h>
#include <linux/ncr.h>
#include "ncrypto.h"
-
-extern int __ncr_file_descriptor;
+#include "ncrypto_internal.h"
int
ncr_session_once_key_data(ncr_key_t key, ncr_key_params_t params, ncr_crypto_op_t op, ncr_algorithm_t algorithm, ncr_key_t input, void *output, size_t output_size)