summaryrefslogtreecommitdiff
path: root/tools/objtool/include/objtool/disas.h
blob: e8f395eff1598594310fa510ab0261d6e97beec6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (c) 2025, Oracle and/or its affiliates.
 */

#ifndef _DISAS_H
#define _DISAS_H

struct alternative;
struct disas_context;
struct disassemble_info;

#ifdef DISAS

struct disas_context *disas_context_create(struct objtool_file *file);
void disas_context_destroy(struct disas_context *dctx);
void disas_warned_funcs(struct disas_context *dctx);
void disas_funcs(struct disas_context *dctx);
int disas_info_init(struct disassemble_info *dinfo,
		    int arch, int mach32, int mach64,
		    const char *options);
size_t disas_insn(struct disas_context *dctx, struct instruction *insn);
char *disas_result(struct disas_context *dctx);
void disas_print_info(FILE *stream, struct instruction *insn, int depth,
		      const char *format, ...);
void disas_print_insn(FILE *stream, struct disas_context *dctx,
		      struct instruction *insn, int depth,
		      const char *format, ...);
char *disas_alt_name(struct alternative *alt);
const char *disas_alt_type_name(struct instruction *insn);

#else /* DISAS */

#include <objtool/warn.h>

static inline struct disas_context *disas_context_create(struct objtool_file *file)
{
	WARN("Rebuild with libopcodes for disassembly support");
	return NULL;
}

static inline void disas_context_destroy(struct disas_context *dctx) {}
static inline void disas_warned_funcs(struct disas_context *dctx) {}
static inline void disas_funcs(struct disas_context *dctx) {}

static inline int disas_info_init(struct disassemble_info *dinfo,
				  int arch, int mach32, int mach64,
				  const char *options)
{
	return -1;
}

static inline size_t disas_insn(struct disas_context *dctx,
				struct instruction *insn)
{
	return -1;
}

static inline char *disas_result(struct disas_context *dctx)
{
	return NULL;
}

static inline void disas_print_info(FILE *stream, struct instruction *insn,
				    int depth, const char *format, ...) {}
static inline void disas_print_insn(FILE *stream, struct disas_context *dctx,
				    struct instruction *insn, int depth,
				    const char *format, ...) {}
static inline char *disas_alt_name(struct alternative *alt)
{
	return NULL;
}

static inline const char *disas_alt_type_name(struct instruction *insn)
{
	return NULL;
}

#endif /* DISAS */

#endif /* _DISAS_H */