summaryrefslogtreecommitdiff
path: root/tools/objtool/tests/generic/test-special-section-shared.sh
blob: 05c6110b6aef0df08097dde1c433be71b110fc08 (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
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Only the patched function's special section entry may be extracted.

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

setup
build_pair special_section_shared.c

has_input_section orig.o .kcfi_traps ||
	probe_skip "fixture produced no .kcfi_traps on this arch"

run_diff

assert_patched     target
assert_not_patched other
assert_section     ".kcfi_traps"

entries="$(out_relocs | awk '/rela\.kcfi_traps/,/^$/' | grep -c 'target')"
[ "$entries" = 1 ] || fail "expected one .kcfi_traps entry, found $entries"

out_relocs | awk '/rela\.kcfi_traps/,/^$/' | grep -q 'other' &&
	fail "the untouched function's entry was dragged in"

pass "only the patched function's entry extracted"