Blame src/logic/mdso_asmgen_symfn.c

6691d8
/****************************************************************/
6691d8
/*  mdso: midipix dso scavenger                                 */
78ab3c
/*  Copyright (C) 2015--2017  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>
18a091
#include "mdso_dprintf_impl.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
2c190d
int mdso_asmgen_symfn(
62fec7
	const struct mdso_driver_ctx *	dctx,
62fec7
	const char *			sym,
18a091
	int				fdout)
6691d8
{
6691d8
	const char * const * line;
af2280
	const char *         uscore;
af2280
18a091
	if (mdso_dprintf(fdout,"\t.file     \".%s_symfn.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++)
18a091
		if (mdso_dprintf(fdout,*line,uscore,sym) < 0)
62fec7
			return MDSO_FILE_ERROR(dctx);
6691d8
6691d8
	return 0;
6691d8
}