summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/mapi/mapi/entry.c9
-rw-r--r--src/mapi/mapi/entry.h8
-rw-r--r--src/mapi/mapi/entry_x86-64_tls.h10
-rw-r--r--src/mapi/mapi/entry_x86_tls.h14
-rw-r--r--src/mapi/mapi/entry_x86_tsd.h11
-rw-r--r--src/mapi/mapi/mapi_abi.py22
-rw-r--r--src/mapi/mapi/stub.c8
7 files changed, 66 insertions, 16 deletions
diff --git a/src/mapi/mapi/entry.c b/src/mapi/mapi/entry.c
index 1f84ad910b5..69b6134bd27 100644
--- a/src/mapi/mapi/entry.c
+++ b/src/mapi/mapi/entry.c
@@ -42,6 +42,8 @@
#include "u_current.h"
/* C version of the public entries */
+#define MAPI_TMP_DEFINES
+#define MAPI_TMP_PUBLIC_DECLARES
#define MAPI_TMP_PUBLIC_ENTRIES
#include "mapi_tmp.h"
@@ -51,6 +53,13 @@ entry_patch_public(void)
}
mapi_func
+entry_get_public(int slot)
+{
+ /* pubic_entries are defined by MAPI_TMP_PUBLIC_ENTRIES */
+ return public_entries[slot];
+}
+
+mapi_func
entry_generate(int slot)
{
return NULL;
diff --git a/src/mapi/mapi/entry.h b/src/mapi/mapi/entry.h
index 48ed3f9ec4a..4d7e1f6d16e 100644
--- a/src/mapi/mapi/entry.h
+++ b/src/mapi/mapi/entry.h
@@ -32,15 +32,13 @@
#include "u_compiler.h"
#include "stub.h"
-/* declare public entries */
-#define MAPI_TMP_DEFINES
-#define MAPI_TMP_PUBLIC_DECLARES
-#include "mapi_tmp.h"
-
void
entry_patch_public(void);
mapi_func
+entry_get_public(int slot);
+
+mapi_func
entry_generate(int slot);
void
diff --git a/src/mapi/mapi/entry_x86-64_tls.h b/src/mapi/mapi/entry_x86-64_tls.h
index 2c02933802f..d14bf1c3946 100644
--- a/src/mapi/mapi/entry_x86-64_tls.h
+++ b/src/mapi/mapi/entry_x86-64_tls.h
@@ -49,6 +49,9 @@ __asm__("x86_64_current_tls:\n\t"
"movq u_current_table@GOTTPOFF(%rip), %rax\n\t"
"ret");
+__asm__(".balign 32\n"
+ "x86_64_entry_start:");
+
#define STUB_ASM_ENTRY(func) \
".globl " func "\n" \
".type " func ", @function\n" \
@@ -71,6 +74,13 @@ entry_patch_public(void)
{
}
+mapi_func
+entry_get_public(int slot)
+{
+ extern char x86_64_entry_start[];
+ return (mapi_func) (x86_64_entry_start + slot * 32);
+}
+
void
entry_patch(mapi_func entry, int slot)
{
diff --git a/src/mapi/mapi/entry_x86_tls.h b/src/mapi/mapi/entry_x86_tls.h
index 3d0b7caffe1..ea63490e1c7 100644
--- a/src/mapi/mapi/entry_x86_tls.h
+++ b/src/mapi/mapi/entry_x86_tls.h
@@ -54,11 +54,12 @@ __asm__("x86_current_tls:\n\t"
"ret");
#ifndef GLX_X86_READONLY_TEXT
-__asm__(".section wtext, \"awx\", @progbits\n"
- ".balign 16\n"
- "x86_entry_start:");
+__asm__(".section wtext, \"awx\", @progbits");
#endif /* GLX_X86_READONLY_TEXT */
+__asm__(".balign 16\n"
+ "x86_entry_start:");
+
#define STUB_ASM_ENTRY(func) \
".globl " func "\n" \
".type " func ", @function\n" \
@@ -101,6 +102,13 @@ entry_patch_public(void)
#endif
}
+mapi_func
+entry_get_public(int slot)
+{
+ extern char x86_entry_start[];
+ return (mapi_func) (x86_entry_start + slot * 16);
+}
+
void
entry_patch(mapi_func entry, int slot)
{
diff --git a/src/mapi/mapi/entry_x86_tsd.h b/src/mapi/mapi/entry_x86_tsd.h
index f37c7473a6f..0a07ad74247 100644
--- a/src/mapi/mapi/entry_x86_tsd.h
+++ b/src/mapi/mapi/entry_x86_tsd.h
@@ -32,7 +32,9 @@
#define X86_ENTRY_SIZE 32
-__asm__(".text");
+__asm__(".text\n"
+ ".balign 32\n"
+ "x86_entry_start:");
#define STUB_ASM_ENTRY(func) \
".globl " func "\n" \
@@ -60,6 +62,13 @@ entry_patch_public(void)
{
}
+mapi_func
+entry_get_public(int slot)
+{
+ extern const char x86_entry_start[];
+ return (mapi_func) (x86_entry_start + slot * X86_ENTRY_SIZE);
+}
+
void
entry_patch(mapi_func entry, int slot)
{
diff --git a/src/mapi/mapi/mapi_abi.py b/src/mapi/mapi/mapi_abi.py
index 0949219c2c4..5c212420a80 100644
--- a/src/mapi/mapi/mapi_abi.py
+++ b/src/mapi/mapi/mapi_abi.py
@@ -378,6 +378,19 @@ class ABIPrinter(object):
return '\n\n'.join(dispatches)
+ def c_public_initializer(self, prefix):
+ """Return the initializer for public dispatch functions."""
+ names = []
+ for ent in self.entries:
+ if ent.alias:
+ continue
+
+ name = '%s(mapi_func) %s' % (self.indent,
+ self._c_function_call(ent, prefix))
+ names.append(name)
+
+ return ',\n'.join(names)
+
def c_stub_string_pool(self):
"""Return the string pool for use by stubs."""
# sort entries by their names
@@ -400,9 +413,8 @@ class ABIPrinter(object):
"""Return the initializer for struct mapi_stub array."""
stubs = []
for ent in self.entries_sorted_by_names:
- stubs.append('%s{ (mapi_func) %s, %d, (void *) %d }' % (
- self.indent, self._c_function_call(ent, prefix),
- ent.slot, pool_offsets[ent]))
+ stubs.append('%s{ (void *) %d, %d, NULL }' % (
+ self.indent, pool_offsets[ent], ent.slot))
return ',\n'.join(stubs)
@@ -526,6 +538,10 @@ class ABIPrinter(object):
print
print '#ifdef MAPI_TMP_PUBLIC_ENTRIES'
print self.c_public_dispatches(self.prefix_lib)
+ print
+ print 'static const mapi_func public_entries[] = {'
+ print self.c_public_initializer(self.prefix_lib)
+ print '};'
print '#undef MAPI_TMP_PUBLIC_ENTRIES'
print '#endif /* MAPI_TMP_PUBLIC_ENTRIES */'
diff --git a/src/mapi/mapi/stub.c b/src/mapi/mapi/stub.c
index 9a5c1d694b3..99b475a3b4b 100644
--- a/src/mapi/mapi/stub.c
+++ b/src/mapi/mapi/stub.c
@@ -27,7 +27,6 @@
*/
#include <stdlib.h>
-#include <stddef.h> /* for offsetof */
#include <string.h>
#include <assert.h>
@@ -40,9 +39,9 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
struct mapi_stub {
- mapi_func addr;
- int slot;
const void *name;
+ int slot;
+ mapi_func addr;
};
/* define public_string_pool and public_stubs */
@@ -203,5 +202,6 @@ stub_get_slot(const struct mapi_stub *stub)
mapi_func
stub_get_addr(const struct mapi_stub *stub)
{
- return stub->addr;
+ assert(stub->addr || (unsigned int) stub->slot < MAPI_TABLE_NUM_STATIC);
+ return (stub->addr) ? stub->addr : entry_get_public(stub->slot);
}