summaryrefslogtreecommitdiff
path: root/tools/objtool/disas.c
diff options
context:
space:
mode:
authorAlexandre Chartre <alexandre.chartre@oracle.com>2025-11-21 10:53:12 +0100
committerPeter Zijlstra <peterz@infradead.org>2025-11-21 15:30:06 +0100
commit1013f2e37bec39b1df5679e1c1e2572ece87c088 (patch)
tree19665abf64be0701afcfed6f32dc2a77c3411540 /tools/objtool/disas.c
parent55d2a473f317ab028d78a5c5ca69473643657c3d (diff)
downloadlinux-next-1013f2e37bec39b1df5679e1c1e2572ece87c088.tar.gz
linux-next-1013f2e37bec39b1df5679e1c1e2572ece87c088.zip
objtool: Create disassembly context
Create a structure to store information for disassembling functions. For now, it is just a wrapper around an objtool file. Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Link: https://patch.msgid.link/20251121095340.464045-3-alexandre.chartre@oracle.com
Diffstat (limited to 'tools/objtool/disas.c')
-rw-r--r--tools/objtool/disas.c32
1 files changed, 30 insertions, 2 deletions
diff --git a/tools/objtool/disas.c b/tools/objtool/disas.c
index 3a7cb1b8002e..7a18e51d43e6 100644
--- a/tools/objtool/disas.c
+++ b/tools/objtool/disas.c
@@ -4,10 +4,35 @@
*/
#include <objtool/arch.h>
+#include <objtool/disas.h>
#include <objtool/warn.h>
#include <linux/string.h>
+struct disas_context {
+ struct objtool_file *file;
+};
+
+struct disas_context *disas_context_create(struct objtool_file *file)
+{
+ struct disas_context *dctx;
+
+ dctx = malloc(sizeof(*dctx));
+ if (!dctx) {
+ WARN("failed to allocate disassembly context");
+ return NULL;
+ }
+
+ dctx->file = file;
+
+ return dctx;
+}
+
+void disas_context_destroy(struct disas_context *dctx)
+{
+ free(dctx);
+}
+
/* 'funcs' is a space-separated list of function names */
static void disas_funcs(const char *funcs)
{
@@ -58,12 +83,15 @@ static void disas_funcs(const char *funcs)
}
}
-void disas_warned_funcs(struct objtool_file *file)
+void disas_warned_funcs(struct disas_context *dctx)
{
struct symbol *sym;
char *funcs = NULL, *tmp;
- for_each_sym(file->elf, sym) {
+ if (!dctx)
+ return;
+
+ for_each_sym(dctx->file->elf, sym) {
if (sym->warned) {
if (!funcs) {
funcs = malloc(strlen(sym->name) + 1);