xref: /linux/tools/objtool/tests/generic/test-static-call-annotate-stripped.sh (revision 5b6dca02b3e2254d2fd5706d76d7ab4610a67296)
1*794b162bSSong Liu#!/bin/bash
2*794b162bSSong Liu# SPDX-License-Identifier: GPL-2.0
3*794b162bSSong Liu#
4*794b162bSSong Liu# A patch may remove the last ANNOTATE_DATA_SPECIAL in a translation unit while
5*794b162bSSong Liu# leaving the special section it described in place.
6*794b162bSSong Liu#
7*794b162bSSong Liu# klp diff needs entry boundaries for a special section: either an entsize, or
8*794b162bSSong Liu# annotations naming where each entry starts.  .static_call_sites has no
9*794b162bSSong Liu# entsize, so the annotations are all there is -- and when the patched object
10*794b162bSSong Liu# is the only side that lost them, the two sides no longer agree on how the
11*794b162bSSong Liu# section divides up.
12*794b162bSSong Liu#
13*794b162bSSong Liu# The section must still be handled.  Dropping it would leave the patched
14*794b162bSSong Liu# function's static call unregistered; misreading its boundaries would attach
15*794b162bSSong Liu# the entry to the wrong code.  Either way nothing is reported at build time.
16*794b162bSSong Liu#
17*794b162bSSong Liu# Fixed by commit 3de711fba73a ("objtool/klp: Fix create_fake_symbols()
18*794b162bSSong Liu# skipping entsize-based sections").
19*794b162bSSong Liu#
20*794b162bSSong Liu# Covers the same ground as corpus/x86_64/static-call-annotate-stripped in Joe
21*794b162bSSong Liu# Lawrence's klp-build unit test corpus.
22*794b162bSSong Liu
23*794b162bSSong Liu. "$(dirname "$0")/../lib.sh"
24*794b162bSSong Liu
25*794b162bSSong Liusetup
26*794b162bSSong Liubuild_pair static_call.c -DNO_ANNOTATE
27*794b162bSSong Liu
28*794b162bSSong Liu# The premise: the original describes its entry, the patched one no longer
29*794b162bSSong Liu# does, and both still have the section itself.
30*794b162bSSong Liuhas_input_section orig.o .discard.annotate_data ||
31*794b162bSSong Liu	fail "fixture produced no annotation in the original"
32*794b162bSSong Liuhas_input_section patched.o .discard.annotate_data &&
33*794b162bSSong Liu	fail "patched object still has the annotation; nothing was stripped"
34*794b162bSSong Liuassert_input_section .static_call_sites
35*794b162bSSong Liu
36*794b162bSSong Liurun_diff
37*794b162bSSong Liu
38*794b162bSSong Liuassert_patched target
39*794b162bSSong Liuassert_section .static_call_sites
40*794b162bSSong Liuassert_reloc_sym .static_call_sites target
41*794b162bSSong Liu
42*794b162bSSong Liupass "static call site kept when the patch strips its data annotation"
43