1*ce30479fSSong Liu#!/bin/bash 2*ce30479fSSong Liu# SPDX-License-Identifier: GPL-2.0 3*ce30479fSSong Liu# 4*ce30479fSSong Liu# klp diff extracts entries from eight special sections. Between them the 5*ce30479fSSong Liu# existing tests reach .kcfi_traps, __jump_table, .static_call_sites and 6*ce30479fSSong Liu# .altinstructions; __bug_table, __ex_table and __mcount_loc are covered by 7*ce30479fSSong Liu# nothing, though the same extraction code serves all of them. 8*ce30479fSSong Liu# 9*ce30479fSSong Liu# Losing an entry is quiet in every case and wrong in a different way for each: 10*ce30479fSSong Liu# a WARN() in patched code that no longer reports where it came from, an 11*ce30479fSSong Liu# exception fixup that is simply not there when the faulting instruction traps, 12*ce30479fSSong Liu# a function ftrace can no longer see. 13*ce30479fSSong Liu 14*ce30479fSSong Liu. "$(dirname "$0")/../lib.sh" 15*ce30479fSSong Liu 16*ce30479fSSong Liu 17*ce30479fSSong Liu# section, entry size, relocations per entry 18*ce30479fSSong Liufor spec in "__bug_table 12 1" "__ex_table 12 2" "__mcount_loc 8 1"; do 19*ce30479fSSong Liu set -- $spec 20*ce30479fSSong Liu sec=$1 21*ce30479fSSong Liu 22*ce30479fSSong Liu # A fresh workdir per section: run_diff caches its checksums. 23*ce30479fSSong Liu setup 24*ce30479fSSong Liu build_pair special_sections.c \ 25*ce30479fSSong Liu -DSPECIAL_SEC="\"$1\"" -DSPECIAL_ENTSIZE="$2" -DSPECIAL_RELOCS="$3" 26*ce30479fSSong Liu 27*ce30479fSSong Liu assert_input_section "$sec" 28*ce30479fSSong Liu run_diff 29*ce30479fSSong Liu 30*ce30479fSSong Liu # Extracted, and pointing at the function that was patched. 31*ce30479fSSong Liu assert_section "$sec" 32*ce30479fSSong Liu assert_reloc_sym "$sec" target 33*ce30479fSSong Liu assert_patched target 34*ce30479fSSong Liu 35*ce30479fSSong Liu # Nothing belonging to the function that was not. 36*ce30479fSSong Liu assert_not_patched other 37*ce30479fSSong Liu assert_no_reloc_sym "$sec" other 38*ce30479fSSong Liu 39*ce30479fSSong Liu cleanup 40*ce30479fSSong Liudone 41*ce30479fSSong Liu 42*ce30479fSSong Liupass "__bug_table, __ex_table and __mcount_loc entries extracted" 43