summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mdso/mdso.h1
-rw-r--r--project/common.mk1
-rw-r--r--src/logic/mdso_generate_symfn.c31
3 files changed, 33 insertions, 0 deletions
diff --git a/include/mdso/mdso.h b/include/mdso/mdso.h
index 2ac8dd4..88159fc 100644
--- a/include/mdso/mdso.h
+++ b/include/mdso/mdso.h
@@ -92,6 +92,7 @@ mdso_api uint32_t mdso_crc32_mbstr (const unsigned char * str, size_t * symlen);
mdso_api uint64_t mdso_crc64_mbstr (const unsigned char * str, size_t * symlen);
mdso_api FILE * mdso_create_output (const struct mdso_driver_ctx *, const char * asmname);
mdso_api int mdso_generate_symentry(const struct mdso_common_ctx *, const char * sym, FILE * fout);
+mdso_api int mdso_generate_symfn (const char * sym, FILE * fout);
#ifdef __cplusplus
}
diff --git a/project/common.mk b/project/common.mk
index 2533550..9278e97 100644
--- a/project/common.mk
+++ b/project/common.mk
@@ -4,6 +4,7 @@ COMMON_SRCS = \
src/driver/mdso_driver_ctx.c \
src/driver/mdso_unit_ctx.c \
src/logic/mdso_generate_symentry.c \
+ src/logic/mdso_generate_symfn.c \
src/logic/mdso_map_input.c \
src/output/mdso_create_output.c \
src/output/mdso_output_export_symbols.c \
diff --git a/src/logic/mdso_generate_symfn.c b/src/logic/mdso_generate_symfn.c
new file mode 100644
index 0000000..4e8de54
--- /dev/null
+++ b/src/logic/mdso_generate_symfn.c
@@ -0,0 +1,31 @@
+/****************************************************************/
+/* mdso: midipix dso scavenger */
+/* Copyright (C) 2015 Z. Gilboa */
+/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
+/****************************************************************/
+
+#include <stdint.h>
+#include <stdio.h>
+#include <mdso/mdso.h>
+
+static const char * const asm_lines[] = {
+ "\t.file \"__%s_sym_fn.s\"\n",
+ "\t.section .text\n",
+ "\t.globl %s\n",
+ "\t.def %s; .scl 2; .type 32; .endef\n\n",
+
+ "%s:\n",
+ "\tjmp *__imp_%s\n\n",
+ 0
+};
+
+int mdso_generate_symfn(const char * sym, FILE * fout)
+{
+ const char * const * line;
+
+ for (line=asm_lines; *line; line++)
+ if ((fprintf(fout,*line,sym)) < 0)
+ return -1;
+
+ return 0;
+}