Rizin
unix-like reverse engineering framework and cli tools
elf_arm.c File Reference
#include "elf.h"

Go to the source code of this file.

Functions

static bool start_a_sequence_of_instruction (RzBinSymbol *symbol)
 
static bool start_a_sequence_of_thumb_instruction (RzBinSymbol *symbol)
 
static bool start_a_sequence_of_data (RzBinSymbol *symbol)
 
bool Elf_() rz_bin_elf_is_arm_binary_supporting_thumb (RZ_NONNULL ELFOBJ *bin)
 
bool Elf_() rz_bin_elf_is_thumb_addr (ut64 addr)
 
void Elf_() rz_bin_elf_fix_arm_thumb_addr (ut64 *addr)
 
void Elf_() rz_bin_elf_fix_arm_thumb_object (RZ_NONNULL ut64 *paddr, RZ_NONNULL ut64 *vaddr, RZ_NONNULL int *bits)
 
void Elf_() rz_bin_elf_fix_arm_thumb_symbol (RZ_NONNULL RzBinSymbol *symbol)
 

Function Documentation

◆ rz_bin_elf_fix_arm_thumb_addr()

void Elf_() rz_bin_elf_fix_arm_thumb_addr ( ut64 addr)

Definition at line 28 of file elf_arm.c.

28  {
30  *addr -= 1;
31 }
bool Elf_() rz_bin_elf_is_thumb_addr(ut64 addr)
Definition: elf_arm.c:24
#define Elf_(name)
Definition: elf_specs.h:32
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
static int addr
Definition: z80asm.c:58

References addr, Elf_, rz_bin_elf_is_thumb_addr(), and rz_return_if_fail.

Referenced by rz_bin_elf_fix_arm_thumb_object().

◆ rz_bin_elf_fix_arm_thumb_object()

void Elf_() rz_bin_elf_fix_arm_thumb_object ( RZ_NONNULL ut64 paddr,
RZ_NONNULL ut64 vaddr,
RZ_NONNULL int bits 
)

Definition at line 33 of file elf_arm.c.

33  {
34  rz_return_if_fail(paddr && vaddr && bits);
35 
36  *bits = 32;
37 
38  if (Elf_(rz_bin_elf_is_thumb_addr)(*paddr)) {
40  *bits = 16;
41  }
42 
43  if (Elf_(rz_bin_elf_is_thumb_addr)(*vaddr)) {
45  *bits = 16;
46  }
47 }
int bits(struct state *s, int need)
Definition: blast.c:72
void Elf_() rz_bin_elf_fix_arm_thumb_addr(ut64 *addr)
Definition: elf_arm.c:28

References bits(), Elf_, rz_bin_elf_fix_arm_thumb_addr(), rz_bin_elf_is_thumb_addr(), and rz_return_if_fail.

◆ rz_bin_elf_fix_arm_thumb_symbol()

void Elf_() rz_bin_elf_fix_arm_thumb_symbol ( RZ_NONNULL RzBinSymbol symbol)

Definition at line 49 of file elf_arm.c.

49  {
50  rz_return_if_fail(symbol && symbol->name);
51 
52  if (start_a_sequence_of_instruction(symbol)) {
53  symbol->bits = 32;
54  } else if (start_a_sequence_of_thumb_instruction(symbol) || !start_a_sequence_of_data(symbol)) {
56  }
57 }
#define rz_bin_elf_fix_arm_thumb_object_dispatch(object)
Definition: elf.h:228
static bool start_a_sequence_of_thumb_instruction(RzBinSymbol *symbol)
Definition: elf_arm.c:11
static bool start_a_sequence_of_data(RzBinSymbol *symbol)
Definition: elf_arm.c:15
static bool start_a_sequence_of_instruction(RzBinSymbol *symbol)
Definition: elf_arm.c:7

References rz_bin_elf_fix_arm_thumb_object_dispatch, rz_return_if_fail, start_a_sequence_of_data(), start_a_sequence_of_instruction(), and start_a_sequence_of_thumb_instruction().

◆ rz_bin_elf_is_arm_binary_supporting_thumb()

bool Elf_() rz_bin_elf_is_arm_binary_supporting_thumb ( RZ_NONNULL ELFOBJ bin)

Definition at line 19 of file elf_arm.c.

19  {
20  rz_return_val_if_fail(bin, false);
21  return bin->ehdr.e_machine == EM_ARM;
22 }
#define EM_ARM
Definition: common.h:129
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
Definition: malloc.c:26

References EM_ARM, and rz_return_val_if_fail.

Referenced by rz_bin_elf_get_bits().

◆ rz_bin_elf_is_thumb_addr()

bool Elf_() rz_bin_elf_is_thumb_addr ( ut64  addr)

Definition at line 24 of file elf_arm.c.

24  {
25  return addr != UT64_MAX && addr & 1;
26 }
#define UT64_MAX
Definition: rz_types_base.h:86

References addr, and UT64_MAX.

Referenced by get_import_addr_arm(), get_main_offset_arm_glibc(), has_thumb_symbol(), rz_bin_elf_fix_arm_thumb_addr(), rz_bin_elf_fix_arm_thumb_object(), and rz_bin_elf_get_bits().

◆ start_a_sequence_of_data()

static bool start_a_sequence_of_data ( RzBinSymbol symbol)
static

Definition at line 15 of file elf_arm.c.

15  {
16  return strlen(symbol->name) > 3 && rz_str_startswith(symbol->name, "$d.");
17 }
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
Definition: str.c:3286
char * name
Definition: rz_bin.h:675

References rz_bin_symbol_t::name, and rz_str_startswith().

Referenced by rz_bin_elf_fix_arm_thumb_symbol().

◆ start_a_sequence_of_instruction()

static bool start_a_sequence_of_instruction ( RzBinSymbol symbol)
static

Definition at line 7 of file elf_arm.c.

7  {
8  return strlen(symbol->name) > 3 && rz_str_startswith(symbol->name, "$a.");
9 }

References rz_bin_symbol_t::name, and rz_str_startswith().

Referenced by rz_bin_elf_fix_arm_thumb_symbol().

◆ start_a_sequence_of_thumb_instruction()

static bool start_a_sequence_of_thumb_instruction ( RzBinSymbol symbol)
static

Definition at line 11 of file elf_arm.c.

11  {
12  return strlen(symbol->name) > 3 && rz_str_startswith(symbol->name, "$t.");
13 }

References rz_bin_symbol_t::name, and rz_str_startswith().

Referenced by rz_bin_elf_fix_arm_thumb_symbol().