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: Don't set 'jump_dest' for sibling calls

For most sibling calls, 'jump_dest' is NULL because objtool treats the
jump like a call and sets 'call_dest'. But there are a few edge cases
where that's not true. Make it consistent to avoid unexpected behavior.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/8737d6b9d1691831aed73375f444f0f42da3e2c9.1649718562.git.jpoimboe@redhat.com

authored by

Josh Poimboeuf and committed by
Peter Zijlstra
26ff6041 02041b32

+22 -13
+22 -13
tools/objtool/check.c
··· 1271 1271 */ 1272 1272 static int add_jump_destinations(struct objtool_file *file) 1273 1273 { 1274 - struct instruction *insn; 1274 + struct instruction *insn, *jump_dest; 1275 1275 struct reloc *reloc; 1276 1276 struct section *dest_sec; 1277 1277 unsigned long dest_off; ··· 1291 1291 add_retpoline_call(file, insn); 1292 1292 continue; 1293 1293 } else if (insn->func) { 1294 - /* internal or external sibling call (with reloc) */ 1294 + /* 1295 + * External sibling call or internal sibling call with 1296 + * STT_FUNC reloc. 1297 + */ 1295 1298 add_call_dest(file, insn, reloc->sym, true); 1296 1299 continue; 1297 1300 } else if (reloc->sym->sec->idx) { ··· 1306 1303 continue; 1307 1304 } 1308 1305 1309 - insn->jump_dest = find_insn(file, dest_sec, dest_off); 1310 - if (!insn->jump_dest) { 1306 + jump_dest = find_insn(file, dest_sec, dest_off); 1307 + if (!jump_dest) { 1311 1308 1312 1309 /* 1313 1310 * This is a special case where an alt instruction ··· 1326 1323 /* 1327 1324 * Cross-function jump. 1328 1325 */ 1329 - if (insn->func && insn->jump_dest->func && 1330 - insn->func != insn->jump_dest->func) { 1326 + if (insn->func && jump_dest->func && 1327 + insn->func != jump_dest->func) { 1331 1328 1332 1329 /* 1333 1330 * For GCC 8+, create parent/child links for any cold ··· 1345 1342 * subfunction is through a jump table. 1346 1343 */ 1347 1344 if (!strstr(insn->func->name, ".cold") && 1348 - strstr(insn->jump_dest->func->name, ".cold")) { 1349 - insn->func->cfunc = insn->jump_dest->func; 1350 - insn->jump_dest->func->pfunc = insn->func; 1345 + strstr(jump_dest->func->name, ".cold")) { 1346 + insn->func->cfunc = jump_dest->func; 1347 + jump_dest->func->pfunc = insn->func; 1351 1348 1352 - } else if (!same_function(insn, insn->jump_dest) && 1353 - is_first_func_insn(file, insn->jump_dest)) { 1354 - /* internal sibling call (without reloc) */ 1355 - add_call_dest(file, insn, insn->jump_dest->func, true); 1349 + } else if (!same_function(insn, jump_dest) && 1350 + is_first_func_insn(file, jump_dest)) { 1351 + /* 1352 + * Internal sibling call without reloc or with 1353 + * STT_SECTION reloc. 1354 + */ 1355 + add_call_dest(file, insn, jump_dest->func, true); 1356 + continue; 1356 1357 } 1357 1358 } 1359 + 1360 + insn->jump_dest = jump_dest; 1358 1361 } 1359 1362 1360 1363 return 0;