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 | |
parent | efc615e033a4e0e3ed23e62edb3053a80a43b437 (diff) | |
download | mdso-6691d883d212073b429b940edc8756b0179b4218.tar.bz2 mdso-6691d883d212073b429b940edc8756b0179b4218.tar.xz |
mdso_generate_symfn(): initial implementation.
-rw-r--r-- | include/mdso/mdso.h | 1 | ||||
-rw-r--r-- | project/common.mk | 1 | ||||
-rw-r--r-- | src/logic/mdso_generate_symfn.c | 31 |
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; +} |