| 1 | |
| 2 | |
| 3 | * Symbols calculate_checksums() must not give an entry of their own.
|
| 4 | *
|
| 5 | * Three kinds are skipped, for two different reasons:
|
| 6 | *
|
| 7 | * zero-length there is nothing to hash, and an entry keyed on the
|
| 8 | * symbol's address would collide with whatever really lives
|
| 9 | * there.
|
| 10 | * alias a second name for an address already checksummed.
|
| 11 | * cold part hashed as part of its parent, which func_for_each_insn()
|
| 12 | * walks into, so a separate entry would double-count it.
|
| 13 | *
|
| 14 | * An entry per address is the invariant: .discard.sym_checksum is looked up by
|
| 15 | * the address a relocation points at, so two entries for one address make the
|
| 16 | * lookup ambiguous and one of the two checksums unreachable.
|
| 17 |
|
| 18 |
|
| 19 | static const char __modinfo[]
|
| 20 | __attribute__((section(".modinfo"), used, aligned(1))) = "\0name=vmlinux";
|
| 21 |
|
| 22 |
|
| 23 | extern char empty_marker[];
|
| 24 | __asm__(".pushsection .data.empty_marker,\"aw\",@progbits\n"
|
| 25 | ".globl empty_marker\n"
|
| 26 | ".type empty_marker, @object\n"
|
| 27 | "empty_marker:\n"
|
| 28 | ".size empty_marker, 0\n"
|
| 29 | ".popsection\n");
|
| 30 |
|
| 31 | int real_function(int x);
|
| 32 | int real_function(int x)
|
| 33 | {
|
| 34 | #ifdef PATCHED
|
| 35 | return x + 2;
|
| 36 | #else
|
| 37 | return x + 1;
|
| 38 | #endif
|
| 39 | }
|
| 40 |
|
| 41 |
|
| 42 | int alias_function(int x) __attribute__((alias("real_function")));
|
| 43 |
|
| 44 | int target(int x)
|
| 45 | {
|
| 46 | return real_function(x) + alias_function(x) + (int)(long)empty_marker;
|
| 47 | }
|