+2016-12-27 H.J. Lu <hongjiu.lu@intel.com>
+ Alexander Ivchenko <alexander.ivchenko@intel.com>
+
+ * mpxwrap/libtool-version: New version.
+ * mpxwrap/mpx_wrappers.c (__mpx_wrapper_realloc): Make it
+ static with external alias.
+ (__mpx_wrapper_bzero): Ditto.
+ (mpx_wrapper_memcpy): Ditto.
+ (__mpx_wrapper_mempcpy): Ditto.
+
2016-12-26 Alexander Ivchenko <alexander.ivchenko@intel.com>
* mpxrt/libtool-version: New version.
#include <assert.h>
#include "mpxrt/mpxrt.h"
-void *
-__mpx_wrapper_malloc (size_t size)
+/* Since internal MPX wrapper calls must avoid PLT which will clear bound
+ registers, we make them static with an external alias. */
+#define EXTERN_ALIAS(f) \
+ __typeof (f) __##f __attribute__((alias(#f)));
+
+static void *
+mpx_wrapper_malloc (size_t size)
{
void *p = (void *)malloc (size);
if (!p) return __bnd_null_ptr_bounds (p);
return __bnd_set_ptr_bounds (p, size);
}
+EXTERN_ALIAS (mpx_wrapper_malloc)
void *
__mpx_wrapper_mmap (void *addr, size_t length, int prot, int flags,
__mpx_wrapper_realloc (void *ptr, size_t n)
{
if (!ptr)
- return __mpx_wrapper_malloc (n);
+ return mpx_wrapper_malloc (n);
/* We don't kwnow how much data is copied by realloc
and therefore may check only lower bounds. */
return __bnd_set_ptr_bounds (p, n_elements * element_size);
}
-void *
-__mpx_wrapper_memset (void *dstpp, int c, size_t len)
+static void *
+mpx_wrapper_memset (void *dstpp, int c, size_t len)
{
if (len > 0)
{
return dstpp;
}
+EXTERN_ALIAS (mpx_wrapper_memset)
+
void
__mpx_wrapper_bzero (void *dst, size_t len)
{
- __mpx_wrapper_memset (dst, 0, len);
+ mpx_wrapper_memset (dst, 0, len);
}
/* The mpx_pointer type is used for getting bits
return;
}
-void *
-__mpx_wrapper_memmove (void *dst, const void *src, size_t n)
+static void *
+mpx_wrapper_memmove (void *dst, const void *src, size_t n)
{
if (n == 0)
return dst;
return dst;
}
+EXTERN_ALIAS (mpx_wrapper_memmove)
-void *
-__mpx_wrapper_memcpy (void *dst, const void *src, size_t n)
+static void *
+mpx_wrapper_memcpy (void *dst, const void *src, size_t n)
{
- return __mpx_wrapper_memmove (dst, src, n);
+ return mpx_wrapper_memmove (dst, src, n);
}
+EXTERN_ALIAS (mpx_wrapper_memcpy)
+
void *
__mpx_wrapper_mempcpy (void *dst, const void *src, size_t n)
{
- return (char *)__mpx_wrapper_memcpy (dst, src, n) + n;
+ return (char *)mpx_wrapper_memcpy (dst, src, n) + n;
}
char *