diff options
author | midipix <writeonce@midipix.org> | 2015-12-22 23:32:20 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-11-11 00:22:30 -0500 |
commit | 6691d883d212073b429b940edc8756b0179b4218 (patch) | |
tree | 84716ba85dd59e7c00222ed097752466e8dc54f2 /src | |
parent | efc615e033a4e0e3ed23e62edb3053a80a43b437 (diff) | |
download | mdso-6691d883d212073b429b940edc8756b0179b4218.tar.bz2 mdso-6691d883d212073b429b940edc8756b0179b4218.tar.xz |
mdso_generate_symfn(): initial implementation.
Diffstat (limited to 'src')
-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; +} |