From: Ard Biesheuvel <ardb+git@google.com>
To: linux-kernel@vger.kernel.org
Cc: llvm@lists.linux.dev, keescook@chromium.org,
linux-hardening@vger.kernel.org, nathan@kernel.org,
Ard Biesheuvel <ardb@kernel.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Jan Beulich <jbeulich@suse.com>,
"Jose E. Marchesi" <jemarch@gnu.org>,
Kees Cook <kees@kernel.org>
Subject: [PATCH v3 3/8] objtool: Make some helper functions globally accessible
Date: Fri, 11 Oct 2024 19:08:51 +0200 [thread overview]
Message-ID: <20241011170847.334429-13-ardb+git@google.com> (raw)
In-Reply-To: <20241011170847.334429-10-ardb+git@google.com>
From: Ard Biesheuvel <ardb@kernel.org>
Move some helpers around so they can be used from arch specific jump
table code that is getting refactored in the next patch.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
tools/objtool/check.c | 22 ++++----------------
tools/objtool/include/objtool/check.h | 16 ++++++++++++++
2 files changed, 20 insertions(+), 18 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index b73e43b9b9e3..fbb05e973acc 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -61,8 +61,8 @@ struct instruction *next_insn_same_sec(struct objtool_file *file,
return insn;
}
-static struct instruction *next_insn_same_func(struct objtool_file *file,
- struct instruction *insn)
+struct instruction *next_insn_same_func(struct objtool_file *file,
+ struct instruction *insn)
{
struct instruction *next = next_insn_same_sec(file, insn);
struct symbol *func = insn_func(insn);
@@ -93,8 +93,8 @@ static struct instruction *prev_insn_same_sec(struct objtool_file *file,
return insn - 1;
}
-static struct instruction *prev_insn_same_sym(struct objtool_file *file,
- struct instruction *insn)
+struct instruction *prev_insn_same_sym(struct objtool_file *file,
+ struct instruction *insn)
{
struct instruction *prev = prev_insn_same_sec(file, insn);
@@ -110,11 +110,6 @@ static struct instruction *prev_insn_same_sym(struct objtool_file *file,
for_each_sec(file, __sec) \
sec_for_each_insn(file, __sec, insn)
-#define func_for_each_insn(file, func, insn) \
- for (insn = find_insn(file, func->sec, func->offset); \
- insn; \
- insn = next_insn_same_func(file, insn))
-
#define sym_for_each_insn(file, sym, insn) \
for (insn = find_insn(file, sym->sec, sym->offset); \
insn && insn->offset < sym->offset + sym->len; \
@@ -141,15 +136,6 @@ static inline struct symbol *insn_call_dest(struct instruction *insn)
return insn->_call_dest;
}
-static inline struct reloc *insn_jump_table(struct instruction *insn)
-{
- if (insn->type == INSN_JUMP_DYNAMIC ||
- insn->type == INSN_CALL_DYNAMIC)
- return insn->_jump_table;
-
- return NULL;
-}
-
static inline unsigned long insn_jump_table_size(struct instruction *insn)
{
if (insn->type == INSN_JUMP_DYNAMIC ||
diff --git a/tools/objtool/include/objtool/check.h b/tools/objtool/include/objtool/check.h
index e1cd13cd28a3..e2f755484c4a 100644
--- a/tools/objtool/include/objtool/check.h
+++ b/tools/objtool/include/objtool/check.h
@@ -114,14 +114,30 @@ static inline bool is_jump(struct instruction *insn)
return is_static_jump(insn) || is_dynamic_jump(insn);
}
+static inline struct reloc *insn_jump_table(struct instruction *insn)
+{
+ if (insn->type == INSN_JUMP_DYNAMIC ||
+ insn->type == INSN_CALL_DYNAMIC)
+ return insn->_jump_table;
+
+ return NULL;
+}
+
struct instruction *find_insn(struct objtool_file *file,
struct section *sec, unsigned long offset);
+struct instruction *prev_insn_same_sym(struct objtool_file *file, struct instruction *insn);
struct instruction *next_insn_same_sec(struct objtool_file *file, struct instruction *insn);
+struct instruction *next_insn_same_func(struct objtool_file *file, struct instruction *insn);
#define sec_for_each_insn(file, _sec, insn) \
for (insn = find_insn(file, _sec, 0); \
insn && insn->sec == _sec; \
insn = next_insn_same_sec(file, insn))
+#define func_for_each_insn(file, func, insn) \
+ for (insn = find_insn(file, func->sec, func->offset); \
+ insn; \
+ insn = next_insn_same_func(file, insn))
+
#endif /* _CHECK_H */
--
2.47.0.rc1.288.g06298d1525-goog
next prev parent reply other threads:[~2024-10-11 17:09 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 17:08 [PATCH v3 0/8] Improve objtool jump table handling Ard Biesheuvel
2024-10-11 17:08 ` [PATCH v3 1/8] objtool: Deal with relative jump tables correctly Ard Biesheuvel
2024-10-11 17:08 ` [PATCH v3 2/8] objtool: Allow arch code to discover jump table size Ard Biesheuvel
2024-12-03 10:45 ` [tip: objtool/core] " tip-bot2 for Ard Biesheuvel
2024-10-11 17:08 ` Ard Biesheuvel [this message]
2024-10-11 17:08 ` [PATCH v3 4/8] objtool: Move jump table heuristics to a x86 specific source file Ard Biesheuvel
2024-10-11 17:08 ` [PATCH v3 5/8] objtool: Add generic support for jump table annotations Ard Biesheuvel
2024-10-11 17:08 ` [PATCH v3 6/8] crypto: x86/crc32c - Use idiomatic relative jump table Ard Biesheuvel
2024-10-14 4:28 ` Eric Biggers
2024-10-14 9:36 ` Ard Biesheuvel
2024-10-11 17:08 ` [PATCH v3 7/8] crypto: x86/crc32c - Add jump table annotation Ard Biesheuvel
2024-10-11 17:08 ` [PATCH v3 8/8] crypto: x86/crc32c-intel - Tweaks to make objtool's life harder Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241011170847.334429-13-ardb+git@google.com \
--to=ardb+git@google.com \
--cc=ardb@kernel.org \
--cc=jbeulich@suse.com \
--cc=jemarch@gnu.org \
--cc=jpoimboe@kernel.org \
--cc=kees@kernel.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=nathan@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox