diff options
author | Josh Poimboeuf <jpoimboe@redhat.com> | 2019-07-17 21:36:50 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2019-07-18 15:01:08 -0400 |
commit | 8e25c9f8b482ea8d8b6fb4f6f5c09bcc5ee18663 (patch) | |
tree | 9d9e6bf2c268d3886d5485b13ba373677fe48bab | |
parent | 61e9b75a0ccf1fecacc28a2d77ea4a19aa404e39 (diff) |
objtool: Change dead_end_function() to return boolean
dead_end_function() can no longer return an error. Simplify its
interface by making it return boolean.
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/9e6679610768fb6e6c51dca23f7d4d0c03b0c910.1563413318.git.jpoimboe@redhat.com
-rw-r--r-- | tools/objtool/check.c | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c index dece3253ff6a..d9d1c9b54947 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c | |||
@@ -105,14 +105,9 @@ static struct instruction *next_insn_same_func(struct objtool_file *file, | |||
105 | * | 105 | * |
106 | * For local functions, we have to detect them manually by simply looking for | 106 | * For local functions, we have to detect them manually by simply looking for |
107 | * the lack of a return instruction. | 107 | * the lack of a return instruction. |
108 | * | ||
109 | * Returns: | ||
110 | * -1: error | ||
111 | * 0: no dead end | ||
112 | * 1: dead end | ||
113 | */ | 108 | */ |
114 | static int __dead_end_function(struct objtool_file *file, struct symbol *func, | 109 | static bool __dead_end_function(struct objtool_file *file, struct symbol *func, |
115 | int recursion) | 110 | int recursion) |
116 | { | 111 | { |
117 | int i; | 112 | int i; |
118 | struct instruction *insn; | 113 | struct instruction *insn; |
@@ -139,29 +134,29 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func, | |||
139 | }; | 134 | }; |
140 | 135 | ||
141 | if (func->bind == STB_WEAK) | 136 | if (func->bind == STB_WEAK) |
142 | return 0; | 137 | return false; |
143 | 138 | ||
144 | if (func->bind == STB_GLOBAL) | 139 | if (func->bind == STB_GLOBAL) |
145 | for (i = 0; i < ARRAY_SIZE(global_noreturns); i++) | 140 | for (i = 0; i < ARRAY_SIZE(global_noreturns); i++) |
146 | if (!strcmp(func->name, global_noreturns[i])) | 141 | if (!strcmp(func->name, global_noreturns[i])) |
147 | return 1; | 142 | return true; |
148 | 143 | ||
149 | if (!func->len) | 144 | if (!func->len) |
150 | return 0; | 145 | return false; |
151 | 146 | ||
152 | insn = find_insn(file, func->sec, func->offset); | 147 | insn = find_insn(file, func->sec, func->offset); |
153 | if (!insn->func) | 148 | if (!insn->func) |
154 | return 0; | 149 | return false; |
155 | 150 | ||
156 | func_for_each_insn_all(file, func, insn) { | 151 | func_for_each_insn_all(file, func, insn) { |
157 | empty = false; | 152 | empty = false; |
158 | 153 | ||
159 | if (insn->type == INSN_RETURN) | 154 | if (insn->type == INSN_RETURN) |
160 | return 0; | 155 | return false; |
161 | } | 156 | } |
162 | 157 | ||
163 | if (empty) | 158 | if (empty) |
164 | return 0; | 159 | return false; |
165 | 160 | ||
166 | /* | 161 | /* |
167 | * A function can have a sibling call instead of a return. In that | 162 | * A function can have a sibling call instead of a return. In that |
@@ -174,7 +169,7 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func, | |||
174 | 169 | ||
175 | if (!dest) | 170 | if (!dest) |
176 | /* sibling call to another file */ | 171 | /* sibling call to another file */ |
177 | return 0; | 172 | return false; |
178 | 173 | ||
179 | if (dest->func && dest->func->pfunc != insn->func->pfunc) { | 174 | if (dest->func && dest->func->pfunc != insn->func->pfunc) { |
180 | 175 | ||
@@ -186,7 +181,7 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func, | |||
186 | * This is a very rare case. It means | 181 | * This is a very rare case. It means |
187 | * they aren't dead ends. | 182 | * they aren't dead ends. |
188 | */ | 183 | */ |
189 | return 0; | 184 | return false; |
190 | } | 185 | } |
191 | 186 | ||
192 | return __dead_end_function(file, dest->func, | 187 | return __dead_end_function(file, dest->func, |
@@ -196,13 +191,13 @@ static int __dead_end_function(struct objtool_file *file, struct symbol *func, | |||
196 | 191 | ||
197 | if (insn->type == INSN_JUMP_DYNAMIC && list_empty(&insn->alts)) | 192 | if (insn->type == INSN_JUMP_DYNAMIC && list_empty(&insn->alts)) |
198 | /* sibling call */ | 193 | /* sibling call */ |
199 | return 0; | 194 | return false; |
200 | } | 195 | } |
201 | 196 | ||
202 | return 1; | 197 | return true; |
203 | } | 198 | } |
204 | 199 | ||
205 | static int dead_end_function(struct objtool_file *file, struct symbol *func) | 200 | static bool dead_end_function(struct objtool_file *file, struct symbol *func) |
206 | { | 201 | { |
207 | return __dead_end_function(file, func, 0); | 202 | return __dead_end_function(file, func, 0); |
208 | } | 203 | } |
@@ -2080,11 +2075,8 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, | |||
2080 | if (is_fentry_call(insn)) | 2075 | if (is_fentry_call(insn)) |
2081 | break; | 2076 | break; |
2082 | 2077 | ||
2083 | ret = dead_end_function(file, insn->call_dest); | 2078 | if (dead_end_function(file, insn->call_dest)) |
2084 | if (ret == 1) | ||
2085 | return 0; | 2079 | return 0; |
2086 | if (ret == -1) | ||
2087 | return 1; | ||
2088 | } | 2080 | } |
2089 | 2081 | ||
2090 | if (!no_fp && func && !has_valid_stack_frame(&state)) { | 2082 | if (!no_fp && func && !has_valid_stack_frame(&state)) { |