Rizin
unix-like reverse engineering framework and cli tools
bcj_test.c File Reference

Source code of compress_prepared_bcj_*. More...

Go to the source code of this file.

Functions

int jump (int a, int b)
 
int call (int a, int b)
 
int main (int argc, char **argv)
 

Detailed Description

Source code of compress_prepared_bcj_*.

This is a simple program that should make the compiler to generate PC-relative branches, jumps, and calls. The compiled files can then be used to test the branch conversion filters. Note that this program itself does nothing useful.

Compiling: gcc -std=c99 -fPIC -c bcj_test.c Don't optimize or strip.

Definition in file bcj_test.c.

Function Documentation

◆ call()

int call ( int  a,
int  b 
)

Definition at line 25 of file bcj_test.c.

26 {
27  if (a < b)
28  a = jump(a, b);
29 
30  return a;
31 }
int jump(int a, int b)
Definition: bcj_test.c:35
#define b(i)
Definition: sha256.c:42
#define a(i)
Definition: sha256.c:41

References a, b, and jump().

Referenced by disasm_strings(), ds_init(), esil_call(), main(), retpoline_reg(), rz_analysis_basic_block_list_handler(), and rz_print_analysis_details_handler().

◆ jump()

int jump ( int  a,
int  b 
)

Definition at line 35 of file bcj_test.c.

36 {
37  // The loop generates conditional jump backwards.
38  while (1) {
39  if (a < b) {
40  a *= 2;
41  a += 3 * b;
42  break;
43  } else {
44  // Put enough code here to prevent JMP SHORT on x86.
45  a += b;
46  a /= 2;
47  b += b % 5;
48  a -= b / 3;
49  b = 2 * b + a - 1;
50  a *= b + a + 1;
51  b += a - 1;
52  a += b * 2 - a / 5;
53  }
54  }
55 
56  return a;
57 }

References a, and b.

Referenced by analop_esil(), arcompact_jump(), arcompact_jump_cond(), call(), INST_HANDLER(), java_disassemble(), print_loop(), rz_analysis_basic_block_list_handler(), rz_analysis_case_op_new(), rz_analysis_fcn_add_bb(), rz_analysis_function_blocks_add_handler(), rz_analysis_hint_set_jump(), rz_analysis_hint_set_jump_handler(), rz_analysis_switch_op_add_case(), rz_serialize_analysis_switch_op_load(), and set_bb_branches().

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 61 of file bcj_test.c.

62 {
63  int a = call(argc, argc + 1);
64  return a == 0;
65 }
int call(int a, int b)
Definition: bcj_test.c:25

References a, and call().