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