1*ade23d75SSong Liu#!/bin/bash 2*ade23d75SSong Liu# SPDX-License-Identifier: GPL-2.0 3*ade23d75SSong Liu# 4*ade23d75SSong Liu# find_export() matched on symbol name alone, so a static function or variable 5*ade23d75SSong Liu# sharing a name with an export was mistaken for a reference to that export. 6*ade23d75SSong Liu# For a vmlinux export that means no klp relocation at all: the normal 7*ade23d75SSong Liu# relocation left behind is resolved by the module loader to the vmlinux 8*ade23d75SSong Liu# symbol, and the patched code quietly reads and writes the wrong object. 9*ade23d75SSong Liu# 10*ade23d75SSong Liu# Exports are always global, so a local symbol is never one. 11*ade23d75SSong Liu 12*ade23d75SSong Liu. "$(dirname "$0")/../lib.sh" 13*ade23d75SSong Liu 14*ade23d75SSong Liusetup 15*ade23d75SSong Liubuild_pair static_local.c 16*ade23d75SSong Liu 17*ade23d75SSong Liu# The static the fixture uses. Compilers mangle statics variously -- gcc says 18*ade23d75SSong Liu# counter.0, clang says target.counter -- so find what this one produced rather 19*ade23d75SSong Liu# than assuming a shape. 20*ade23d75SSong Liulocal_sym="$(in_symbols orig.o | 21*ade23d75SSong Liu awk '$4 == "OBJECT" && $5 == "LOCAL" && $8 ~ /counter/ { print $8; exit }')" 22*ade23d75SSong Liu[ -n "$local_sym" ] || 23*ade23d75SSong Liu fail "fixture produced no local 'counter' symbol" 24*ade23d75SSong Liu 25*ade23d75SSong Liu# Contrive the collision: something else exports that same name. 26*ade23d75SSong Liuexport_syms "$local_sym" counter 27*ade23d75SSong Liurun_diff 28*ade23d75SSong Liu 29*ade23d75SSong Liu# Still treated as the local it is, not as the export. 30*ade23d75SSong Liuassert_klp_sym "$local_sym" vmlinux 31*ade23d75SSong Liu 32*ade23d75SSong Liupass "local symbol not mistaken for an export of the same name" 33