| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 |
|
| 25 | . "$(dirname "$0")/../lib.sh"
|
| 26 |
|
| 27 | clang_only "only Clang emits switch jump tables in their own section"
|
| 28 |
|
| 29 | setup
|
| 30 | build_pair switch_rodata.c
|
| 31 |
|
| 32 | |
| 33 | |
| 34 | tbl=.rodata..Lswitch.table.status_to_string
|
| 35 | has_input_section orig.o "$tbl" ||
|
| 36 | probe_skip "this clang built no jump table for the switch"
|
| 37 | |
| 38 | |
| 39 | tbl_size()
|
| 40 | {
|
| 41 | in_sections "$1" | sed 's/^ *\[[ 0-9]*\] *//' |
|
| 42 | awk -v s="$tbl" '$1 == s { print $5 }'
|
| 43 | }
|
| 44 | [ "$(tbl_size orig.o)" != "$(tbl_size patched.o)" ] ||
|
| 45 | fail "fixture's added case did not change the jump table"
|
| 46 |
|
| 47 | run_diff
|
| 48 |
|
| 49 | assert_patched status_to_string
|
| 50 | assert_section "$tbl"
|
| 51 | assert_reloc_sym .text.status_to_string "$tbl"
|
| 52 |
|
| 53 | pass "Clang switch jump table carried with the function it belongs to"
|