diff options
Diffstat (limited to 'src/logic')
-rw-r--r-- | src/logic/mdso_generate_symfn.c | 31 |
1 files changed, 31 insertions, 0 deletions
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; +} |