diff mbox series

[09/11] objtool: Include weak functions in global_noreturns check

Message ID c5939160ab44a078b00adfb55966cb8fe4fb065b.1680912057.git.jpoimboe@kernel.org (mailing list archive)
State New, archived
Headers show
Series Sprinkle more __noreturn | expand

Commit Message

Josh Poimboeuf April 8, 2023, 12:10 a.m. UTC
If a global function doesn't return, and its prototype has the
__noreturn attribute, its weak counterpart must also not return so that
it matches the prototype and meets call site expectations.

To properly follow the compiled control flow at the call sites, change
the global_noreturns check to include both global and weak functions.

On the other hand, if a weak function isn't in global_noreturns, assume
the prototype doesn't have __noreturn.  Even if the weak function
doesn't return, call sites treat it like a returnable function.

Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
 tools/objtool/check.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a926da218c01..a42a2af99ea2 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -239,14 +239,14 @@  static bool __dead_end_function(struct objtool_file *file, struct symbol *func,
 	if (!func)
 		return false;
 
-	if (func->bind == STB_WEAK)
-		return false;
-
-	if (func->bind == STB_GLOBAL)
+	if (func->bind == STB_GLOBAL || func->bind == STB_WEAK)
 		for (i = 0; i < ARRAY_SIZE(global_noreturns); i++)
 			if (!strcmp(func->name, global_noreturns[i]))
 				return true;
 
+	if (func->bind == STB_WEAK)
+		return false;
+
 	if (!func->len)
 		return false;