| 1 | |
| 2 | |
| 3 | * Two translation units (TU_B selects the second) linked with ThinLTO.
|
| 4 | * Importing bump() promotes the file-local counter, renaming it
|
| 5 | * counter.llvm.<hash>. The hash is content derived, so it differs between the
|
| 6 | * original and patched builds.
|
| 7 |
|
| 8 |
|
| 9 | #ifdef TU_B
|
| 10 |
|
| 11 | extern int bump(void);
|
| 12 |
|
| 13 | int other_entry(void)
|
| 14 | {
|
| 15 | return bump() + bump();
|
| 16 | }
|
| 17 |
|
| 18 | #else
|
| 19 |
|
| 20 | static const char __modinfo[]
|
| 21 | __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
|
| 22 |
|
| 23 | static int counter;
|
| 24 |
|
| 25 | int bump(void)
|
| 26 | {
|
| 27 | return ++counter;
|
| 28 | }
|
| 29 |
|
| 30 | int target(void)
|
| 31 | {
|
| 32 | #ifdef PATCHED
|
| 33 | return counter + 1;
|
| 34 | #else
|
| 35 | return counter;
|
| 36 | #endif
|
| 37 | }
|
| 38 |
|
| 39 | #endif
|