bcj.h 2.8 KB

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