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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
/* SPDX-License-Identifier: 0BSD */
/**
* \file lzma/bcj.h
* \brief Branch/Call/Jump conversion filters
* \note Never include this file directly. Use <lzma.h> instead.
*/
/*
* Author: Lasse Collin
*/
/* Filter IDs for lzma_filter.id */
/**
* \brief Filter for x86 binaries
*/
/**
* \brief Filter for Big endian PowerPC binaries
*/
/**
* \brief Filter for IA-64 (Itanium) binaries
*/
/**
* \brief Filter for ARM binaries
*/
/**
* \brief Filter for ARM-Thumb binaries
*/
/**
* \brief Filter for SPARC binaries
*/
/**
* \brief Filter for ARM64 binaries
*/
/**
* \brief Filter for RISC-V binaries
*/
/**
* \brief Options for BCJ filters
*
* The BCJ filters never change the size of the data. Specifying options
* for them is optional: if pointer to options is NULL, default value is
* used. You probably never need to specify options to BCJ filters, so just
* set the options pointer to NULL and be happy.
*
* If options with non-default values have been specified when encoding,
* the same options must also be specified when decoding.
*
* \note At the moment, none of the BCJ filters support
* LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
* LZMA_OPTIONS_ERROR will be returned. If there is need,
* partial support for LZMA_SYNC_FLUSH can be added in future.
* Partial means that flushing would be possible only at
* offsets that are multiple of 2, 4, or 16 depending on
* the filter, except x86 which cannot be made to support
* LZMA_SYNC_FLUSH predictably.
*/
typedef struct lzma_options_bcj;
/**
* \brief Raw ARM64 BCJ encoder
*
* This is for special use cases only.
*
* \param start_offset The lowest 32 bits of the offset in the
* executable being filtered. For the ARM64
* filter, this must be a multiple of four.
* For the very best results, this should also
* be in sync with 4096-byte page boundaries
* in the executable due to how ARM64's ADRP
* instruction works.
* \param buf Buffer to be filtered in place
* \param size Size of the buffer
*
* \return Number of bytes that were processed in `buf`. This is at most
* `size`. With the ARM64 filter, the return value is always
* a multiple of 4, and at most 3 bytes are left unfiltered.
*
* \since 5.7.1alpha
*/
extern lzma_nothrow;
/**
* \brief Raw ARM64 BCJ decoder
*
* See lzma_bcj_arm64_encode().
*
* \since 5.7.1alpha
*/
extern lzma_nothrow;
/**
* \brief Raw RISC-V BCJ encoder
*
* This is for special use cases only.
*
* \param start_offset The lowest 32 bits of the offset in the
* executable being filtered. For the RISC-V
* filter, this must be a multiple of 2.
* \param buf Buffer to be filtered in place
* \param size Size of the buffer
*
* \return Number of bytes that were processed in `buf`. This is at most
* `size`. With the RISC-V filter, the return value is always
* a multiple of 2, and at most 7 bytes are left unfiltered.
*
* \since 5.7.1alpha
*/
extern lzma_nothrow;
/**
* \brief Raw RISC-V BCJ decoder
*
* See lzma_bcj_riscv_encode().
*
* \since 5.7.1alpha
*/
extern lzma_nothrow;
/**
* \brief Raw x86 BCJ encoder
*
* This is for special use cases only.
*
* \param start_offset The lowest 32 bits of the offset in the
* executable being filtered. For the x86
* filter, all values are valid.
* \param buf Buffer to be filtered in place
* \param size Size of the buffer
*
* \return Number of bytes that were processed in `buf`. This is at most
* `size`. For the x86 filter, the return value is always
* a multiple of 1, and at most 4 bytes are left unfiltered.
*
* \since 5.7.1alpha
*/
extern lzma_nothrow;
/**
* \brief Raw x86 BCJ decoder
*
* See lzma_bcj_x86_encode().
*
* \since 5.7.1alpha
*/
extern lzma_nothrow;