diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2024-05-14 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2024-05-15 23:55:04 +0500 |
commit | fc662341e6f85da78ada0e443f6116b978f79f22 (patch) | |
tree | 1be1cc402a7a9cbc18d4eeea6b141354c2d559e3 /C/Bra.h | |
parent | 5b39dc76f1bc82f941d5c800ab9f34407a06b53a (diff) | |
download | 7zip-fc662341e6f85da78ada0e443f6116b978f79f22.tar.gz 7zip-fc662341e6f85da78ada0e443f6116b978f79f22.tar.bz2 7zip-fc662341e6f85da78ada0e443f6116b978f79f22.zip |
24.0524.05
Diffstat (limited to 'C/Bra.h')
-rw-r--r-- | C/Bra.h | 36 |
1 files changed, 21 insertions, 15 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* Bra.h -- Branch converters for executables | 1 | /* Bra.h -- Branch converters for executables |
2 | 2023-04-02 : Igor Pavlov : Public domain */ | 2 | 2024-01-20 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #ifndef ZIP7_INC_BRA_H | 4 | #ifndef ZIP7_INC_BRA_H |
5 | #define ZIP7_INC_BRA_H | 5 | #define ZIP7_INC_BRA_H |
@@ -8,8 +8,12 @@ | |||
8 | 8 | ||
9 | EXTERN_C_BEGIN | 9 | EXTERN_C_BEGIN |
10 | 10 | ||
11 | #define Z7_BRANCH_CONV_DEC(name) z7_BranchConv_ ## name ## _Dec | 11 | /* #define PPC BAD_PPC_11 // for debug */ |
12 | #define Z7_BRANCH_CONV_ENC(name) z7_BranchConv_ ## name ## _Enc | 12 | |
13 | #define Z7_BRANCH_CONV_DEC_2(name) z7_ ## name ## _Dec | ||
14 | #define Z7_BRANCH_CONV_ENC_2(name) z7_ ## name ## _Enc | ||
15 | #define Z7_BRANCH_CONV_DEC(name) Z7_BRANCH_CONV_DEC_2(BranchConv_ ## name) | ||
16 | #define Z7_BRANCH_CONV_ENC(name) Z7_BRANCH_CONV_ENC_2(BranchConv_ ## name) | ||
13 | #define Z7_BRANCH_CONV_ST_DEC(name) z7_BranchConvSt_ ## name ## _Dec | 17 | #define Z7_BRANCH_CONV_ST_DEC(name) z7_BranchConvSt_ ## name ## _Dec |
14 | #define Z7_BRANCH_CONV_ST_ENC(name) z7_BranchConvSt_ ## name ## _Enc | 18 | #define Z7_BRANCH_CONV_ST_ENC(name) z7_BranchConvSt_ ## name ## _Enc |
15 | 19 | ||
@@ -20,19 +24,20 @@ typedef Z7_BRANCH_CONV_DECL( (*z7_Func_BranchConv)); | |||
20 | typedef Z7_BRANCH_CONV_ST_DECL((*z7_Func_BranchConvSt)); | 24 | typedef Z7_BRANCH_CONV_ST_DECL((*z7_Func_BranchConvSt)); |
21 | 25 | ||
22 | #define Z7_BRANCH_CONV_ST_X86_STATE_INIT_VAL 0 | 26 | #define Z7_BRANCH_CONV_ST_X86_STATE_INIT_VAL 0 |
23 | Z7_BRANCH_CONV_ST_DECL(Z7_BRANCH_CONV_ST_DEC(X86)); | 27 | Z7_BRANCH_CONV_ST_DECL (Z7_BRANCH_CONV_ST_DEC(X86)); |
24 | Z7_BRANCH_CONV_ST_DECL(Z7_BRANCH_CONV_ST_ENC(X86)); | 28 | Z7_BRANCH_CONV_ST_DECL (Z7_BRANCH_CONV_ST_ENC(X86)); |
25 | 29 | ||
26 | #define Z7_BRANCH_FUNCS_DECL(name) \ | 30 | #define Z7_BRANCH_FUNCS_DECL(name) \ |
27 | Z7_BRANCH_CONV_DECL(Z7_BRANCH_CONV_DEC(name)); \ | 31 | Z7_BRANCH_CONV_DECL (Z7_BRANCH_CONV_DEC_2(name)); \ |
28 | Z7_BRANCH_CONV_DECL(Z7_BRANCH_CONV_ENC(name)); | 32 | Z7_BRANCH_CONV_DECL (Z7_BRANCH_CONV_ENC_2(name)); |
29 | 33 | ||
30 | Z7_BRANCH_FUNCS_DECL(ARM64) | 34 | Z7_BRANCH_FUNCS_DECL (BranchConv_ARM64) |
31 | Z7_BRANCH_FUNCS_DECL(ARM) | 35 | Z7_BRANCH_FUNCS_DECL (BranchConv_ARM) |
32 | Z7_BRANCH_FUNCS_DECL(ARMT) | 36 | Z7_BRANCH_FUNCS_DECL (BranchConv_ARMT) |
33 | Z7_BRANCH_FUNCS_DECL(PPC) | 37 | Z7_BRANCH_FUNCS_DECL (BranchConv_PPC) |
34 | Z7_BRANCH_FUNCS_DECL(SPARC) | 38 | Z7_BRANCH_FUNCS_DECL (BranchConv_SPARC) |
35 | Z7_BRANCH_FUNCS_DECL(IA64) | 39 | Z7_BRANCH_FUNCS_DECL (BranchConv_IA64) |
40 | Z7_BRANCH_FUNCS_DECL (BranchConv_RISCV) | ||
36 | 41 | ||
37 | /* | 42 | /* |
38 | These functions convert data that contain CPU instructions. | 43 | These functions convert data that contain CPU instructions. |
@@ -49,14 +54,14 @@ and one for decoding (_Enc/_Dec postfixes in function name). | |||
49 | In params: | 54 | In params: |
50 | data : data buffer | 55 | data : data buffer |
51 | size : size of data | 56 | size : size of data |
52 | pc : current virtual Program Counter (Instruction Pinter) value | 57 | pc : current virtual Program Counter (Instruction Pointer) value |
53 | In/Out param: | 58 | In/Out param: |
54 | state : pointer to state variable (for X86 converter only) | 59 | state : pointer to state variable (for X86 converter only) |
55 | 60 | ||
56 | Return: | 61 | Return: |
57 | The pointer to position in (data) buffer after last byte that was processed. | 62 | The pointer to position in (data) buffer after last byte that was processed. |
58 | If the caller calls converter again, it must call it starting with that position. | 63 | If the caller calls converter again, it must call it starting with that position. |
59 | But the caller is allowed to move data in buffer. so pointer to | 64 | But the caller is allowed to move data in buffer. So pointer to |
60 | current processed position also will be changed for next call. | 65 | current processed position also will be changed for next call. |
61 | Also the caller must increase internal (pc) value for next call. | 66 | Also the caller must increase internal (pc) value for next call. |
62 | 67 | ||
@@ -65,6 +70,7 @@ Each converter has some characteristics: Endian, Alignment, LookAhead. | |||
65 | 70 | ||
66 | X86 little 1 4 | 71 | X86 little 1 4 |
67 | ARMT little 2 2 | 72 | ARMT little 2 2 |
73 | RISCV little 2 6 | ||
68 | ARM little 4 0 | 74 | ARM little 4 0 |
69 | ARM64 little 4 0 | 75 | ARM64 little 4 0 |
70 | PPC big 4 0 | 76 | PPC big 4 0 |