about summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-07-03 14:14:17 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-07-03 14:14:17 +0200
commit672a41a79cbcfa095d6951112d592354e0efbd5a (patch)
tree3a0b361da40ab3cb2562f7e18e7de20a9018c93e /tests
parent48b881f4912bc795e0467e334e359e9876f73c4f (diff)
downloadbox64-672a41a79cbcfa095d6951112d592354e0efbd5a.tar.gz
box64-672a41a79cbcfa095d6951112d592354e0efbd5a.zip
Added support for R_X86_64_IRELATIVE reloc, along with a test for it (for #303)
Diffstat (limited to 'tests')
-rw-r--r--tests/ref20.txt2
-rwxr-xr-xtests/test20bin0 -> 17616 bytes
-rw-r--r--tests/test20.c21
3 files changed, 23 insertions, 0 deletions
diff --git a/tests/ref20.txt b/tests/ref20.txt
new file mode 100644
index 00000000..fa4fb4f7
--- /dev/null
+++ b/tests/ref20.txt
@@ -0,0 +1,2 @@
+
+Called function number 2
diff --git a/tests/test20 b/tests/test20
new file mode 100755
index 00000000..98de9e83
--- /dev/null
+++ b/tests/test20
Binary files differdiff --git a/tests/test20.c b/tests/test20.c
new file mode 100644
index 00000000..d80a5f5b
--- /dev/null
+++ b/tests/test20.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+int myfunc1() { return 1; }
+int myfunc2() { return 2; }
+
+// Prototype for the common entry point
+/*extern "C" */int myfunc();
+__asm__ (".type myfunc, @gnu_indirect_function");
+// Make the dispatcher function. This returns a pointer to the desired function version
+typeof(myfunc) * myfunc_dispatch (void) __asm__ ("myfunc");
+typeof(myfunc) * myfunc_dispatch (void)  {
+if (0) 
+  return &myfunc1;
+else
+  return &myfunc2;
+}
+
+int main() {
+   printf("\nCalled function number %i\n", myfunc());
+   return 0;
+}
+