summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/x86/test-alt-annotation.sh
blob: 96760e6df9e5f595e390ce8bb28cb8aa1f86a785 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# A text annotation on an instruction inside an alternative's replacement must
# be carried into the patch.
#
# The kernel annotates replacement code wherever objtool has to be told
# something about it -- a retpoline-safe indirect branch, a deliberately absent
# ENDBR.  Two things made klp diff drop those annotations:
#
#   - replacement code has no real symbol, so objtool invents a NOTYPE fake
#     one, and the extraction only kept references to FUNC symbols;
#   - .discard.annotate_insn was processed before .altinstructions, so the
#     replacement it referenced had no clone to point at yet.
#
# Nothing fails at build time when the annotation goes missing.  It surfaces
# later as objtool warning about, or rejecting, the patched code it was there
# to explain.
#
# Fixed by 62a7a01fde87 ("objtool/klp: Fix extraction of text annotations for
# alternatives").

. "$(dirname "$0")/../lib.sh"

setup
build_pair alt_annotate.c

assert_input_section .altinstructions
assert_input_section .discard.annotate_insn

run_diff

# The annotation has to survive, and to still name the replacement.  Checking
# only the section would pass on an entry whose relocation was dropped.
assert_section .discard.annotate_insn
assert_reloc_sym .discard.annotate_insn target_repl

pass "text annotation on an alternative replacement carried into the patch"