1*1a50e18bSSong Liu // SPDX-License-Identifier: GPL-2.0 2*1a50e18bSSong Liu /* 3*1a50e18bSSong Liu * Two translation units with a same-named static, placed so that the linker 4*1a50e18bSSong Liu * puts them in the opposite order to the one they appear in the symbol table. 5*1a50e18bSSong Liu * 6*1a50e18bSSong Liu * VARSEC selects the section the static lands in. Linking with 7*1a50e18bSSong Liu * --sort-section=name then orders them alphabetically rather than by object 8*1a50e18bSSong Liu * order, so the first symbol in the symbol table ends up at the *higher* 9*1a50e18bSSong Liu * address. That is the whole point: counting symbol table order and reading 10*1a50e18bSSong Liu * the linked image's addresses now give different answers, which is what makes 11*1a50e18bSSong Liu * it possible to tell which one klp diff used. 12*1a50e18bSSong Liu * 13*1a50e18bSSong Liu * Only use_a is patched, so exactly one sympos is emitted and there is nothing 14*1a50e18bSSong Liu * to attribute. 15*1a50e18bSSong Liu */ 16*1a50e18bSSong Liu 17*1a50e18bSSong Liu #ifndef FUNC_NAME 18*1a50e18bSSong Liu #define FUNC_NAME use_a 19*1a50e18bSSong Liu #endif 20*1a50e18bSSong Liu #ifndef VARSEC 21*1a50e18bSSong Liu #define VARSEC ".data.mmm" 22*1a50e18bSSong Liu #endif 23*1a50e18bSSong Liu 24*1a50e18bSSong Liu #ifndef NO_MODINFO 25*1a50e18bSSong Liu static const char __modinfo[] 26*1a50e18bSSong Liu __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux"; 27*1a50e18bSSong Liu #endif 28*1a50e18bSSong Liu 29*1a50e18bSSong Liu /* volatile so it survives as an STT_OBJECT rather than being folded away */ 30*1a50e18bSSong Liu static volatile int dup_counter __attribute__((section(VARSEC))) = 1; 31*1a50e18bSSong Liu FUNC_NAME(int x)32*1a50e18bSSong Liuint FUNC_NAME(int x) 33*1a50e18bSSong Liu { 34*1a50e18bSSong Liu dup_counter += x; 35*1a50e18bSSong Liu #ifdef PATCHED 36*1a50e18bSSong Liu return dup_counter + 1; 37*1a50e18bSSong Liu #else 38*1a50e18bSSong Liu return dup_counter; 39*1a50e18bSSong Liu #endif 40*1a50e18bSSong Liu } 41