[RFC,v1,21/23] objtool: Add arch-specific "noreturn" function handling
Commit Message
Fix the following warnings:
arch/loongarch/mm/fault.o: warning: objtool: no_context.part.0() falls through to
next function do_sigsegv()
It should mark 'dead_end' when the function is "noreturn/__noreturn".
Signed-off-by: Youling Tang <tangyouling@loongson.cn>
---
tools/objtool/arch/loongarch/special.c | 5 +++++
tools/objtool/arch/powerpc/special.c | 3 +++
tools/objtool/arch/x86/special.c | 4 ++++
tools/objtool/check.c | 7 ++++++-
tools/objtool/include/objtool/special.h | 3 +++
5 files changed, 21 insertions(+), 1 deletion(-)
@@ -5,6 +5,11 @@
#include <objtool/special.h>
#include <objtool/builtin.h>
+/* Architecture specific "noreturn" function */
+const char * const arch_noreturns[] = {
+ "die",
+};
+int arch_noreturns_size = ARRAY_SIZE(arch_noreturns);
bool arch_support_alt_relocation(struct special_alt *special_alt,
struct instruction *insn,
@@ -4,6 +4,9 @@
#include <objtool/special.h>
#include <objtool/builtin.h>
+/* Architecture specific "noreturn" function */
+const char * const arch_noreturns[] = {};
+int arch_noreturns_size = ARRAY_SIZE(arch_noreturns);
bool arch_support_alt_relocation(struct special_alt *special_alt,
struct instruction *insn,
@@ -7,6 +7,10 @@
#define X86_FEATURE_POPCNT (4 * 32 + 23)
#define X86_FEATURE_SMAP (9 * 32 + 20)
+/* Architecture specific "noreturn" function */
+const char * const arch_noreturns[] = {};
+int arch_noreturns_size = ARRAY_SIZE(arch_noreturns);
+
void arch_handle_alternative(unsigned short feature, struct special_alt *alt)
{
switch (feature) {
@@ -110,11 +110,16 @@ static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
if (func->bind == STB_WEAK)
return false;
- if (func->bind == STB_GLOBAL)
+ if (func->bind == STB_GLOBAL) {
for (i = 0; i < ARRAY_SIZE(global_noreturns); i++)
if (!strcmp(func->name, global_noreturns[i]))
return true;
+ for (i = 0; i < arch_noreturns_size; i++)
+ if (!strcmp(func->name, arch_noreturns[i]))
+ return true;
+ }
+
if (!func->len)
return false;
@@ -30,6 +30,9 @@ struct special_alt {
unsigned int orig_len, new_len; /* group only */
};
+extern const char * const arch_noreturns[];
+extern int arch_noreturns_size;
+
int special_get_alts(struct elf *elf, struct list_head *alts);
void arch_handle_alternative(unsigned short feature, struct special_alt *alt);