xref: /freebsd/contrib/xz/src/liblzma/api/lzma/bcj.h (revision fee65b7e21eeeb625dcaba8cf2b9e0cf5af83498)
1 /**
2  * \file        lzma/bcj.h
3  * \brief       Branch/Call/Jump conversion filters
4  * \note        Never include this file directly. Use <lzma.h> instead.
5  */
6 
7 /*
8  * Author: Lasse Collin
9  *
10  * This file has been put into the public domain.
11  * You can do whatever you want with this file.
12  */
13 
14 #ifndef LZMA_H_INTERNAL
15 #	error Never include this file directly. Use <lzma.h> instead.
16 #endif
17 
18 
19 /* Filter IDs for lzma_filter.id */
20 
21 /**
22  * \brief       Filter for x86 binaries
23  */
24 #define LZMA_FILTER_X86         LZMA_VLI_C(0x04)
25 
26 /**
27  * \brief       Filter for Big endian PowerPC binaries
28  */
29 #define LZMA_FILTER_POWERPC     LZMA_VLI_C(0x05)
30 
31 /**
32  * \brief       Filter for IA-64 (Itanium) binaries
33  */
34 #define LZMA_FILTER_IA64        LZMA_VLI_C(0x06)
35 
36 /**
37  * \brief       Filter for ARM binaries
38  */
39 #define LZMA_FILTER_ARM         LZMA_VLI_C(0x07)
40 
41 /**
42  * \brief       Filter for ARM-Thumb binaries
43  */
44 #define LZMA_FILTER_ARMTHUMB    LZMA_VLI_C(0x08)
45 
46 /**
47  * \brief       Filter for SPARC binaries
48  */
49 #define LZMA_FILTER_SPARC       LZMA_VLI_C(0x09)
50 
51 /**
52  * \brief       Filter for ARM64 binaries
53  */
54 #define LZMA_FILTER_ARM64       LZMA_VLI_C(0x0A)
55 
56 
57 /**
58  * \brief       Options for BCJ filters
59  *
60  * The BCJ filters never change the size of the data. Specifying options
61  * for them is optional: if pointer to options is NULL, default value is
62  * used. You probably never need to specify options to BCJ filters, so just
63  * set the options pointer to NULL and be happy.
64  *
65  * If options with non-default values have been specified when encoding,
66  * the same options must also be specified when decoding.
67  *
68  * \note        At the moment, none of the BCJ filters support
69  *              LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
70  *              LZMA_OPTIONS_ERROR will be returned. If there is need,
71  *              partial support for LZMA_SYNC_FLUSH can be added in future.
72  *              Partial means that flushing would be possible only at
73  *              offsets that are multiple of 2, 4, or 16 depending on
74  *              the filter, except x86 which cannot be made to support
75  *              LZMA_SYNC_FLUSH predictably.
76  */
77 typedef struct {
78 	/**
79 	 * \brief       Start offset for conversions
80 	 *
81 	 * This setting is useful only when the same filter is used
82 	 * _separately_ for multiple sections of the same executable file,
83 	 * and the sections contain cross-section branch/call/jump
84 	 * instructions. In that case it is beneficial to set the start
85 	 * offset of the non-first sections so that the relative addresses
86 	 * of the cross-section branch/call/jump instructions will use the
87 	 * same absolute addresses as in the first section.
88 	 *
89 	 * When the pointer to options is NULL, the default value (zero)
90 	 * is used.
91 	 */
92 	uint32_t start_offset;
93 
94 } lzma_options_bcj;
95