1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * A reference which only exists in the patched build. The symbol has no twin 4 * in the original object, so what klp diff may do with it depends entirely on 5 * whether Module.symvers says it is exported, and by what. 6 */ 7 8 static const char __modinfo[] 9 __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux"; 10 11 extern int newly_referenced(int x); 12 13 /* 14 * A reference both builds have. When Module.symvers says a module exports 15 * this one, the original already depends on that module, which is what makes 16 * a new reference to it safe -- the loader will not let the patched module 17 * load without it. EXISTING_DEP leaves it out, for the case where there is 18 * no such dependency to inherit. 19 */ 20 extern int existing_dep(int x); 21 target(int x)22int target(int x) 23 { 24 #ifdef EXISTING_DEP 25 int base = existing_dep(x); 26 #else 27 int base = x; 28 #endif 29 30 #ifdef PATCHED 31 return newly_referenced(base); 32 #else 33 return base + 1; 34 #endif 35 } 36