Skip to content

Commit f7b097e

Browse files
Thadeu Lima de Souza Cascardogregkh
authored andcommitted
objtool: skip non-text sections when adding return-thunk sites
The .discard.text section is added in order to reserve BRK, with a temporary function just so it can give it a size. This adds a relocation to the return thunk, which objtool will add to the .return_sites section. Linking will then fail as there are references to the .discard.text section. Do not add instructions from non-text sections to the list of return thunk calls, avoiding the reference to .discard.text. Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> Acked-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 262941a commit f7b097e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/objtool/check.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,9 @@ static void add_return_call(struct objtool_file *file, struct instruction *insn)
13081308
insn->type = INSN_RETURN;
13091309
insn->retpoline_safe = true;
13101310

1311-
list_add_tail(&insn->call_node, &file->return_thunk_list);
1311+
/* Skip the non-text sections, specially .discard ones */
1312+
if (insn->sec->text)
1313+
list_add_tail(&insn->call_node, &file->return_thunk_list);
13121314
}
13131315

13141316
static bool same_function(struct instruction *insn1, struct instruction *insn2)

0 commit comments

Comments
 (0)