Coverage Report

Created: 2026-02-09 06:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/CMake/Utilities/cmliblzma/liblzma/simple/arm.c
Line
Count
Source
1
// SPDX-License-Identifier: 0BSD
2
3
///////////////////////////////////////////////////////////////////////////////
4
//
5
/// \file       arm.c
6
/// \brief      Filter for ARM binaries
7
///
8
//  Authors:    Igor Pavlov
9
//              Lasse Collin
10
//
11
///////////////////////////////////////////////////////////////////////////////
12
13
#include "simple_private.h"
14
15
16
static size_t
17
arm_code(void *simple lzma_attribute((__unused__)),
18
    uint32_t now_pos, bool is_encoder,
19
    uint8_t *buffer, size_t size)
20
0
{
21
0
  size_t i;
22
0
  for (i = 0; i + 4 <= size; i += 4) {
23
0
    if (buffer[i + 3] == 0xEB) {
24
0
      uint32_t src = ((uint32_t)(buffer[i + 2]) << 16)
25
0
          | ((uint32_t)(buffer[i + 1]) << 8)
26
0
          | (uint32_t)(buffer[i + 0]);
27
0
      src <<= 2;
28
29
0
      uint32_t dest;
30
0
      if (is_encoder)
31
0
        dest = now_pos + (uint32_t)(i) + 8 + src;
32
0
      else
33
0
        dest = src - (now_pos + (uint32_t)(i) + 8);
34
35
0
      dest >>= 2;
36
0
      buffer[i + 2] = (dest >> 16);
37
0
      buffer[i + 1] = (dest >> 8);
38
0
      buffer[i + 0] = dest;
39
0
    }
40
0
  }
41
42
0
  return i;
43
0
}
44
45
46
static lzma_ret
47
arm_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
48
    const lzma_filter_info *filters, bool is_encoder)
49
0
{
50
0
  return lzma_simple_coder_init(next, allocator, filters,
51
0
      &arm_code, 0, 4, 4, is_encoder);
52
0
}
53
54
55
#ifdef HAVE_ENCODER_ARM
56
extern lzma_ret
57
lzma_simple_arm_encoder_init(lzma_next_coder *next,
58
    const lzma_allocator *allocator,
59
    const lzma_filter_info *filters)
60
0
{
61
0
  return arm_coder_init(next, allocator, filters, true);
62
0
}
63
#endif
64
65
66
#ifdef HAVE_DECODER_ARM
67
extern lzma_ret
68
lzma_simple_arm_decoder_init(lzma_next_coder *next,
69
    const lzma_allocator *allocator,
70
    const lzma_filter_info *filters)
71
0
{
72
  return arm_coder_init(next, allocator, filters, false);
73
0
}
74
#endif