projects/linux·blob 5b6dca02 · refs

44 lines · 1.3 KiB

1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3#
4# A cloned __jump_table entry must keep a relocation in its key slot, whether
5# the key needs a klp relocation or not.
6
7. "$(dirname "$0")/../lib.sh"
8
9key=klp_test_key
10
11setup
12build_pair jump_label.c
13
14has_input_section orig.o __jump_table ||
15 probe_skip "fixture produced no __jump_table on this arch"
16
17key_slot_relocs()
18{
19 out_relocs | awk '/rela__jump_table/,/^$/' | grep -c "^0*8[[:space:]]"
20}
21
22# Unexported: klp relocation, key slot holds a tombstone.
23export_syms
24run_diff
25
26[ "$(key_slot_relocs)" = 1 ] ||
27 fail "unexported key: key slot has no relocation"
28out_relocs | awk '/rela__jump_table/,/^$/' | grep -q "\.klp\.tombstone\.$key" ||
29 fail "unexported key: expected a .klp.tombstone.$key relocation"
30out_symbols | grep -q "\.klp\.sym\..*\.$key," ||
31 fail "unexported key: no .klp.sym reference for the real relocation"
32
33# Exported: ordinary relocation, no klp machinery.
34export_syms "$key"
35run_diff
36
37[ "$(key_slot_relocs)" = 1 ] ||
38 fail "exported key: key slot has no relocation"
39out_relocs | awk '/rela__jump_table/,/^$/' | grep -q "[[:space:]]$key[[:space:]]*+" ||
40 fail "exported key: expected a direct relocation to $key"
41out_symbols | grep -q '\.klp\.tombstone\.' &&
42 fail "exported key: tombstone emitted for an exported symbol"
43
44pass "key slot populated for exported and unexported vmlinux keys"