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