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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// SPDX-License-Identifier: MPL-2.0
use crateVaddr;
unsafe extern "C"
/// A structure representing the usage of exception table (ExTable).
/// This table is used for recovering from specific exception handling faults
/// occurring at known points in the code.
///
/// To add a recovery instruction for a target assembly instruction, one should add
/// the following statements:
///
/// ```
/// .pushsection .ex_table, "a"
/// .align 8
/// .quad [.target_label],
/// .quad [.recovery_label],
/// .popsection
/// ```
///
/// where the `target_label` and `recovery_label` are the labels of the target instruction
/// and the label of recovery instruction respectively.
///
/// For example, we have the following assembly code snippets in an input file:
/// ```
/// .label1:
/// rep movsb
/// mov rax, rcx
/// .label2:
/// ret
/// ```
///
/// We can add the following statements in the same file (`label1` and `label2` are local
/// labels):
///
/// ```
/// .pushsection .ex_table, "a"
/// .align 8
/// .quad [.label1],
/// .quad [.label2],
/// .popsection
/// ```
///
/// After that, we can use the API of `ExTable` to resume execution when handling
/// exceptions caused by `rep movsb` (which `label1` point to) failing.
pub ;