| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 |
|
| 17 | . "$(dirname "$0")/../lib.sh"
|
| 18 |
|
| 19 | setup
|
| 20 |
|
| 21 | |
| 22 | |
| 23 | build_pair checksum_position.c -fno-function-sections
|
| 24 |
|
| 25 | assert_input_symbol target
|
| 26 |
|
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | sym_off() |
| 33 | {
|
| 34 | in_symbols "$1" | awk -v n="$2" '$NF == n { print $2; exit }'
|
| 35 | }
|
| 36 |
|
| 37 | orig_t="$(sym_off orig.o target)"; orig_c="$(sym_off orig.o callee)"
|
| 38 | new_t="$(sym_off patched.o target)"; new_c="$(sym_off patched.o callee)"
|
| 39 |
|
| 40 | [ -n "$orig_t" ] && [ -n "$orig_c" ] && [ -n "$new_t" ] && [ -n "$new_c" ] ||
|
| 41 | fail "target or callee missing from one of the objects"
|
| 42 |
|
| 43 | orig_gap=$(( 16#$orig_t - 16#$orig_c ))
|
| 44 | new_gap=$(( 16#$new_t - 16#$new_c ))
|
| 45 | [ "$orig_gap" != "$new_gap" ] ||
|
| 46 | probe_skip "this compiler kept target() and callee() the same distance" \
|
| 47 | "apart; the call displacement did not change"
|
| 48 |
|
| 49 | assert_checksum_matches target
|
| 50 |
|
| 51 | pass "checksum unchanged when the function only moves"
|