Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Alexandre Chartre and committed by
Peter Zijlstra
1013f2e3 55d2a473

+49 -5
+5 -1
tools/objtool/check.c
··· 12 12 #include <objtool/builtin.h> 13 13 #include <objtool/cfi.h> 14 14 #include <objtool/arch.h> 15 + #include <objtool/disas.h> 15 16 #include <objtool/check.h> 16 17 #include <objtool/special.h> 17 18 #include <objtool/warn.h> ··· 4803 4802 4804 4803 int check(struct objtool_file *file) 4805 4804 { 4805 + struct disas_context *disas_ctx; 4806 4806 int ret = 0, warnings = 0; 4807 4807 4808 4808 arch_initial_func_cfi_state(&initial_func_cfi); ··· 4945 4943 if (opts.verbose) { 4946 4944 if (opts.werror && warnings) 4947 4945 WARN("%d warning(s) upgraded to errors", warnings); 4948 - disas_warned_funcs(file); 4946 + disas_ctx = disas_context_create(file); 4947 + disas_warned_funcs(disas_ctx); 4948 + disas_context_destroy(disas_ctx); 4949 4949 } 4950 4950 4951 4951 if (opts.backup && make_backup())
+30 -2
tools/objtool/disas.c
··· 4 4 */ 5 5 6 6 #include <objtool/arch.h> 7 + #include <objtool/disas.h> 7 8 #include <objtool/warn.h> 8 9 9 10 #include <linux/string.h> 11 + 12 + struct disas_context { 13 + struct objtool_file *file; 14 + }; 15 + 16 + struct disas_context *disas_context_create(struct objtool_file *file) 17 + { 18 + struct disas_context *dctx; 19 + 20 + dctx = malloc(sizeof(*dctx)); 21 + if (!dctx) { 22 + WARN("failed to allocate disassembly context"); 23 + return NULL; 24 + } 25 + 26 + dctx->file = file; 27 + 28 + return dctx; 29 + } 30 + 31 + void disas_context_destroy(struct disas_context *dctx) 32 + { 33 + free(dctx); 34 + } 10 35 11 36 /* 'funcs' is a space-separated list of function names */ 12 37 static void disas_funcs(const char *funcs) ··· 83 58 } 84 59 } 85 60 86 - void disas_warned_funcs(struct objtool_file *file) 61 + void disas_warned_funcs(struct disas_context *dctx) 87 62 { 88 63 struct symbol *sym; 89 64 char *funcs = NULL, *tmp; 90 65 91 - for_each_sym(file->elf, sym) { 66 + if (!dctx) 67 + return; 68 + 69 + for_each_sym(dctx->file->elf, sym) { 92 70 if (sym->warned) { 93 71 if (!funcs) { 94 72 funcs = malloc(strlen(sym->name) + 1);
+14
tools/objtool/include/objtool/disas.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 + /* 3 + * Copyright (c) 2025, Oracle and/or its affiliates. 4 + */ 5 + 6 + #ifndef _DISAS_H 7 + #define _DISAS_H 8 + 9 + struct disas_context; 10 + struct disas_context *disas_context_create(struct objtool_file *file); 11 + void disas_context_destroy(struct disas_context *dctx); 12 + void disas_warned_funcs(struct disas_context *dctx); 13 + 14 + #endif /* _DISAS_H */
-2
tools/objtool/include/objtool/objtool.h
··· 49 49 int orc_dump(const char *objname); 50 50 int orc_create(struct objtool_file *file); 51 51 52 - void disas_warned_funcs(struct objtool_file *file); 53 - 54 52 #endif /* _OBJTOOL_H */