xref: /linux/tools/objtool/tests/generic/test-static-call-module-key.sh (revision 5b6dca02b3e2254d2fd5706d76d7ab4610a67296)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# As for static branches, a static call key owned by a module must be rejected
5# while a vmlinux-owned one is accepted.
6
7. "$(dirname "$0")/../lib.sh"
8
9setup
10build_pair static_call.c
11
12has_input_section orig.o .static_call_sites ||
13	probe_skip "fixture produced no .static_call_sites on this arch"
14
15run_diff
16assert_patched target
17
18# The accepted half has to show the entry was carried, not just that the
19# function was: dropping the section silently would leave the patched call
20# unregistered, and "target was cloned" cannot tell the two apart.
21assert_section .static_call_sites
22assert_reloc_sym .static_call_sites target
23
24rm -f "$workdir/out.o"
25build_pair static_call.c -DMODNAME='"klp_testmod"'
26run_diff 255
27
28diff_log | grep -q 'unsupported static call key __SCK__klp_test_call' ||
29	fail "expected rejection, got: $(diff_log | tail -1)"
30
31# A rejection has to leave nothing behind.  out.o was removed above, so
32# anything here was written by the run which was supposed to refuse.
33[ -e "$workdir/out.o" ] &&
34	fail "output object produced for a rejected input"
35
36pass "module-owned static call key rejected, vmlinux-owned accepted"
37