1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * A switch dense enough that Clang builds a jump table for it, in a section of
4 * its own: .rodata..Lswitch.table.<function>.
5 *
6 * The table belongs to the function and has to travel with it. It is named
7 * after the function but is not part of it, so klp diff has to associate the
8 * two rather than treating the table as unrelated data.
9 *
10 * The patch adds a case, which changes the table's contents and length.
11 */
12
13 static const char __modinfo[]
14 __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
status_to_string(unsigned int c)15 const char *status_to_string(unsigned int c)
16 {
17 switch (c) {
18 case 0: return "idle";
19 case 1: return "running";
20 case 2: return "stopped";
21 case 3: return "error";
22 case 4: return "paused";
23 case 5: return "waiting";
24 case 6: return "starting";
25 case 7: return "stopping";
26 #ifdef PATCHED
27 case 8: return "completed";
28 #endif
29 }
30 return "unknown";
31 }
32