Rizin
unix-like reverse engineering framework and cli tools
elf_arm.c
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: 2021 08A <08A@riseup.net>
2 // SPDX-FileCopyrightText: 2021 RizinOrg <info@rizin.re>
3 // SPDX-License-Identifier: LGPL-3.0-only
4 
5 #include "elf.h"
6 
8  return strlen(symbol->name) > 3 && rz_str_startswith(symbol->name, "$a.");
9 }
10 
12  return strlen(symbol->name) > 3 && rz_str_startswith(symbol->name, "$t.");
13 }
14 
15 static bool start_a_sequence_of_data(RzBinSymbol *symbol) {
16  return strlen(symbol->name) > 3 && rz_str_startswith(symbol->name, "$d.");
17 }
18 
20  rz_return_val_if_fail(bin, false);
21  return bin->ehdr.e_machine == EM_ARM;
22 }
23 
25  return addr != UT64_MAX && addr & 1;
26 }
27 
30  *addr -= 1;
31 }
32 
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 }
48 
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 }
int bits(struct state *s, int need)
Definition: blast.c:72
#define rz_bin_elf_fix_arm_thumb_object_dispatch(object)
Definition: elf.h:228
#define ELFOBJ
Definition: elf.h:24
void Elf_() rz_bin_elf_fix_arm_thumb_symbol(RZ_NONNULL RzBinSymbol *symbol)
Definition: elf_arm.c:49
bool Elf_() rz_bin_elf_is_arm_binary_supporting_thumb(RZ_NONNULL ELFOBJ *bin)
Definition: elf_arm.c:19
void Elf_() rz_bin_elf_fix_arm_thumb_addr(ut64 *addr)
Definition: elf_arm.c:28
bool Elf_() rz_bin_elf_is_thumb_addr(ut64 addr)
Definition: elf_arm.c:24
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
void Elf_() rz_bin_elf_fix_arm_thumb_object(RZ_NONNULL ut64 *paddr, RZ_NONNULL ut64 *vaddr, RZ_NONNULL int *bits)
Definition: elf_arm.c:33
#define Elf_(name)
Definition: elf_specs.h:32
#define EM_ARM
Definition: common.h:129
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
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
#define RZ_NONNULL
Definition: rz_types.h:64
#define UT64_MAX
Definition: rz_types_base.h:86
Definition: malloc.c:26
char * name
Definition: rz_bin.h:675
ut64(WINAPI *w32_GetEnabledXStateFeatures)()
static int addr
Definition: z80asm.c:58