|
|
efc615 |
/****************************************************************/
|
|
|
efc615 |
/* mdso: midipix dso scavenger */
|
|
|
efc615 |
/* Copyright (C) 2015 Z. Gilboa */
|
|
|
efc615 |
/* Released under GPLv2 and GPLv3; see COPYING.MDSO. */
|
|
|
efc615 |
/****************************************************************/
|
|
|
efc615 |
|
|
|
efc615 |
#include <stdint.h>
|
|
|
efc615 |
#include <stdio.h>
|
|
|
efc615 |
#include <mdso/mdso.h>
|
|
|
efc615 |
#include <mdso/mdso_specs.h>
|
|
|
efc615 |
|
|
|
efc615 |
static const char * const asm_lines[] = {
|
|
|
efc615 |
"\t.file \"__%s_sym_entry.s\"\n",
|
|
|
efc615 |
|
|
|
efc615 |
"\t.section " MDSO_STRS_SECTION ",\"r\"\n",
|
|
|
efc615 |
"\t.globl .__dsostr_%s\n",
|
|
|
efc615 |
"\t.balign 2\n\n",
|
|
|
efc615 |
".__dsostr_%s:\n",
|
|
|
efc615 |
"\t.ascii\t\"%s\\0\"\n\n"
|
|
|
efc615 |
|
|
|
efc615 |
"\t.section " MDSO_SYMS_SECTION ",\"r\"\n",
|
|
|
efc615 |
"\t.globl __imp_%s\n",
|
|
|
efc615 |
0
|
|
|
efc615 |
};
|
|
|
efc615 |
|
|
|
efc615 |
int mdso_generate_symentry(
|
|
|
efc615 |
const struct mdso_common_ctx * cctx,
|
|
|
efc615 |
const char * sym,
|
|
|
efc615 |
FILE * fout)
|
|
|
efc615 |
{
|
|
|
efc615 |
const char * const * line;
|
|
|
efc615 |
const char * alignstr;
|
|
|
efc615 |
const char * ptrsize;
|
|
|
efc615 |
|
|
|
efc615 |
if (cctx->drvflags & MDSO_DRIVER_QUAD_PTR) {
|
|
|
efc615 |
alignstr = "\t.balign 16\n\n";
|
|
|
efc615 |
ptrsize = ".quad";
|
|
|
efc615 |
} else {
|
|
|
efc615 |
alignstr = "\t.balign 8\n\n";
|
|
|
efc615 |
ptrsize = ".long";
|
|
|
efc615 |
}
|
|
|
efc615 |
|
|
|
efc615 |
for (line=asm_lines; *line; line++)
|
|
|
efc615 |
if ((fprintf(fout,*line,sym)) < 0)
|
|
|
efc615 |
return -1;
|
|
|
efc615 |
|
|
|
efc615 |
if ((fputs(alignstr,fout)) < 0)
|
|
|
efc615 |
return -1;
|
|
|
efc615 |
|
|
|
efc615 |
if ((fprintf(fout,"__imp_%s:\n",sym)) < 0)
|
|
|
efc615 |
return -1;
|
|
|
efc615 |
|
|
|
efc615 |
if ((fprintf(fout,"\t%s\t.__dsostr_%s\n",ptrsize,sym)) < 0)
|
|
|
efc615 |
return -1;
|
|
|
efc615 |
|
|
|
efc615 |
if ((fprintf(fout,"\t%s\t.__dsometa_%s\n",ptrsize,cctx->libname)) < 0)
|
|
|
efc615 |
return -1;
|
|
|
efc615 |
|
|
|
efc615 |
return 0;
|
|
|
efc615 |
}
|