VirtualBox

source: vbox/trunk/src/libs/liblzma-5.8.1/simple/arm.c@ 108911

Last change on this file since 108911 was 108911, checked in by vboxsync, 4 weeks ago

libs/liblzma: Applied and adjusted our liblzma changes to 5.8.1 and export to OSE. jiraref:VBP-1635

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
  • Property sync-process set to export
File size: 1.7 KB
Line 
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
16static size_t
17arm_code(void *simple lzma_attribute((__unused__)),
18 uint32_t now_pos, bool is_encoder,
19 uint8_t *buffer, size_t size)
20{
21 size &= ~(size_t)3;
22
23 size_t i;
24 for (i = 0; i < size; i += 4) {
25 if (buffer[i + 3] == 0xEB) {
26 uint32_t src = ((uint32_t)(buffer[i + 2]) << 16)
27 | ((uint32_t)(buffer[i + 1]) << 8)
28 | (uint32_t)(buffer[i + 0]);
29 src <<= 2;
30
31 uint32_t dest;
32 if (is_encoder)
33 dest = now_pos + (uint32_t)(i) + 8 + src;
34 else
35 dest = src - (now_pos + (uint32_t)(i) + 8);
36
37 dest >>= 2;
38 buffer[i + 2] = (dest >> 16);
39 buffer[i + 1] = (dest >> 8);
40 buffer[i + 0] = dest;
41 }
42 }
43
44 return i;
45}
46
47
48static lzma_ret
49arm_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,
50 const lzma_filter_info *filters, bool is_encoder)
51{
52 return lzma_simple_coder_init(next, allocator, filters,
53 &arm_code, 0, 4, 4, is_encoder);
54}
55
56
57#ifdef HAVE_ENCODER_ARM
58extern lzma_ret
59lzma_simple_arm_encoder_init(lzma_next_coder *next,
60 const lzma_allocator *allocator,
61 const lzma_filter_info *filters)
62{
63 return arm_coder_init(next, allocator, filters, true);
64}
65#endif
66
67
68#ifdef HAVE_DECODER_ARM
69extern lzma_ret
70lzma_simple_arm_decoder_init(lzma_next_coder *next,
71 const lzma_allocator *allocator,
72 const lzma_filter_info *filters)
73{
74 return arm_coder_init(next, allocator, filters, false);
75}
76#endif
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette