Blame src/logic/mdso_generate_symfn.c

6691d8
/****************************************************************/
6691d8
/*  mdso: midipix dso scavenger                                 */
3e816c
/*  Copyright (C) 2015--2016  Z. Gilboa                         */
6691d8
/*  Released under GPLv2 and GPLv3; see COPYING.MDSO.           */
6691d8
/****************************************************************/
6691d8
6691d8
#include <stdint.h>
6691d8
#include <stdio.h>
62fec7
6691d8
#include <mdso/mdso.h>
62fec7
#include "mdso_errinfo_impl.h"
6691d8
6691d8
static const char * const asm_lines[] = {
6691d8
	"\t.section  .text\n",
af2280
	"\t.globl    %s%s\n",
af2280
	"\t.def      %s%s; .scl 2; .type 32; .endef\n\n",
6691d8
af2280
	"%s%s:\n",
af2280
	"\tjmp *__imp_%s%s\n\n",
6691d8
	0
6691d8
};
6691d8
62fec7
int mdso_generate_symfn(
62fec7
	const struct mdso_driver_ctx *	dctx,
62fec7
	const char *			sym,
62fec7
	FILE *				fout)
6691d8
{
6691d8
	const char * const * line;
af2280
	const char *         uscore;
af2280
af2280
	if (fprintf(fout,"\t.file     \"__%s_sym_fn.s\"\n",sym) < 0)
af2280
		return MDSO_FILE_ERROR(dctx);
af2280
af2280
	uscore = (dctx->cctx->drvflags & MDSO_DRIVER_QUAD_PTR)
af2280
		? "" : "_";
6691d8
6691d8
	for (line=asm_lines; *line; line++)
af2280
		if (fprintf(fout,*line,uscore,sym) < 0)
62fec7
			return MDSO_FILE_ERROR(dctx);
6691d8
6691d8
	return 0;
6691d8
}