Rizin
unix-like reverse engineering framework and cli tools
golang.c File Reference
#include <rz_core.h>

Go to the source code of this file.

Classes

struct  go_pc_line_table_t
 
struct  go_string_recover_t
 
struct  go_string_info_t
 
struct  go_asm_pattern_t
 
struct  go_signature_t
 

Macros

#define GO_MAX_STRING_SIZE   0x4000
 
#define GO_1_2   (12)
 
#define GO_1_16   (116)
 
#define GO_1_18   (118)
 
#define IS_GOPCLNTAB_1_2_LE(x)   (x[0] == 0xfb && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff)
 
#define IS_GOPCLNTAB_1_2_BE(x)   (x[3] == 0xfb && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff)
 
#define IS_GOPCLNTAB_1_16_LE(x)   (x[0] == 0xfa && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff)
 
#define IS_GOPCLNTAB_1_16_BE(x)   (x[3] == 0xfa && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff)
 
#define IS_GOPCLNTAB_1_18_LE(x)   (x[0] == 0xf0 && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff)
 
#define IS_GOPCLNTAB_1_18_BE(x)   (x[3] == 0xf0 && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff)
 
#define is_addr_outside(x)   ((x) <= begin || (x) >= end)
 
#define go_is_sign_match_autosize(ctx, info, sigs)   go_is_sign_match(ctx, info, sigs, RZ_ARRAY_SIZE(sigs))
 
#define go_asm_pattern_name(arch, bits, mnemonic)   go_##arch##_##bits##_##mnemonic
 
#define go_asm_pattern_define(arch, bits, mnemonic, pattern, mask, set_xref)    static GoAsmPattern go_asm_pattern_name(arch, bits, mnemonic) = { (const ut8 *)pattern, (const ut8 *)mask, (sizeof(pattern) - 1), set_xref }
 

Typedefs

typedef struct go_pc_line_table_t GoPcLnTab
 
typedef struct go_string_recover_t GoStrRecover
 
typedef struct go_string_info_t GoStrInfo
 
typedef struct go_asm_pattern_t GoAsmPattern
 
typedef bool(* GoDecodeCb) (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
typedef struct go_signature_t GoSignature
 
typedef ut32(* GoStrRecoverCb) (GoStrRecover *ctx)
 

Functions

ut32 go_func_tab_field_size (GoPcLnTab *pclntab)
 
ut64 go_uintptr (GoPcLnTab *pclntab, ut8 *bytes)
 
ut64 go_offset (GoPcLnTab *pclntab, ut32 n_word)
 
ut64 go_data (GoPcLnTab *pclntab, ut32 n_word)
 
static bool is_pclntab_valid (GoPcLnTab *pclntab)
 
static void add_new_func_symbol (RzCore *core, const char *name, ut64 vaddr)
 
static ut32 core_recover_golang_functions_go_1_18 (RzCore *core, GoPcLnTab *pclntab)
 
static ut32 core_recover_golang_functions_go_1_16 (RzCore *core, GoPcLnTab *pclntab)
 
static ut32 core_recover_golang_functions_go_1_2 (RzCore *core, GoPcLnTab *pclntab)
 
RZ_API bool rz_core_analysis_recover_golang_functions (RzCore *core)
 reads pclntab table in go binaries and recovers functions. Follows the code https://github.com/golang/go/blob/master/src/debug/gosym/pclntab.go#L188 More...
 
static bool add_new_bin_string (RzCore *core, char *string, ut64 vaddr, ut32 size)
 
static bool recover_string_at (GoStrRecover *ctx, ut64 str_addr, ut64 str_size)
 
static bool go_is_sign_match (GoStrRecover *ctx, GoStrInfo *info, GoSignature *sigs, const size_t n_sigs)
 
static ut32 decode_one_opcode_size (GoStrRecover *ctx)
 
static bool decode_from_table (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
static bool decode_val_set_size (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
static bool decode_val_set_addr (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
static bool decode_val_add_addr (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
static bool decode_ptr_set_addr (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
static bool decode_disp_set_addr (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
 go_asm_pattern_define (x86, 64, lea, "\x48\x00\x00\x00\x00\x00\x00", "\xff\x00\x00\x00\x00\x00\x00", true)
 
 go_asm_pattern_define (x86, 64, mov_imm0, "\xb9\x00\x00\x00\x00", "\xff\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 64, mov_imm1, "\x48\xc7\x00\x00\x00\x00\x00\x00", "\xff\xff\x00\x00\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 64, mov_imm2, "\x41\x00\x00\x00\x00\x00", "\xff\x00\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 64, mov_imm3, "\xbb\x00\x00\x00\x00", "\xff\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 64, mov_imm4, "\xbf\x00\x00\x00\x00", "\xff\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 64, mov_reg0, "\x48\x00\x00\x00", "\xff\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 64, mov_reg1, "\x48\x00\x00\x00\x00", "\xff\x00\x00\x00\x00", false)
 
static ut32 golang_recover_string_x64 (GoStrRecover *ctx)
 
 go_asm_pattern_define (x86, 32, lea, "\x8d\x00\x00\x00\x00\x00", "\xff\x00\x00\x00\x00\x00", true)
 
 go_asm_pattern_define (x86, 32, mov_imm0, "\xc7\x00\x00\x00\x00\x00\x00", "\xff\x00\x00\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 32, mov_imm1, "\xc7\x00\x00\x00\x00\x00\x00\x00", "\xff\x00\x00\x00\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (x86, 32, mov_reg0, "\x89\x00\x00", "\xff\x00\x00", false)
 
 go_asm_pattern_define (x86, 32, mov_reg1, "\x89\x00\x00\x00", "\xff\x00\x00\x00", false)
 
static ut32 golang_recover_string_x86 (GoStrRecover *ctx)
 
 go_asm_pattern_define (arm, 64, adrp, "\x00\x00\x00\x80", "\x00\x00\x00\x8f", true)
 
 go_asm_pattern_define (arm, 64, add, "\x00\x00\x00\x01", "\x00\x00\x00\x6f", false)
 
 go_asm_pattern_define (arm, 64, orr, "\x00\x00\x00\x22", "\x00\x00\x80\x6f", false)
 
 go_asm_pattern_define (arm, 64, movz, "\x00\x00\x80\x42", "\x00\x00\x80\x6f", false)
 
 go_asm_pattern_define (arm, 64, any, "\x00\x00\x00\x00", "\x00\x00\x00\x00", false)
 
static ut32 golang_recover_string_arm64 (GoStrRecover *ctx)
 
static bool decode_ldr_set_addr (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
 go_asm_pattern_define (arm, 32, ldr, "\x00\x00\x9f\xe5", "\x00\x00\x9f\xe5", true)
 
 go_asm_pattern_define (arm, 32, mov, "\x00\x00\xa0\xe3", "\x00\x00\xa0\xe3", false)
 
 go_asm_pattern_define (arm, 32, any, "\x00\x00\x00\x00", "\x00\x00\x00\x00", false)
 
static ut32 golang_recover_string_arm32 (GoStrRecover *ctx)
 
static bool decode_lui_set_addr (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
 go_asm_pattern_define (mips, 32, any, "\x00\x00\x00\x00", "\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (mipsbe, 32, addiu, "\x24\x00\x00\x00", "\xff\x00\x00\x00", false)
 
 go_asm_pattern_define (mipsle, 32, addiu, "\x00\x00\x00\x24", "\x00\x00\x00\xff", false)
 
 go_asm_pattern_define (mipsbe, 32, lui, "\x3c\x00\x00\x00", "\xff\x00\x00\x00", true)
 
 go_asm_pattern_define (mipsle, 32, lui, "\x00\x00\x00\x3c", "\x00\x00\x00\xff", true)
 
static ut32 golang_recover_string_mips32 (GoStrRecover *ctx)
 
 go_asm_pattern_define (mips, 64, any, "\x00\x00\x00\x00", "\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (mipsbe, 64, daddu, "\x00\x00\x00\x2d", "\x00\x00\x00\xff", false)
 
 go_asm_pattern_define (mipsle, 64, daddu, "\x2d\x00\x00\x00", "\xff\x00\x00\x00", false)
 
 go_asm_pattern_define (mipsbe, 64, daddiu, "\x64\x00\x00\x00", "\xfc\x00\x00\x00", false)
 
 go_asm_pattern_define (mipsle, 64, daddiu, "\x00\x00\x00\x64", "\x00\x00\x00\xfc", false)
 
 go_asm_pattern_define (mipsbe, 64, move, "\x64\x00\x00\x00", "\xff\xe0\x00\x00", false)
 
 go_asm_pattern_define (mipsle, 64, move, "\x00\x00\x00\x64", "\x00\x00\xe0\xff", false)
 
 go_asm_pattern_define (mipsbe, 64, lui, "\x3c\x00\x00\x00", "\xff\x00\x00\x00", true)
 
 go_asm_pattern_define (mipsle, 64, lui, "\x00\x00\x00\x3c", "\x00\x00\x00\xff", true)
 
static ut32 golang_recover_string_mips64 (GoStrRecover *ctx)
 
 go_asm_pattern_define (ppc, 64, any, "\x00\x00\x00\x00", "\x00\x00\x00\x00", false)
 
 go_asm_pattern_define (ppcle, 64, lis, "\x00\x00\x00\x3c", "\x00\x00\x00\xfc", true)
 
 go_asm_pattern_define (ppcbe, 64, lis, "\x3c\x00\x00\x00", "\xfc\x00\x00\x00", true)
 
 go_asm_pattern_define (ppcle, 64, addi, "\x00\x00\x00\x38", "\x00\x00\x00\xfc", false)
 
 go_asm_pattern_define (ppcbe, 64, addi, "\x38\x00\x00\x00", "\xfc\x00\x00\x00", false)
 
 go_asm_pattern_define (ppcle, 64, li, "\x00\x00\x00\x38", "\x00\x00\x1f\xfc", false)
 
 go_asm_pattern_define (ppcbe, 64, li, "\x38\x00\x00\x00", "\xfc\x1f\x00\x00", false)
 
static ut32 golang_recover_string_ppc64 (GoStrRecover *ctx)
 
static bool decode_auipc_set_addr (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
 
 go_asm_pattern_define (riscv, 64, auipc, "\x17\x00\x00\x00", "\x7f\x00\x00\x00", true)
 
 go_asm_pattern_define (riscv, 64, addi, "\x13\x00\x00\x00", "\x7f\x00\x00\x00", false)
 
 go_asm_pattern_define (riscv, 64, addiw, "\x1b\x00\x00\x00", "\x7f\x70\x00\x00", false)
 
 go_asm_pattern_define (riscv, 64, li, "\x13\x00\x00\x00", "\x7f\x80\x0F\x00", false)
 
 go_asm_pattern_define (riscv, 64, any, "\x00\x00\x00\x00", "\x00\x00\x00\x00", false)
 
static ut32 golang_recover_string_riscv64 (GoStrRecover *ctx)
 
RZ_API void rz_core_analysis_resolve_golang_strings (RzCore *core)
 Attempts to recover all golang string. More...
 

Variables

static GoSignature go_x64_lea_mov0_mov_signature []
 
static GoSignature go_x64_lea_mov1_mov_signature []
 
static GoSignature go_x64_lea_mov0_signature []
 
static GoSignature go_x64_lea_mov1_signature []
 
static GoSignature go_x64_lea_mov2_signature []
 
static GoSignature go_x64_lea_mov3_signature []
 
static GoSignature go_x64_mov0_lea_signature []
 
static GoSignature go_x64_mov1_lea_signature []
 
static GoSignature go_x64_mov2_lea_signature []
 
static GoSignature go_x64_mov3_lea_signature []
 
static GoSignature go_x64_table0_signature []
 
static GoSignature go_x64_table1_signature []
 
static GoSignature go_x86_lea_mov0_mov_signature []
 
static GoSignature go_x86_lea_mov1_mov_signature []
 
static GoSignature go_x86_lea_mov0_signature []
 
static GoSignature go_x86_lea_mov1_signature []
 
static GoSignature go_x86_mov_lea_signature []
 
static GoSignature go_x86_table_signature []
 
static GoSignature go_arm64_adrp_add_str_orr_signature []
 
static GoSignature go_arm64_adrp_add_str_movz_signature []
 
static GoSignature go_arm64_orr_str_adrp_add_signature []
 
static GoSignature go_arm64_movz_str_adrp_add_signature []
 
static GoSignature go_arm64_adrp_add_orr_signature []
 
static GoSignature go_arm64_adrp_add_movz_signature []
 
static GoSignature go_arm64_table_signature []
 
static GoSignature go_arm32_ldr_str_mov_signature []
 
static GoSignature go_arm32_mov_str_ldr_signature []
 
static GoSignature go_arm32_ldr_mov_signature []
 
static GoSignature go_arm32_table_signature []
 
static GoSignature go_mipsle32_lui_addiu_sw_addiu_signature []
 
static GoSignature go_mipsle32_addiu_sw_lui_addiu_signature []
 
static GoSignature go_mipsle32_lui_addiu_addiu_signature []
 
static GoSignature go_mipsle32_table_signature []
 
static GoSignature go_mipsbe32_lui_addiu_sw_addiu_signature []
 
static GoSignature go_mipsbe32_addiu_sw_lui_addiu_signature []
 
static GoSignature go_mipsbe32_lui_addiu_addiu_signature []
 
static GoSignature go_mipsbe32_table_signature []
 
static GoSignature go_mipsle64_lui_daddu_daddiu_sd_daddiu_signature []
 
static GoSignature go_mipsle64_daddiu_sd_lui_daddu_daddiu_signature []
 
static GoSignature go_mipsle64_lui_daddu_daddiu_daddiu_signature []
 
static GoSignature go_mipsle64_table_signature []
 
static GoSignature go_mipsbe64_lui_daddu_daddiu_sd_daddiu_signature []
 
static GoSignature go_mipsbe64_daddiu_sd_lui_daddu_daddiu_signature []
 
static GoSignature go_mipsbe64_lui_daddu_daddiu_daddiu_signature []
 
static GoSignature go_mipsbe64_table_signature []
 
static GoSignature go_ppcle64_lis_addi_std_li_signature []
 
static GoSignature go_ppcle64_li_std_lis_addi_signature []
 
static GoSignature go_ppcle64_lis_addi_li_signature []
 
static GoSignature go_ppcle64_table_signature []
 
static GoSignature go_ppcbe64_lis_addi_std_li_signature []
 
static GoSignature go_ppcbe64_li_std_lis_addi_signature []
 
static GoSignature go_ppcbe64_lis_addi_li_signature []
 
static GoSignature go_ppcbe64_table_signature []
 
static GoSignature go_riscv64_auipc_add_sd_addiw_signature []
 
static GoSignature go_riscv64_auipc_add_sd_li_signature []
 
static GoSignature go_riscv64_li_sd_auipc_add_signature []
 
static GoSignature go_riscv64_addiw_sd_auipc_add_signature []
 
static GoSignature go_riscv64_auipc_add_addiw_signature []
 
static GoSignature go_riscv64_auipc_add_li_signature []
 
static GoSignature go_riscv64_table_signature []
 

Macro Definition Documentation

◆ GO_1_16

#define GO_1_16   (116)

Definition at line 9 of file golang.c.

◆ GO_1_18

#define GO_1_18   (118)

Definition at line 10 of file golang.c.

◆ GO_1_2

#define GO_1_2   (12)

Definition at line 8 of file golang.c.

◆ go_asm_pattern_define

#define go_asm_pattern_define (   arch,
  bits,
  mnemonic,
  pattern,
  mask,
  set_xref 
)     static GoAsmPattern go_asm_pattern_name(arch, bits, mnemonic) = { (const ut8 *)pattern, (const ut8 *)mask, (sizeof(pattern) - 1), set_xref }

Definition at line 659 of file golang.c.

◆ go_asm_pattern_name

#define go_asm_pattern_name (   arch,
  bits,
  mnemonic 
)    go_##arch##_##bits##_##mnemonic

Definition at line 658 of file golang.c.

◆ go_is_sign_match_autosize

#define go_is_sign_match_autosize (   ctx,
  info,
  sigs 
)    go_is_sign_match(ctx, info, sigs, RZ_ARRAY_SIZE(sigs))

Definition at line 657 of file golang.c.

◆ GO_MAX_STRING_SIZE

#define GO_MAX_STRING_SIZE   0x4000

Definition at line 6 of file golang.c.

◆ is_addr_outside

#define is_addr_outside (   x)    ((x) <= begin || (x) >= end)

Definition at line 103 of file golang.c.

◆ IS_GOPCLNTAB_1_16_BE

#define IS_GOPCLNTAB_1_16_BE (   x)    (x[3] == 0xfa && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff)

Definition at line 15 of file golang.c.

◆ IS_GOPCLNTAB_1_16_LE

#define IS_GOPCLNTAB_1_16_LE (   x)    (x[0] == 0xfa && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff)

Definition at line 14 of file golang.c.

◆ IS_GOPCLNTAB_1_18_BE

#define IS_GOPCLNTAB_1_18_BE (   x)    (x[3] == 0xf0 && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff)

Definition at line 17 of file golang.c.

◆ IS_GOPCLNTAB_1_18_LE

#define IS_GOPCLNTAB_1_18_LE (   x)    (x[0] == 0xf0 && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff)

Definition at line 16 of file golang.c.

◆ IS_GOPCLNTAB_1_2_BE

#define IS_GOPCLNTAB_1_2_BE (   x)    (x[3] == 0xfb && x[2] == 0xff && x[1] == 0xff && x[0] == 0xff)

Definition at line 13 of file golang.c.

◆ IS_GOPCLNTAB_1_2_LE

#define IS_GOPCLNTAB_1_2_LE (   x)    (x[0] == 0xfb && x[1] == 0xff && x[2] == 0xff && x[3] == 0xff)

Definition at line 12 of file golang.c.

Typedef Documentation

◆ GoAsmPattern

◆ GoDecodeCb

typedef bool(* GoDecodeCb) (RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)

Definition at line 63 of file golang.c.

◆ GoPcLnTab

typedef struct go_pc_line_table_t GoPcLnTab

◆ GoSignature

typedef struct go_signature_t GoSignature

◆ GoStrInfo

typedef struct go_string_info_t GoStrInfo

◆ GoStrRecover

◆ GoStrRecoverCb

typedef ut32(* GoStrRecoverCb) (GoStrRecover *ctx)

Definition at line 70 of file golang.c.

Function Documentation

◆ add_new_bin_string()

static bool add_new_bin_string ( RzCore core,
char *  string,
ut64  vaddr,
ut32  size 
)
static

Definition at line 486 of file golang.c.

486  {
487  ut32 ordinal = 0;
488  RzBinString *bstr;
489  RzBin *bin = core->bin;
490  RzBinFile *bf = rz_bin_cur(bin);
491  if (!bf || !bf->o || !bf->o->strings) {
492  free(string);
493  return false;
494  }
495 
496  bstr = rz_bin_object_get_string_at(bf->o, vaddr, true);
497  if (bstr && bstr->vaddr == vaddr && bstr->size == size) {
498  free(string);
499  return true;
500  }
501 
503  ordinal = rz_list_length(strings);
504 
505  ut64 paddr = rz_io_v2p(core->io, vaddr);
506 
507  bstr = RZ_NEW0(RzBinString);
508  if (!bstr) {
509  RZ_LOG_ERROR("Failed allocate new go string\n");
510  free(string);
511  return false;
512  }
513  bstr->paddr = paddr;
514  bstr->vaddr = vaddr;
515  bstr->ordinal = ordinal;
516  bstr->length = bstr->size = size;
517  bstr->string = string;
518  bstr->type = RZ_STRING_ENC_UTF8;
519  if (!rz_bin_string_database_add(bf->o->strings, bstr)) {
520  RZ_LOG_ERROR("Failed append new go string to strings database\n");
521  rz_bin_string_free(bstr);
522  return false;
523  }
524  return true;
525 }
RZ_API void rz_bin_string_free(void *_str)
Definition: bin.c:192
RZ_API RzBinFile * rz_bin_cur(RzBin *bin)
Definition: bin.c:895
RZ_API RZ_BORROW RzBinString * rz_bin_object_get_string_at(RZ_NONNULL RzBinObject *obj, ut64 address, bool is_va)
Return RzBinString if at address there is an entry in the RzBinObject string database.
Definition: bobj.c:861
RZ_API const RzList * rz_bin_object_get_strings(RZ_NONNULL RzBinObject *obj)
Get list of RzBinString representing the strings identified in the binary object.
Definition: bobj.c:798
RZ_API bool rz_bin_string_database_add(RZ_NONNULL RzBinStrDb *db, RZ_NONNULL RzBinString *bstr)
{ function_description }
Definition: bobj.c:1094
uint32_t ut32
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n output MIME type strings(--mime-type and\n" " --mime-encoding)\n") OPT('s'
RZ_API void Ht_() free(HtName_(Ht) *ht)
Definition: ht_inc.c:130
voidpf void uLong size
Definition: ioapi.h:138
RZ_API ut32 rz_list_length(RZ_NONNULL const RzList *list)
Returns the length of the list.
Definition: list.c:109
RZ_API ut64 rz_io_v2p(RzIO *io, ut64 va)
Definition: io.c:541
#define RZ_LOG_ERROR(fmtstr,...)
Definition: rz_log.h:58
@ RZ_STRING_ENC_UTF8
Definition: rz_str.h:21
#define RZ_NEW0(x)
Definition: rz_types.h:284
Definition: malloc.c:26
XX curplugin == o->plugin.
Definition: rz_bin.h:298
RzBinObject * o
Definition: rz_bin.h:305
RzBinStrDb * strings
Definition: rz_bin.h:280
ut32 ordinal
Definition: rz_bin.h:755
char * string
Definition: rz_bin.h:752
RzBin * bin
Definition: rz_core.h:298
RzIO * io
Definition: rz_core.h:313
ut64(WINAPI *w32_GetEnabledXStateFeatures)()

References rz_core_t::bin, free(), rz_core_t::io, rz_bin_string_t::length, rz_bin_file_t::o, rz_bin_string_t::ordinal, rz_bin_string_t::paddr, rz_bin_cur(), rz_bin_object_get_string_at(), rz_bin_object_get_strings(), rz_bin_string_database_add(), rz_bin_string_free(), rz_io_v2p(), rz_list_length(), RZ_LOG_ERROR, RZ_NEW0, RZ_STRING_ENC_UTF8, rz_bin_string_t::size, rz_bin_string_t::string, rz_bin_object_t::strings, strings(), rz_bin_string_t::type, ut64(), and rz_bin_string_t::vaddr.

Referenced by recover_string_at().

◆ add_new_func_symbol()

static void add_new_func_symbol ( RzCore core,
const char *  name,
ut64  vaddr 
)
static

Definition at line 136 of file golang.c.

136  {
137  RzBinFile *bf = rz_bin_cur(core->bin);
138  if (!bf || !bf->o || !bf->o->symbols) {
139  return;
140  }
141  ut64 paddr = rz_io_v2p(core->io, vaddr);
142  RzBinSymbol *symbol = rz_bin_symbol_new(name, paddr, vaddr);
143  if (!symbol) {
144  RZ_LOG_ERROR("Failed allocate new go symbol\n");
145  return;
146  }
147 
148  symbol->bind = RZ_BIN_BIND_GLOBAL_STR;
149  symbol->type = RZ_BIN_TYPE_FUNC_STR;
150  if (!rz_list_append(bf->o->symbols, symbol)) {
151  RZ_LOG_ERROR("Failed append new go symbol to symbols list\n");
152  rz_bin_symbol_free(symbol);
153  }
154 
155  if (!strcmp(name, "main.main")) {
156  rz_flag_set(core->flags, "main", vaddr, 1);
157  }
158 }
RZ_API RzBinSymbol * rz_bin_symbol_new(const char *name, ut64 paddr, ut64 vaddr)
Definition: bin.c:165
RZ_API void rz_bin_symbol_free(RzBinSymbol *sym)
Definition: bin.c:175
RZ_API RzFlagItem * rz_flag_set(RzFlag *f, const char *name, ut64 off, ut32 size)
Definition: flag.c:521
RZ_API RZ_BORROW RzListIter * rz_list_append(RZ_NONNULL RzList *list, void *data)
Appends at the end of the list a new element.
Definition: list.c:288
#define RZ_BIN_BIND_GLOBAL_STR
Definition: rz_bin.h:107
#define RZ_BIN_TYPE_FUNC_STR
Definition: rz_bin.h:119
Definition: z80asm.h:102
RzList * symbols
Definition: rz_bin.h:269
const char * bind
Definition: rz_bin.h:681
const char * type
Definition: rz_bin.h:682
RzFlag * flags
Definition: rz_core.h:330

References rz_core_t::bin, rz_bin_symbol_t::bind, rz_core_t::flags, rz_core_t::io, rz_bin_file_t::o, RZ_BIN_BIND_GLOBAL_STR, rz_bin_cur(), rz_bin_symbol_free(), rz_bin_symbol_new(), RZ_BIN_TYPE_FUNC_STR, rz_flag_set(), rz_io_v2p(), rz_list_append(), RZ_LOG_ERROR, rz_bin_object_t::symbols, rz_bin_symbol_t::type, and ut64().

Referenced by core_recover_golang_functions_go_1_16(), core_recover_golang_functions_go_1_18(), and core_recover_golang_functions_go_1_2().

◆ core_recover_golang_functions_go_1_16()

static ut32 core_recover_golang_functions_go_1_16 ( RzCore core,
GoPcLnTab pclntab 
)
static

Definition at line 235 of file golang.c.

235  {
236  rz_core_notify_done(core, "Found go 1.16 pclntab data.");
237  ut8 tmp8[8];
238  char name[256];
239  char *flag = NULL;
240  ut32 num_syms = 0;
241  ut64 func_ptr = 0, func_off = 0, name_ptr = 0, name_off = 0;
242 
243  pclntab->nfunctab = (ut32)go_offset(pclntab, 0);
244  pclntab->nfiletab = (ut32)go_offset(pclntab, 1);
245  pclntab->funcnametab = go_data(pclntab, 2);
246  pclntab->cutab = go_data(pclntab, 3);
247  pclntab->filetab = go_data(pclntab, 4);
248  pclntab->pctab = go_data(pclntab, 5);
249  pclntab->funcdata = go_data(pclntab, 6);
250  pclntab->functab = go_data(pclntab, 6);
251  pclntab->functabsize = ((pclntab->nfunctab * 2) + 1) * go_func_tab_field_size(pclntab);
252 
253  if (!is_pclntab_valid(pclntab)) {
254  rz_core_notify_error(core, "Invalid go 1.16 pclntab (invalid table).");
255  return 0;
256  }
257 
258  rz_flag_space_push(core->flags, RZ_FLAGS_FS_SYMBOLS);
259  for (ut32 i = 0, ptr = 0; i < pclntab->nfunctab; ++i, ptr += (pclntab->ptrsize * 2)) {
260  ut64 offset = pclntab->functab + ptr;
261 
262  // reads the value of the function pointer
263  if (0 > rz_io_nread_at(pclntab->io, offset, tmp8, sizeof(tmp8))) {
264  RZ_LOG_ERROR("Failed to read go function address at 0x%08" PFMT64x "\n", offset);
265  break;
266  }
267  func_ptr = go_uintptr(pclntab, tmp8);
268 
269  // reads the value of the function data offset
270  if (0 > rz_io_nread_at(pclntab->io, offset + pclntab->ptrsize, tmp8, sizeof(tmp8))) {
271  RZ_LOG_ERROR("Failed to read go function data address at 0x%08" PFMT64x "\n", offset);
272  break;
273  }
274  func_off = go_uintptr(pclntab, tmp8);
275 
276  name_ptr = pclntab->functab + func_off + pclntab->ptrsize;
277  // reads the location of the function name within funcnametab
278  if (0 > rz_io_nread_at(pclntab->io, name_ptr, tmp8, sizeof(ut32))) {
279  RZ_LOG_ERROR("Failed to read go function name address at 0x%08" PFMT64x "\n", offset);
280  break;
281  }
282 
283  name_off = pclntab->funcnametab + rz_read_ble32(tmp8, pclntab->big_endian);
284 
285  // ignore failures, we can always create a new name.
286  memset(name, 0, sizeof(name));
287  (void)rz_io_nread_at(pclntab->io, name_off, (ut8 *)name, sizeof(name));
288  name[sizeof(name) - 1] = 0;
289  RZ_LOG_INFO("Recovered symbol at 0x%08" PFMT64x " with name '%s'\n", func_ptr, name);
290 
291  if (rz_str_len_utf8_ansi(name) > 0) {
292  // always add it before filtering the name.
293  add_new_func_symbol(core, name, func_ptr);
294  rz_name_filter(name, 0, true);
295  } else {
296  rz_strf(name, "fcn.pclntab.unknown.%08" PFMT64x, func_ptr);
297  add_new_func_symbol(core, name, func_ptr);
298  }
299 
300  flag = rz_str_newf("sym.go.%s", name);
301  rz_flag_set(core->flags, flag, func_ptr, 1);
302  free(flag);
303 
304  num_syms++;
305  }
306  rz_flag_space_pop(core->flags);
307 
308  return num_syms;
309 }
lzma_index ** i
Definition: index.h:629
ut64 go_data(GoPcLnTab *pclntab, ut32 n_word)
Definition: golang.c:95
ut64 go_uintptr(GoPcLnTab *pclntab, ut8 *bytes)
Definition: golang.c:79
ut64 go_offset(GoPcLnTab *pclntab, ut32 n_word)
Definition: golang.c:86
ut32 go_func_tab_field_size(GoPcLnTab *pclntab)
Definition: golang.c:72
static void add_new_func_symbol(RzCore *core, const char *name, ut64 vaddr)
Definition: golang.c:136
static bool is_pclntab_valid(GoPcLnTab *pclntab)
Definition: golang.c:104
#define NULL
Definition: cris-opc.c:27
voidpf uLong offset
Definition: ioapi.h:144
uint8_t ut8
Definition: lh5801.h:11
return memset(p, 0, total)
RZ_API void rz_core_notify_done(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format,...)
Prints a message definining the end of a task which succeeded.
Definition: core.c:60
RZ_API void rz_core_notify_error(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format,...)
Prints a message definining the end of a task which errored.
Definition: core.c:87
const char * name
Definition: op.c:541
#define RZ_FLAGS_FS_SYMBOLS
Definition: rz_core.h:67
static ut32 rz_read_ble32(const void *src, bool big_endian)
Definition: rz_endian.h:497
RZ_API int rz_io_nread_at(RzIO *io, ut64 addr, ut8 *buf, int len)
Definition: io.c:338
#define RZ_LOG_INFO(fmtstr,...)
Definition: rz_log.h:54
RZ_API bool rz_name_filter(char *name, int len, bool strict)
Definition: name.c:43
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API size_t rz_str_len_utf8_ansi(const char *str)
Definition: str.c:2723
#define rz_strf(buf,...)
Convenience macro for local temporary strings.
Definition: rz_str.h:59
#define PFMT64x
Definition: rz_types.h:393
ut64 funcnametab
Definition: golang.c:34
ut32 functabsize
Definition: golang.c:32

References add_new_func_symbol(), go_pc_line_table_t::big_endian, go_pc_line_table_t::cutab, go_pc_line_table_t::filetab, rz_core_t::flags, free(), go_pc_line_table_t::funcdata, go_pc_line_table_t::funcnametab, go_pc_line_table_t::functab, go_pc_line_table_t::functabsize, go_data(), go_func_tab_field_size(), go_offset(), go_uintptr(), i, go_pc_line_table_t::io, is_pclntab_valid(), memset(), name, go_pc_line_table_t::nfiletab, go_pc_line_table_t::nfunctab, NULL, go_pc_line_table_t::pctab, PFMT64x, go_pc_line_table_t::ptrsize, rz_core_notify_done(), rz_core_notify_error(), rz_flag_set(), RZ_FLAGS_FS_SYMBOLS, rz_io_nread_at(), RZ_LOG_ERROR, RZ_LOG_INFO, rz_name_filter(), rz_read_ble32(), rz_str_len_utf8_ansi(), rz_str_newf(), rz_strf, and ut64().

Referenced by rz_core_analysis_recover_golang_functions().

◆ core_recover_golang_functions_go_1_18()

static ut32 core_recover_golang_functions_go_1_18 ( RzCore core,
GoPcLnTab pclntab 
)
static

Definition at line 160 of file golang.c.

160  {
161  rz_core_notify_done(core, "Found go 1.18 pclntab data.");
162  ut8 tmp8[8];
163  char name[256];
164  char *flag = NULL;
165  ut32 num_syms = 0;
166  ut64 func_ptr = 0, func_off = 0, name_ptr = 0, name_off = 0;
167 
168  pclntab->nfunctab = (ut32)go_offset(pclntab, 0);
169  pclntab->nfiletab = (ut32)go_offset(pclntab, 1);
170  pclntab->funcnametab = go_data(pclntab, 3);
171  pclntab->cutab = go_data(pclntab, 4);
172  pclntab->filetab = go_data(pclntab, 5);
173  pclntab->pctab = go_data(pclntab, 6);
174  pclntab->funcdata = go_data(pclntab, 7);
175  pclntab->functab = go_data(pclntab, 7);
176  pclntab->functabsize = ((pclntab->nfunctab * 2) + 1) * go_func_tab_field_size(pclntab);
177  pclntab->ptrsize = 4; // GO 1.18+ uses ut32 words.
178 
179  if (!is_pclntab_valid(pclntab)) {
180  rz_core_notify_error(core, "Invalid go 1.18 pclntab (invalid table).");
181  return 0;
182  }
183 
184  rz_flag_space_push(core->flags, RZ_FLAGS_FS_SYMBOLS);
185  for (ut32 i = 0, ptr = 0; i < pclntab->nfunctab; ++i, ptr += (pclntab->ptrsize * 2)) {
186  ut64 offset = pclntab->functab + ptr;
187 
188  // reads the value of the function pointer
189  if (0 > rz_io_nread_at(pclntab->io, offset, tmp8, sizeof(tmp8))) {
190  RZ_LOG_ERROR("Failed to read go function address at 0x%08" PFMT64x "\n", offset);
191  break;
192  }
193  func_ptr = pclntab->text_start + go_uintptr(pclntab, tmp8);
194 
195  // reads the value of the function data offset
196  if (0 > rz_io_nread_at(pclntab->io, offset + pclntab->ptrsize, tmp8, sizeof(tmp8))) {
197  RZ_LOG_ERROR("Failed to read go function data address at 0x%08" PFMT64x "\n", offset);
198  break;
199  }
200  func_off = go_uintptr(pclntab, tmp8);
201 
202  name_ptr = pclntab->functab + func_off + pclntab->ptrsize;
203  // reads the location of the function name within funcnametab
204  if (0 > rz_io_nread_at(pclntab->io, name_ptr, tmp8, sizeof(ut32))) {
205  RZ_LOG_ERROR("Failed to read go function name address at 0x%08" PFMT64x "\n", offset);
206  break;
207  }
208  name_off = pclntab->funcnametab + rz_read_ble32(tmp8, pclntab->big_endian);
209 
210  // ignore failures, we can always create a new name.
211  memset(name, 0, sizeof(name));
212  (void)rz_io_nread_at(pclntab->io, name_off, (ut8 *)name, sizeof(name));
213  name[sizeof(name) - 1] = 0;
214  RZ_LOG_INFO("Recovered symbol at 0x%08" PFMT64x " with name '%s'\n", func_ptr, name);
215  if (rz_str_len_utf8_ansi(name) > 0) {
216  // always add it before filtering the name.
217  add_new_func_symbol(core, name, func_ptr);
218  rz_name_filter(name, 0, true);
219  } else {
220  rz_strf(name, "fcn.pclntab.unknown.%08" PFMT64x, func_ptr);
221  add_new_func_symbol(core, name, func_ptr);
222  }
223 
224  flag = rz_str_newf("sym.go.%s", name);
225  rz_flag_set(core->flags, flag, func_ptr, 1);
226  free(flag);
227 
228  num_syms++;
229  }
230  rz_flag_space_pop(core->flags);
231 
232  return num_syms;
233 }

References add_new_func_symbol(), go_pc_line_table_t::big_endian, go_pc_line_table_t::cutab, go_pc_line_table_t::filetab, rz_core_t::flags, free(), go_pc_line_table_t::funcdata, go_pc_line_table_t::funcnametab, go_pc_line_table_t::functab, go_pc_line_table_t::functabsize, go_data(), go_func_tab_field_size(), go_offset(), go_uintptr(), i, go_pc_line_table_t::io, is_pclntab_valid(), memset(), name, go_pc_line_table_t::nfiletab, go_pc_line_table_t::nfunctab, NULL, go_pc_line_table_t::pctab, PFMT64x, go_pc_line_table_t::ptrsize, rz_core_notify_done(), rz_core_notify_error(), rz_flag_set(), RZ_FLAGS_FS_SYMBOLS, rz_io_nread_at(), RZ_LOG_ERROR, RZ_LOG_INFO, rz_name_filter(), rz_read_ble32(), rz_str_len_utf8_ansi(), rz_str_newf(), rz_strf, go_pc_line_table_t::text_start, and ut64().

Referenced by rz_core_analysis_recover_golang_functions().

◆ core_recover_golang_functions_go_1_2()

static ut32 core_recover_golang_functions_go_1_2 ( RzCore core,
GoPcLnTab pclntab 
)
static

Definition at line 312 of file golang.c.

312  {
313  rz_core_notify_done(core, "Found go 1.12 pclntab data.");
314  ut8 tmp8[8];
315  char name[256];
316  char *flag = NULL;
317  ut32 num_syms = 0;
318  ut64 func_ptr = 0, func_off = 0, name_ptr = 0, name_off = 0;
319 
320  if (0 > rz_io_nread_at(pclntab->io, pclntab->vaddr + 8, tmp8, sizeof(tmp8))) {
321  return 0;
322  }
323 
324  pclntab->nfunctab = (ut32)go_uintptr(pclntab, tmp8);
325  pclntab->functab = pclntab->vaddr + 8 + pclntab->ptrsize;
326  pclntab->functabsize = ((pclntab->nfunctab * 2) + 1) * go_func_tab_field_size(pclntab);
327 
328  if (0 > rz_io_nread_at(pclntab->io, pclntab->functab + pclntab->functabsize, tmp8, sizeof(ut32))) {
329  RZ_LOG_ERROR("Failed to read go functab at 0x%08" PFMT64x "\n", pclntab->functab);
330  return 0;
331  }
332 
333  pclntab->filetab = pclntab->vaddr + rz_read_ble32(tmp8, pclntab->big_endian);
334  if (0 > rz_io_nread_at(pclntab->io, pclntab->filetab, tmp8, sizeof(ut32))) {
335  RZ_LOG_ERROR("Failed to read go filetab at 0x%08" PFMT64x "\n", pclntab->filetab);
336  return 0;
337  }
338  pclntab->nfiletab = rz_read_ble32(tmp8, pclntab->big_endian);
339 
340  if (!is_pclntab_valid(pclntab)) {
341  rz_core_notify_error(core, "Invalid go 1.12 pclntab (invalid table).");
342  return 0;
343  }
344 
345  rz_flag_space_push(core->flags, RZ_FLAGS_FS_SYMBOLS);
346  for (ut32 i = 0, ptr = 0; i < pclntab->nfunctab; ++i, ptr += (pclntab->ptrsize * 2)) {
347  ut64 offset = pclntab->functab + ptr;
348 
349  // reads the value of the function pointer
350  if (0 > rz_io_nread_at(pclntab->io, offset, tmp8, sizeof(tmp8))) {
351  RZ_LOG_ERROR("Failed to read go function address at 0x%08" PFMT64x "\n", offset);
352  break;
353  }
354  func_ptr = go_uintptr(pclntab, tmp8);
355 
356  // reads the value of the function data offset
357  if (0 > rz_io_nread_at(pclntab->io, offset + pclntab->ptrsize, tmp8, sizeof(tmp8))) {
358  RZ_LOG_ERROR("Failed to read go function address data at 0x%08" PFMT64x "\n", offset);
359  break;
360  }
361  func_off = go_uintptr(pclntab, tmp8);
362 
363  name_ptr = pclntab->vaddr + func_off + pclntab->ptrsize;
364  // reads the location of the function name within funcnametab
365  if (0 > rz_io_nread_at(pclntab->io, name_ptr, tmp8, sizeof(ut32))) {
366  RZ_LOG_ERROR("Failed to read go function name address at 0x%08" PFMT64x "\n", offset);
367  break;
368  }
369 
370  name_off = pclntab->vaddr + rz_read_ble32(tmp8, pclntab->big_endian);
371 
372  // ignore failures, we can always create a new name.
373  memset(name, 0, sizeof(name));
374  (void)rz_io_nread_at(pclntab->io, name_off, (ut8 *)name, sizeof(name));
375  name[sizeof(name) - 1] = 0;
376  RZ_LOG_INFO("Recovered symbol at 0x%08" PFMT64x " with name '%s'\n", func_ptr, name);
377 
378  if (rz_str_len_utf8_ansi(name) > 0) {
379  // always add it before filtering the name.
380  add_new_func_symbol(core, name, func_ptr);
381  rz_name_filter(name, 0, true);
382  } else {
383  rz_strf(name, "fcn.pclntab.unknown.%08" PFMT64x, func_ptr);
384  add_new_func_symbol(core, name, func_ptr);
385  }
386 
387  flag = rz_str_newf("sym.go.%s", name);
388  rz_flag_set(core->flags, flag, func_ptr, 1);
389  free(flag);
390 
391  num_syms++;
392  }
393  rz_flag_space_pop(core->flags);
394 
395  return num_syms;
396 }

References add_new_func_symbol(), go_pc_line_table_t::big_endian, go_pc_line_table_t::filetab, rz_core_t::flags, free(), go_pc_line_table_t::functab, go_pc_line_table_t::functabsize, go_func_tab_field_size(), go_uintptr(), i, go_pc_line_table_t::io, is_pclntab_valid(), memset(), name, go_pc_line_table_t::nfiletab, go_pc_line_table_t::nfunctab, NULL, PFMT64x, go_pc_line_table_t::ptrsize, rz_core_notify_done(), rz_core_notify_error(), rz_flag_set(), RZ_FLAGS_FS_SYMBOLS, rz_io_nread_at(), RZ_LOG_ERROR, RZ_LOG_INFO, rz_name_filter(), rz_read_ble32(), rz_str_len_utf8_ansi(), rz_str_newf(), rz_strf, ut64(), and go_pc_line_table_t::vaddr.

Referenced by rz_core_analysis_recover_golang_functions().

◆ decode_auipc_set_addr()

static bool decode_auipc_set_addr ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 1496 of file golang.c.

1496  {
1497  RzAnalysisOp aop;
1498  rz_analysis_op_init(&aop);
1499  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
1500  rz_analysis_op_fini(&aop);
1501  return false;
1502  }
1503  info->addr = pc + aop.val;
1504  rz_analysis_op_fini(&aop);
1505  return true;
1506 }
RzBinInfo * info(RzBinFile *bf)
Definition: bin_ne.c:86
RZ_API bool rz_analysis_op_fini(RzAnalysisOp *op)
Definition: op.c:37
RZ_API void rz_analysis_op_init(RzAnalysisOp *op)
Definition: op.c:23
RZ_API int rz_analysis_op(RzAnalysis *analysis, RzAnalysisOp *op, ut64 addr, const ut8 *data, int len, RzAnalysisOpMask mask)
Definition: op.c:96
@ RZ_ANALYSIS_OP_MASK_DISASM
Definition: rz_analysis.h:445
Definition: buffer.h:15
RzAnalysis * analysis
Definition: rz_core.h:322

References rz_core_t::analysis, info(), pc, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), RZ_ANALYSIS_OP_MASK_DISASM, and rz_analysis_op_t::val.

◆ decode_disp_set_addr()

static bool decode_disp_set_addr ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 722 of file golang.c.

722  {
723  RzAnalysisOp aop;
724  rz_analysis_op_init(&aop);
725  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
726  rz_analysis_op_fini(&aop);
727  return false;
728  }
729  info->addr = aop.disp;
730  rz_analysis_op_fini(&aop);
731  return true;
732 }

References rz_core_t::analysis, rz_analysis_op_t::disp, info(), pc, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), and RZ_ANALYSIS_OP_MASK_DISASM.

◆ decode_from_table()

static bool decode_from_table ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 662 of file golang.c.

662  {
663  RzAnalysis *analysis = core->analysis;
664  ut8 tmp[16];
665  if (0 > rz_io_nread_at(core->io, info->addr, tmp, sizeof(tmp))) {
666  return false;
667  }
668  ut32 offset = analysis->bits / 8;
669  info->addr = rz_read_ble(tmp, analysis->big_endian, analysis->bits);
670  info->size = rz_read_ble(tmp + offset, analysis->big_endian, analysis->bits);
671  return true;
672 }
static ut64 rz_read_ble(const void *src, bool big_endian, int size)
Definition: rz_endian.h:517

References rz_core_t::analysis, rz_analysis_t::big_endian, rz_analysis_t::bits, info(), rz_core_t::io, rz_io_nread_at(), rz_read_ble(), and autogen_x86imm::tmp.

◆ decode_ldr_set_addr()

static bool decode_ldr_set_addr ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 1036 of file golang.c.

1036  {
1037  RzAnalysisOp aop;
1038  ut8 tmp[4];
1039  ut64 addr = 0;
1040 
1041  rz_analysis_op_init(&aop);
1042  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
1043  rz_analysis_op_fini(&aop);
1044  return false;
1045  }
1046  addr = aop.ptr;
1047  rz_analysis_op_fini(&aop);
1048 
1049  if (0 > rz_io_nread_at(core->io, addr, tmp, sizeof(tmp))) {
1050  return false;
1051  }
1052  info->addr = rz_read_ble32(tmp, core->analysis->big_endian);
1053  return true;
1054 }
static int addr
Definition: z80asm.c:58

References addr, rz_core_t::analysis, rz_analysis_t::big_endian, info(), rz_core_t::io, pc, rz_analysis_op_t::ptr, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), RZ_ANALYSIS_OP_MASK_DISASM, rz_io_nread_at(), rz_read_ble32(), autogen_x86imm::tmp, and ut64().

◆ decode_lui_set_addr()

static bool decode_lui_set_addr ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 1112 of file golang.c.

1112  {
1113  RzAnalysisOp aop;
1114  rz_analysis_op_init(&aop);
1115  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
1116  rz_analysis_op_fini(&aop);
1117  return false;
1118  }
1119  info->addr = aop.val;
1120  info->addr <<= 16;
1121  rz_analysis_op_fini(&aop);
1122  return true;
1123 }

References rz_core_t::analysis, info(), pc, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), RZ_ANALYSIS_OP_MASK_DISASM, and rz_analysis_op_t::val.

◆ decode_one_opcode_size()

static ut32 decode_one_opcode_size ( GoStrRecover ctx)
static

Definition at line 645 of file golang.c.

645  {
646  RzAnalysisOp aop;
647  rz_analysis_op_init(&aop);
648  if (rz_analysis_op(ctx->core->analysis, &aop, ctx->pc, ctx->bytes, ctx->size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
649  rz_analysis_op_fini(&aop);
650  return 0;
651  }
652  int size = aop.size;
653  rz_analysis_op_fini(&aop);
654  return size > 0 ? size : 0;
655 }

References rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), RZ_ANALYSIS_OP_MASK_DISASM, and rz_analysis_op_t::size.

Referenced by golang_recover_string_x64(), and golang_recover_string_x86().

◆ decode_ptr_set_addr()

static bool decode_ptr_set_addr ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 710 of file golang.c.

710  {
711  RzAnalysisOp aop;
712  rz_analysis_op_init(&aop);
713  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
714  rz_analysis_op_fini(&aop);
715  return false;
716  }
717  info->addr = aop.ptr;
718  rz_analysis_op_fini(&aop);
719  return true;
720 }

References rz_core_t::analysis, info(), pc, rz_analysis_op_t::ptr, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), and RZ_ANALYSIS_OP_MASK_DISASM.

◆ decode_val_add_addr()

static bool decode_val_add_addr ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 698 of file golang.c.

698  {
699  RzAnalysisOp aop;
700  rz_analysis_op_init(&aop);
701  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
702  rz_analysis_op_fini(&aop);
703  return false;
704  }
705  info->addr += aop.val;
706  rz_analysis_op_fini(&aop);
707  return true;
708 }

References rz_core_t::analysis, info(), pc, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), RZ_ANALYSIS_OP_MASK_DISASM, and rz_analysis_op_t::val.

◆ decode_val_set_addr()

static bool decode_val_set_addr ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 686 of file golang.c.

686  {
687  RzAnalysisOp aop;
688  rz_analysis_op_init(&aop);
689  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
690  rz_analysis_op_fini(&aop);
691  return false;
692  }
693  info->addr = aop.val;
694  rz_analysis_op_fini(&aop);
695  return true;
696 }

References rz_core_t::analysis, info(), pc, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), RZ_ANALYSIS_OP_MASK_DISASM, and rz_analysis_op_t::val.

◆ decode_val_set_size()

static bool decode_val_set_size ( RzCore core,
GoStrInfo info,
ut64  pc,
const ut8 buffer,
const ut32  size 
)
static

Definition at line 674 of file golang.c.

674  {
675  RzAnalysisOp aop;
676  rz_analysis_op_init(&aop);
677  if (rz_analysis_op(core->analysis, &aop, pc, buffer, size, RZ_ANALYSIS_OP_MASK_DISASM) < 1) {
678  rz_analysis_op_fini(&aop);
679  return false;
680  }
681  info->size = aop.val;
682  rz_analysis_op_fini(&aop);
683  return true;
684 }

References rz_core_t::analysis, info(), pc, rz_analysis_op(), rz_analysis_op_fini(), rz_analysis_op_init(), RZ_ANALYSIS_OP_MASK_DISASM, and rz_analysis_op_t::val.

◆ go_asm_pattern_define() [1/47]

go_asm_pattern_define ( arm  ,
32  ,
any  ,
"\x00\x00\x00\x00"  ,
"\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [2/47]

go_asm_pattern_define ( arm  ,
32  ,
ldr  ,
"\x00\x00\x9f\xe5"  ,
"\x00\x00\x9f\xe5"  ,
true   
)

◆ go_asm_pattern_define() [3/47]

go_asm_pattern_define ( arm  ,
32  ,
mov  ,
"\x00\x00\xa0\xe3"  ,
"\x00\x00\xa0\xe3"  ,
false   
)

◆ go_asm_pattern_define() [4/47]

go_asm_pattern_define ( arm  ,
64  ,
add  ,
"\x00\x00\x00\x01"  ,
"\x00\x00\x00\x6f"  ,
false   
)

◆ go_asm_pattern_define() [5/47]

go_asm_pattern_define ( arm  ,
64  ,
adrp  ,
"\x00\x00\x00\x80"  ,
"\x00\x00\x00\x8f"  ,
true   
)

◆ go_asm_pattern_define() [6/47]

go_asm_pattern_define ( arm  ,
64  ,
any  ,
"\x00\x00\x00\x00"  ,
"\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [7/47]

go_asm_pattern_define ( arm  ,
64  ,
movz  ,
"\x00\x00\x80\x42"  ,
"\x00\x00\x80\x6f"  ,
false   
)

◆ go_asm_pattern_define() [8/47]

go_asm_pattern_define ( arm  ,
64  ,
orr  ,
"\x00\x00\x00\x22"  ,
"\x00\x00\x80\x6f"  ,
false   
)

◆ go_asm_pattern_define() [9/47]

go_asm_pattern_define ( mips  ,
32  ,
any  ,
"\x00\x00\x00\x00"  ,
"\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [10/47]

go_asm_pattern_define ( mips  ,
64  ,
any  ,
"\x00\x00\x00\x00"  ,
"\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [11/47]

go_asm_pattern_define ( mipsbe  ,
32  ,
addiu  ,
"\x24\x00\x00\x00"  ,
"\xff\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [12/47]

go_asm_pattern_define ( mipsbe  ,
32  ,
lui  ,
"\x3c\x00\x00\x00"  ,
"\xff\x00\x00\x00"  ,
true   
)

◆ go_asm_pattern_define() [13/47]

go_asm_pattern_define ( mipsbe  ,
64  ,
daddiu  ,
"\x64\x00\x00\x00"  ,
"\xfc\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [14/47]

go_asm_pattern_define ( mipsbe  ,
64  ,
daddu  ,
"\x00\x00\x00\x2d"  ,
"\x00\x00\x00\xff"  ,
false   
)

◆ go_asm_pattern_define() [15/47]

go_asm_pattern_define ( mipsbe  ,
64  ,
lui  ,
"\x3c\x00\x00\x00"  ,
"\xff\x00\x00\x00"  ,
true   
)

◆ go_asm_pattern_define() [16/47]

go_asm_pattern_define ( mipsbe  ,
64  ,
move  ,
"\x64\x00\x00\x00"  ,
"\xff\xe0\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [17/47]

go_asm_pattern_define ( mipsle  ,
32  ,
addiu  ,
"\x00\x00\x00\x24"  ,
"\x00\x00\x00\xff"  ,
false   
)

◆ go_asm_pattern_define() [18/47]

go_asm_pattern_define ( mipsle  ,
32  ,
lui  ,
"\x00\x00\x00\x3c"  ,
"\x00\x00\x00\xff"  ,
true   
)

◆ go_asm_pattern_define() [19/47]

go_asm_pattern_define ( mipsle  ,
64  ,
daddiu  ,
"\x00\x00\x00\x64"  ,
"\x00\x00\x00\xfc"  ,
false   
)

◆ go_asm_pattern_define() [20/47]

go_asm_pattern_define ( mipsle  ,
64  ,
daddu  ,
"\x2d\x00\x00\x00"  ,
"\xff\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [21/47]

go_asm_pattern_define ( mipsle  ,
64  ,
lui  ,
"\x00\x00\x00\x3c"  ,
"\x00\x00\x00\xff"  ,
true   
)

◆ go_asm_pattern_define() [22/47]

go_asm_pattern_define ( mipsle  ,
64  ,
move  ,
"\x00\x00\x00\x64"  ,
"\x00\x00\xe0\xff"  ,
false   
)

◆ go_asm_pattern_define() [23/47]

go_asm_pattern_define ( ppc  ,
64  ,
any  ,
"\x00\x00\x00\x00"  ,
"\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [24/47]

go_asm_pattern_define ( ppcbe  ,
64  ,
addi  ,
"\x38\x00\x00\x00"  ,
"\xfc\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [25/47]

go_asm_pattern_define ( ppcbe  ,
64  ,
li  ,
"\x38\x00\x00\x00"  ,
"\xfc\x1f\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [26/47]

go_asm_pattern_define ( ppcbe  ,
64  ,
lis  ,
"\x3c\x00\x00\x00"  ,
"\xfc\x00\x00\x00"  ,
true   
)

◆ go_asm_pattern_define() [27/47]

go_asm_pattern_define ( ppcle  ,
64  ,
addi  ,
"\x00\x00\x00\x38"  ,
"\x00\x00\x00\xfc"  ,
false   
)

◆ go_asm_pattern_define() [28/47]

go_asm_pattern_define ( ppcle  ,
64  ,
li  ,
"\x00\x00\x00\x38"  ,
"\x00\x00\x1f\xfc"  ,
false   
)

◆ go_asm_pattern_define() [29/47]

go_asm_pattern_define ( ppcle  ,
64  ,
lis  ,
"\x00\x00\x00\x3c"  ,
"\x00\x00\x00\xfc"  ,
true   
)

◆ go_asm_pattern_define() [30/47]

go_asm_pattern_define ( riscv  ,
64  ,
addi  ,
"\x13\x00\x00\x00"  ,
"\x7f\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [31/47]

go_asm_pattern_define ( riscv  ,
64  ,
addiw  ,
"\x1b\x00\x00\x00"  ,
"\x7f\x70\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [32/47]

go_asm_pattern_define ( riscv  ,
64  ,
any  ,
"\x00\x00\x00\x00"  ,
"\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [33/47]

go_asm_pattern_define ( riscv  ,
64  ,
auipc  ,
"\x17\x00\x00\x00"  ,
"\x7f\x00\x00\x00"  ,
true   
)

◆ go_asm_pattern_define() [34/47]

go_asm_pattern_define ( riscv  ,
64  ,
li  ,
"\x13\x00\x00\x00"  ,
"\x7f\x80\x0F\x00"  ,
false   
)

◆ go_asm_pattern_define() [35/47]

go_asm_pattern_define ( x86  ,
32  ,
lea  ,
"\x8d\x00\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00\x00"  ,
true   
)

◆ go_asm_pattern_define() [36/47]

go_asm_pattern_define ( x86  ,
32  ,
mov_imm0  ,
"\xc7\x00\x00\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [37/47]

go_asm_pattern_define ( x86  ,
32  ,
mov_imm1  ,
"\xc7\x00\x00\x00\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [38/47]

go_asm_pattern_define ( x86  ,
32  ,
mov_reg0  ,
"\x89\x00\x00"  ,
"\xff\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [39/47]

go_asm_pattern_define ( x86  ,
32  ,
mov_reg1  ,
"\x89\x00\x00\x00"  ,
"\xff\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [40/47]

go_asm_pattern_define ( x86  ,
64  ,
lea  ,
"\x48\x00\x00\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00\x00\x00"  ,
true   
)

◆ go_asm_pattern_define() [41/47]

go_asm_pattern_define ( x86  ,
64  ,
mov_imm0  ,
"\xb9\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [42/47]

go_asm_pattern_define ( x86  ,
64  ,
mov_imm1  ,
"\x48\xc7\x00\x00\x00\x00\x00\x00"  ,
"\xff\xff\x00\x00\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [43/47]

go_asm_pattern_define ( x86  ,
64  ,
mov_imm2  ,
"\x41\x00\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [44/47]

go_asm_pattern_define ( x86  ,
64  ,
mov_imm3  ,
"\xbb\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [45/47]

go_asm_pattern_define ( x86  ,
64  ,
mov_imm4  ,
"\xbf\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [46/47]

go_asm_pattern_define ( x86  ,
64  ,
mov_reg0  ,
"\x48\x00\x00\x00"  ,
"\xff\x00\x00\x00"  ,
false   
)

◆ go_asm_pattern_define() [47/47]

go_asm_pattern_define ( x86  ,
64  ,
mov_reg1  ,
"\x48\x00\x00\x00\x00"  ,
"\xff\x00\x00\x00\x00"  ,
false   
)

◆ go_data()

ut64 go_data ( GoPcLnTab pclntab,
ut32  n_word 
)

Definition at line 95 of file golang.c.

95  {
96  ut64 offset = go_offset(pclntab, n_word);
97  if (offset == UT64_MAX) {
98  return UT64_MAX;
99  }
100  return pclntab->vaddr + offset;
101 }
#define UT64_MAX
Definition: rz_types_base.h:86

References go_offset(), ut64(), UT64_MAX, and go_pc_line_table_t::vaddr.

Referenced by core_recover_golang_functions_go_1_16(), and core_recover_golang_functions_go_1_18().

◆ go_func_tab_field_size()

ut32 go_func_tab_field_size ( GoPcLnTab pclntab)

Definition at line 72 of file golang.c.

72  {
73  if (pclntab->version >= GO_1_18) {
74  return 4;
75  }
76  return pclntab->ptrsize;
77 }
#define GO_1_18
Definition: golang.c:10

References GO_1_18, go_pc_line_table_t::ptrsize, and go_pc_line_table_t::version.

Referenced by core_recover_golang_functions_go_1_16(), core_recover_golang_functions_go_1_18(), and core_recover_golang_functions_go_1_2().

◆ go_is_sign_match()

static bool go_is_sign_match ( GoStrRecover ctx,
GoStrInfo info,
GoSignature sigs,
const size_t  n_sigs 
)
static

Definition at line 599 of file golang.c.

599  {
600  ut8 copy[32]; // big enough to handle any pattern.
601  ut32 nlen = 0;
602  memset(info, 0, sizeof(GoStrInfo));
603 
604  for (size_t i = 0; i < n_sigs; ++i) {
605  if (nlen >= ctx->size) {
606  return false;
607  }
608 
609  GoSignature *sig = &sigs[i];
610  ut8 *bytes = ctx->bytes + nlen;
611  ut32 size = ctx->size - nlen;
612  if (sig->pasm->size > size) {
613  return false;
614  }
615 
616  // copy opcodes
617  memcpy(copy, bytes, sig->pasm->size);
618 
619  // apply mask
620  for (ut32 j = 0; j < sig->pasm->size; ++j) {
621  copy[j] = copy[j] & sig->pasm->mask[j];
622  }
623 
624  // verify the masked input matches the pattern
625  if (memcmp(copy, sig->pasm->pattern, sig->pasm->size)) {
626  return false;
627  }
628 
629  // decode info
630  if (sig->decode && !sig->decode(ctx->core, info, ctx->pc + nlen, bytes, size)) {
631  return false;
632  }
633 
634  // sets from where the xrefs starts.
635  if (sig->pasm->xrefs) {
636  info->xref = ctx->pc + nlen;
637  }
638 
639  nlen += sig->pasm->size;
640  }
641 
642  return true;
643 }
static ut8 bytes[32]
Definition: asm_arc.c:23
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
const ut8 * pattern
Definition: golang.c:57
const ut8 * mask
Definition: golang.c:58
GoAsmPattern * pasm
Definition: golang.c:66
GoDecodeCb decode
Definition: golang.c:67

References bytes, go_signature_t::decode, i, info(), go_asm_pattern_t::mask, memcpy(), memset(), go_signature_t::pasm, go_asm_pattern_t::pattern, go_asm_pattern_t::size, and go_asm_pattern_t::xrefs.

◆ go_offset()

ut64 go_offset ( GoPcLnTab pclntab,
ut32  n_word 
)

Definition at line 86 of file golang.c.

86  {
87  ut8 bytes[8];
88  ut64 location = pclntab->vaddr + 8 + (n_word * pclntab->ptrsize);
89  if (0 > rz_io_nread_at(pclntab->io, location, bytes, sizeof(bytes))) {
90  return UT64_MAX;
91  }
92  return go_uintptr(pclntab, bytes);
93 }

References bytes, go_uintptr(), go_pc_line_table_t::io, go_pc_line_table_t::ptrsize, rz_io_nread_at(), ut64(), UT64_MAX, and go_pc_line_table_t::vaddr.

Referenced by core_recover_golang_functions_go_1_16(), core_recover_golang_functions_go_1_18(), and go_data().

◆ go_uintptr()

ut64 go_uintptr ( GoPcLnTab pclntab,
ut8 bytes 
)

Definition at line 79 of file golang.c.

79  {
80  if (pclntab->ptrsize == 4) {
81  return rz_read_ble32(bytes, pclntab->big_endian);
82  }
83  return rz_read_ble64(bytes, pclntab->big_endian);
84 }
static ut64 rz_read_ble64(const void *src, bool big_endian)
Definition: rz_endian.h:501

References go_pc_line_table_t::big_endian, bytes, go_pc_line_table_t::ptrsize, rz_read_ble32(), and rz_read_ble64().

Referenced by core_recover_golang_functions_go_1_16(), core_recover_golang_functions_go_1_18(), core_recover_golang_functions_go_1_2(), and go_offset().

◆ golang_recover_string_arm32()

static ut32 golang_recover_string_arm32 ( GoStrRecover ctx)
static

Definition at line 1092 of file golang.c.

1092  {
1093  RzAnalysis *analysis = ctx->core->analysis;
1094  GoStrInfo info = { 0 };
1095 
1100  return 4;
1101  }
1102 
1103  // try to recover the string.
1104  if (!recover_string_at(ctx, info.addr, info.size)) {
1105  return 4;
1106  }
1107 
1109  return 4;
1110 }
static bool recover_string_at(GoStrRecover *ctx, ut64 str_addr, ut64 str_size)
Definition: golang.c:527
static GoSignature go_arm32_ldr_mov_signature[]
Definition: golang.c:1078
#define go_is_sign_match_autosize(ctx, info, sigs)
Definition: golang.c:657
static GoSignature go_arm32_mov_str_ldr_signature[]
Definition: golang.c:1069
static GoSignature go_arm32_table_signature[]
Definition: golang.c:1085
static GoSignature go_arm32_ldr_str_mov_signature[]
Definition: golang.c:1060
@ RZ_ANALYSIS_XREF_TYPE_STRING
Definition: rz_analysis.h:903
RZ_API bool rz_analysis_xrefs_set(RzAnalysis *analysis, ut64 from, ut64 to, RzAnalysisXRefType type)
Definition: xrefs.c:117

References go_arm32_ldr_mov_signature, go_arm32_ldr_str_mov_signature, go_arm32_mov_str_ldr_signature, go_arm32_table_signature, go_is_sign_match_autosize, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ golang_recover_string_arm64()

static ut32 golang_recover_string_arm64 ( GoStrRecover ctx)
static

Definition at line 1013 of file golang.c.

1013  {
1014  RzAnalysis *analysis = ctx->core->analysis;
1015  GoStrInfo info = { 0 };
1016 
1024  return 4;
1025  }
1026 
1027  // try to recover the string.
1028  if (!recover_string_at(ctx, info.addr, info.size)) {
1029  return 4;
1030  }
1031 
1033  return 4;
1034 }
static GoSignature go_arm64_adrp_add_str_movz_signature[]
Definition: golang.c:953
static GoSignature go_arm64_movz_str_adrp_add_signature[]
Definition: golang.c:975
static GoSignature go_arm64_adrp_add_movz_signature[]
Definition: golang.c:995
static GoSignature go_arm64_table_signature[]
Definition: golang.c:1004
static GoSignature go_arm64_orr_str_adrp_add_signature[]
Definition: golang.c:964
static GoSignature go_arm64_adrp_add_orr_signature[]
Definition: golang.c:986
static GoSignature go_arm64_adrp_add_str_orr_signature[]
Definition: golang.c:942

References go_arm64_adrp_add_movz_signature, go_arm64_adrp_add_orr_signature, go_arm64_adrp_add_str_movz_signature, go_arm64_adrp_add_str_orr_signature, go_arm64_movz_str_adrp_add_signature, go_arm64_orr_str_adrp_add_signature, go_arm64_table_signature, go_is_sign_match_autosize, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ golang_recover_string_mips32()

static ut32 golang_recover_string_mips32 ( GoStrRecover ctx)
static

Definition at line 1213 of file golang.c.

1213  {
1214  RzAnalysis *analysis = ctx->core->analysis;
1215  GoStrInfo info = { 0 };
1216 
1217  if (analysis->big_endian &&
1222  return 4;
1223  } else if (!analysis->big_endian &&
1228  return 4;
1229  }
1230 
1231  // try to recover the string.
1232  if (!recover_string_at(ctx, info.addr, info.size)) {
1233  return 4;
1234  }
1235 
1237  return 4;
1238 }
static GoSignature go_mipsbe32_table_signature[]
Definition: golang.c:1204
static GoSignature go_mipsle32_table_signature[]
Definition: golang.c:1163
static GoSignature go_mipsle32_lui_addiu_sw_addiu_signature[]
Definition: golang.c:1132
static GoSignature go_mipsbe32_addiu_sw_lui_addiu_signature[]
Definition: golang.c:1184
static GoSignature go_mipsle32_addiu_sw_lui_addiu_signature[]
Definition: golang.c:1143
static GoSignature go_mipsle32_lui_addiu_addiu_signature[]
Definition: golang.c:1154
static GoSignature go_mipsbe32_lui_addiu_sw_addiu_signature[]
Definition: golang.c:1173
static GoSignature go_mipsbe32_lui_addiu_addiu_signature[]
Definition: golang.c:1195

References rz_analysis_t::big_endian, go_is_sign_match_autosize, go_mipsbe32_addiu_sw_lui_addiu_signature, go_mipsbe32_lui_addiu_addiu_signature, go_mipsbe32_lui_addiu_sw_addiu_signature, go_mipsbe32_table_signature, go_mipsle32_addiu_sw_lui_addiu_signature, go_mipsle32_lui_addiu_addiu_signature, go_mipsle32_lui_addiu_sw_addiu_signature, go_mipsle32_table_signature, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ golang_recover_string_mips64()

static ut32 golang_recover_string_mips64 ( GoStrRecover ctx)
static

Definition at line 1348 of file golang.c.

1348  {
1349  RzAnalysis *analysis = ctx->core->analysis;
1350  GoStrInfo info = { 0 };
1351 
1352  if (analysis->big_endian &&
1357  return 4;
1358  } else if (!analysis->big_endian &&
1363  return 4;
1364  }
1365 
1366  // try to recover the string.
1367  if (!recover_string_at(ctx, info.addr, info.size)) {
1368  return 4;
1369  }
1370 
1372  return 4;
1373 }
static GoSignature go_mipsle64_daddiu_sd_lui_daddu_daddiu_signature[]
Definition: golang.c:1264
static GoSignature go_mipsle64_table_signature[]
Definition: golang.c:1288
static GoSignature go_mipsbe64_lui_daddu_daddiu_daddiu_signature[]
Definition: golang.c:1326
static GoSignature go_mipsle64_lui_daddu_daddiu_sd_daddiu_signature[]
Definition: golang.c:1251
static GoSignature go_mipsle64_lui_daddu_daddiu_daddiu_signature[]
Definition: golang.c:1277
static GoSignature go_mipsbe64_lui_daddu_daddiu_sd_daddiu_signature[]
Definition: golang.c:1300
static GoSignature go_mipsbe64_daddiu_sd_lui_daddu_daddiu_signature[]
Definition: golang.c:1313
static GoSignature go_mipsbe64_table_signature[]
Definition: golang.c:1337

References rz_analysis_t::big_endian, go_is_sign_match_autosize, go_mipsbe64_daddiu_sd_lui_daddu_daddiu_signature, go_mipsbe64_lui_daddu_daddiu_daddiu_signature, go_mipsbe64_lui_daddu_daddiu_sd_daddiu_signature, go_mipsbe64_table_signature, go_mipsle64_daddiu_sd_lui_daddu_daddiu_signature, go_mipsle64_lui_daddu_daddiu_daddiu_signature, go_mipsle64_lui_daddu_daddiu_sd_daddiu_signature, go_mipsle64_table_signature, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ golang_recover_string_ppc64()

static ut32 golang_recover_string_ppc64 ( GoStrRecover ctx)
static

Definition at line 1465 of file golang.c.

1465  {
1466  RzAnalysis *analysis = ctx->core->analysis;
1467  GoStrInfo info = { 0 };
1468 
1469  if (analysis->big_endian &&
1473  return 4;
1474  } else if (!analysis->big_endian &&
1478  return 4;
1479  }
1480 
1481  // try to recover the string.
1482  if (!recover_string_at(ctx, info.addr, info.size)) {
1484  return 4;
1486  return 4;
1487  } else if (!recover_string_at(ctx, info.addr, info.size)) {
1488  return 4;
1489  }
1490  }
1491 
1493  return 4;
1494 }
static GoSignature go_ppcle64_li_std_lis_addi_signature[]
Definition: golang.c:1395
static GoSignature go_ppcbe64_lis_addi_std_li_signature[]
Definition: golang.c:1425
static GoSignature go_ppcle64_lis_addi_li_signature[]
Definition: golang.c:1406
static GoSignature go_ppcbe64_li_std_lis_addi_signature[]
Definition: golang.c:1436
static GoSignature go_ppcbe64_table_signature[]
Definition: golang.c:1456
static GoSignature go_ppcle64_lis_addi_std_li_signature[]
Definition: golang.c:1384
static GoSignature go_ppcbe64_lis_addi_li_signature[]
Definition: golang.c:1447
static GoSignature go_ppcle64_table_signature[]
Definition: golang.c:1415

References rz_analysis_t::big_endian, go_is_sign_match_autosize, go_ppcbe64_li_std_lis_addi_signature, go_ppcbe64_lis_addi_li_signature, go_ppcbe64_lis_addi_std_li_signature, go_ppcbe64_table_signature, go_ppcle64_li_std_lis_addi_signature, go_ppcle64_lis_addi_li_signature, go_ppcle64_lis_addi_std_li_signature, go_ppcle64_table_signature, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ golang_recover_string_riscv64()

static ut32 golang_recover_string_riscv64 ( GoStrRecover ctx)
static

Definition at line 1585 of file golang.c.

1585  {
1586  RzAnalysis *analysis = ctx->core->analysis;
1587  GoStrInfo info = { 0 };
1588 
1596  return 4;
1597  }
1598 
1599  // try to recover the string.
1600  if (!recover_string_at(ctx, info.addr, info.size)) {
1601  return 4;
1602  }
1603 
1605  return 4;
1606 }
static GoSignature go_riscv64_li_sd_auipc_add_signature[]
Definition: golang.c:1536
static GoSignature go_riscv64_table_signature[]
Definition: golang.c:1576
static GoSignature go_riscv64_auipc_add_addiw_signature[]
Definition: golang.c:1558
static GoSignature go_riscv64_addiw_sd_auipc_add_signature[]
Definition: golang.c:1547
static GoSignature go_riscv64_auipc_add_li_signature[]
Definition: golang.c:1567
static GoSignature go_riscv64_auipc_add_sd_addiw_signature[]
Definition: golang.c:1514
static GoSignature go_riscv64_auipc_add_sd_li_signature[]
Definition: golang.c:1525

References go_is_sign_match_autosize, go_riscv64_addiw_sd_auipc_add_signature, go_riscv64_auipc_add_addiw_signature, go_riscv64_auipc_add_li_signature, go_riscv64_auipc_add_sd_addiw_signature, go_riscv64_auipc_add_sd_li_signature, go_riscv64_li_sd_auipc_add_signature, go_riscv64_table_signature, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ golang_recover_string_x64()

static ut32 golang_recover_string_x64 ( GoStrRecover ctx)
static

Definition at line 832 of file golang.c.

832  {
833  RzAnalysis *analysis = ctx->core->analysis;
835  GoStrInfo info = { 0 };
836 
849  return oplen;
850  }
851 
852  // try to recover the string.
853  if (!recover_string_at(ctx, info.addr, info.size)) {
854  return oplen;
855  }
856 
858  return oplen;
859 }
static GoSignature go_x64_mov3_lea_signature[]
Definition: golang.c:811
static GoSignature go_x64_lea_mov2_signature[]
Definition: golang.c:776
static ut32 decode_one_opcode_size(GoStrRecover *ctx)
Definition: golang.c:645
static GoSignature go_x64_lea_mov1_mov_signature[]
Definition: golang.c:753
static GoSignature go_x64_table1_signature[]
Definition: golang.c:825
static GoSignature go_x64_table0_signature[]
Definition: golang.c:818
static GoSignature go_x64_lea_mov3_signature[]
Definition: golang.c:783
static GoSignature go_x64_mov1_lea_signature[]
Definition: golang.c:797
static GoSignature go_x64_lea_mov0_mov_signature[]
Definition: golang.c:744
static GoSignature go_x64_lea_mov0_signature[]
Definition: golang.c:762
static GoSignature go_x64_mov2_lea_signature[]
Definition: golang.c:804
static GoSignature go_x64_mov0_lea_signature[]
Definition: golang.c:790
static GoSignature go_x64_lea_mov1_signature[]
Definition: golang.c:769

References decode_one_opcode_size(), go_is_sign_match_autosize, go_x64_lea_mov0_mov_signature, go_x64_lea_mov0_signature, go_x64_lea_mov1_mov_signature, go_x64_lea_mov1_signature, go_x64_lea_mov2_signature, go_x64_lea_mov3_signature, go_x64_mov0_lea_signature, go_x64_mov1_lea_signature, go_x64_mov2_lea_signature, go_x64_mov3_lea_signature, go_x64_table0_signature, go_x64_table1_signature, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ golang_recover_string_x86()

static ut32 golang_recover_string_x86 ( GoStrRecover ctx)
static

Definition at line 913 of file golang.c.

913  {
914  RzAnalysis *analysis = ctx->core->analysis;
916  GoStrInfo info = { 0 };
917 
924  return oplen;
925  }
926 
927  // try to recover the string.
928  if (!recover_string_at(ctx, info.addr, info.size)) {
929  return oplen;
930  }
931 
933  return oplen;
934 }
static GoSignature go_x86_table_signature[]
Definition: golang.c:906
static GoSignature go_x86_lea_mov0_mov_signature[]
Definition: golang.c:867
static GoSignature go_x86_lea_mov1_signature[]
Definition: golang.c:892
static GoSignature go_x86_lea_mov1_mov_signature[]
Definition: golang.c:876
static GoSignature go_x86_mov_lea_signature[]
Definition: golang.c:899
static GoSignature go_x86_lea_mov0_signature[]
Definition: golang.c:885

References decode_one_opcode_size(), go_is_sign_match_autosize, go_x86_lea_mov0_mov_signature, go_x86_lea_mov0_signature, go_x86_lea_mov1_mov_signature, go_x86_lea_mov1_signature, go_x86_mov_lea_signature, go_x86_table_signature, info(), recover_string_at(), RZ_ANALYSIS_XREF_TYPE_STRING, and rz_analysis_xrefs_set().

Referenced by rz_core_analysis_resolve_golang_strings().

◆ is_pclntab_valid()

static bool is_pclntab_valid ( GoPcLnTab pclntab)
static

Definition at line 104 of file golang.c.

104  {
105  ut64 begin = pclntab->vaddr + 8;
106  ut64 end = pclntab->vaddr + pclntab->size;
107 
108  if (pclntab->version > GO_1_2) {
109  if (is_addr_outside(pclntab->funcnametab)) {
110  return false;
111  } else if (is_addr_outside(pclntab->cutab)) {
112  return false;
113  } else if (is_addr_outside(pclntab->pctab)) {
114  return false;
115  } else if (is_addr_outside(pclntab->funcdata)) {
116  return false;
117  }
118  }
119 
120  if (pclntab->version >= GO_1_18 && !pclntab->text_start) {
121  return false;
122  }
123 
124  if (is_addr_outside(pclntab->filetab)) {
125  return false;
126  } else if (is_addr_outside(pclntab->functab)) {
127  return false;
128  } else if (pclntab->functabsize >= (pclntab->size - 8)) {
129  return false;
130  }
131 
132  return true;
133 }
#define is_addr_outside(x)
Definition: golang.c:103
#define GO_1_2
Definition: golang.c:8

References go_pc_line_table_t::cutab, test_evm::end, go_pc_line_table_t::filetab, go_pc_line_table_t::funcdata, go_pc_line_table_t::funcnametab, go_pc_line_table_t::functab, go_pc_line_table_t::functabsize, GO_1_18, GO_1_2, is_addr_outside, go_pc_line_table_t::pctab, go_pc_line_table_t::size, go_pc_line_table_t::text_start, ut64(), go_pc_line_table_t::vaddr, and go_pc_line_table_t::version.

Referenced by core_recover_golang_functions_go_1_16(), core_recover_golang_functions_go_1_18(), and core_recover_golang_functions_go_1_2().

◆ recover_string_at()

static bool recover_string_at ( GoStrRecover ctx,
ut64  str_addr,
ut64  str_size 
)
static

Definition at line 527 of file golang.c.

527  {
528  // check that the values are acceptable.
529  if (str_size < 2 || str_size > GO_MAX_STRING_SIZE || str_addr < 1 || str_addr == UT64_MAX) {
530  return false;
531  }
532 
533  RzBinObject *obj = rz_bin_cur_object(ctx->core->bin);
534  if (!obj || !rz_bin_get_section_at(obj, str_addr, true)) {
535  // skip any possible string from invalid sections.
536  return false;
537  }
538 
539  const size_t n_prefix = strlen("str.");
540  // string size + strlen('str.') + \0
541  char *flag = malloc(str_size + n_prefix + 1);
542  char *raw = malloc(str_size + 1);
543  if (!flag || !raw) {
544  RZ_LOG_ERROR("Cannot allocate buffer to read string.");
545  free(flag);
546  free(raw);
547  return false;
548  }
549 
550  // set prefix and zero-terminator
551  flag[0] = 's';
552  flag[1] = 't';
553  flag[2] = 'r';
554  flag[3] = '.';
555  flag[str_size + 4] = 0;
556  raw[str_size] = 0;
557 
558  if (0 > rz_io_nread_at(ctx->core->io, str_addr, (ut8 *)raw, str_size)) {
559  RZ_LOG_ERROR("Failed to read string value at address %" PFMT64x "\n", str_addr);
560  free(flag);
561  free(raw);
562  return false;
563  } else if (rz_str_len_utf8_ansi(raw) != str_size) {
564  free(flag);
565  free(raw);
566  return false;
567  }
568  memcpy(flag + n_prefix, raw, str_size);
569 
570  // apply any filter to the new flag name
571  rz_name_filter(flag + n_prefix, str_size, true);
572 
573  // verify is a valid flag.
574  if (rz_str_len_utf8_ansi(flag) < 5) {
575  free(flag);
576  free(raw);
577  return false;
578  }
579 
580  // add new string to string list (raw is freed/owned by add_new_bin_string)
581  if (!add_new_bin_string(ctx->core, raw, str_addr, str_size)) {
582  free(flag);
583  return false;
584  }
585 
586  // remove any flag already set at this address
587  rz_flag_unset_all_off(ctx->core->flags, str_addr);
588 
589  // add string to string flag space.
590  rz_flag_space_push(ctx->core->flags, RZ_FLAGS_FS_STRINGS);
591  rz_flag_set(ctx->core->flags, flag, str_addr, str_size);
592  rz_flag_space_pop(ctx->core->flags);
593  free(flag);
594  ctx->n_recovered++;
595 
596  return true;
597 }
RZ_API RzBinObject * rz_bin_cur_object(RzBin *bin)
Definition: bin.c:900
RZ_API RZ_BORROW RzBinSection * rz_bin_get_section_at(RzBinObject *o, ut64 off, int va)
Find the binary section at offset off.
Definition: bin.c:611
#define GO_MAX_STRING_SIZE
Definition: golang.c:6
static bool add_new_bin_string(RzCore *core, char *string, ut64 vaddr, ut32 size)
Definition: golang.c:486
RZ_API bool rz_flag_unset_all_off(RzFlag *f, ut64 off)
Definition: flag.c:635
void * malloc(size_t size)
Definition: malloc.c:123
#define RZ_FLAGS_FS_STRINGS
Definition: rz_core.h:66

References add_new_bin_string(), free(), GO_MAX_STRING_SIZE, malloc(), memcpy(), PFMT64x, rz_bin_cur_object(), rz_bin_get_section_at(), rz_flag_set(), rz_flag_unset_all_off(), RZ_FLAGS_FS_STRINGS, rz_io_nread_at(), RZ_LOG_ERROR, rz_name_filter(), rz_str_len_utf8_ansi(), and UT64_MAX.

Referenced by golang_recover_string_arm32(), golang_recover_string_arm64(), golang_recover_string_mips32(), golang_recover_string_mips64(), golang_recover_string_ppc64(), golang_recover_string_riscv64(), golang_recover_string_x64(), and golang_recover_string_x86().

◆ rz_core_analysis_recover_golang_functions()

RZ_API bool rz_core_analysis_recover_golang_functions ( RzCore core)

reads pclntab table in go binaries and recovers functions. Follows the code https://github.com/golang/go/blob/master/src/debug/gosym/pclntab.go#L188

Parameters
coreThe RzCore to use
Returns
Returns true when 1 or more symbols have been recovered.

Definition at line 405 of file golang.c.

405  {
406  rz_return_val_if_fail(core && core->bin && core->io, false);
407 
408  RzList *section_list = rz_bin_get_sections(core->bin);
409  RzList *symbols_list = rz_bin_get_symbols(core->bin);
410  RzListIter *iter;
412  ut32 num_syms = 0;
413  GoPcLnTab pclntab = { 0 };
414  ut8 header[8] = { 0 };
415 
416  rz_list_foreach (section_list, iter, section) {
417  // on ELF files the pclntab sections is named .gopclntab, but on macho is __gopclntab
418  if (section->vsize >= 16 && strstr(section->name, "gopclntab")) {
419  pclntab.vaddr = section->vaddr;
420  pclntab.size = section->vsize;
421  } else if (!pclntab.text_start &&
422  (!strcmp(section->name, ".text") || strstr(section->name, "__text"))) {
423  pclntab.text_start = section->vaddr;
424  }
425  }
426 
427  if (!pclntab.vaddr) {
428  RzBinSymbol *symbol;
429  rz_list_foreach (symbols_list, iter, symbol) {
430  // on PE files the pclntab sections is inside .rdata, so rizin creates a symbol for it
431  if (symbol->size >= 16 && !strcmp(symbol->name, "gopclntab")) {
432  pclntab.vaddr = symbol->vaddr;
433  pclntab.size = symbol->size;
434  break;
435  }
436  }
437  }
438 
439  if (!pclntab.vaddr) {
440  rz_core_notify_done(core, "Could not find go pclntab section");
441  return false;
442  } else if (0 > rz_io_nread_at(core->io, pclntab.vaddr, header, sizeof(header))) {
443  RZ_LOG_ERROR("Failed to read gopclntab at address %" PFMT64x "\n", pclntab.vaddr);
444  return false;
445  } else if (header[4] != 0 || header[5] != 0 ||
446  (header[6] != 1 && header[6] != 2 && header[6] != 4) || // pc quantum
447  (header[7] != 4 && header[7] != 8)) { // pointer size
448  rz_core_notify_error(core, "Invalid go pclntab (invalid pc quantum or pointer size).");
449  return false;
450  }
451 
452  pclntab.io = core->io;
453  pclntab.quantum = header[6];
454  pclntab.ptrsize = header[7];
455 
457  pclntab.version = GO_1_18;
459  num_syms = core_recover_golang_functions_go_1_18(core, &pclntab);
461  pclntab.version = GO_1_16;
463  num_syms = core_recover_golang_functions_go_1_16(core, &pclntab);
465  pclntab.version = GO_1_2;
467  num_syms = core_recover_golang_functions_go_1_2(core, &pclntab);
468  } else {
469  ut32 magic = rz_read_be32(header);
470  rz_core_notify_error(core, "Invalid go pclntab (unknown version: 0x%x).", magic);
471  return false;
472  }
473 
474  if (num_syms) {
475  rz_core_notify_done(core, "Recovered %u symbols and saved them at sym.go.*", num_syms);
476  rz_core_notify_begin(core, "Analyze all flags starting with sym.go. (aF @@f:sym.go.*)");
477  rz_core_cmd0(core, "aF @@f:sym.go.*");
478  rz_core_notify_done(core, "Analyze all flags starting with sym.go. (aF @@f:sym.go.*)");
479  return true;
480  }
481 
482  rz_core_notify_error(core, "Could not recover any symbol from the go pclntab.");
483  return false;
484 }
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_symbols(RZ_NONNULL RzBin *bin)
Definition: bin.c:696
RZ_DEPRECATE RZ_API RZ_BORROW RzList * rz_bin_get_sections(RZ_NONNULL RzBin *bin)
Definition: bin.c:597
RZ_API int rz_core_cmd0(RzCore *core, const char *cmd)
Definition: cmd.c:5428
#define IS_GOPCLNTAB_1_2_LE(x)
Definition: golang.c:12
#define IS_GOPCLNTAB_1_16_BE(x)
Definition: golang.c:15
static ut32 core_recover_golang_functions_go_1_2(RzCore *core, GoPcLnTab *pclntab)
Definition: golang.c:312
#define IS_GOPCLNTAB_1_18_BE(x)
Definition: golang.c:17
static ut32 core_recover_golang_functions_go_1_18(RzCore *core, GoPcLnTab *pclntab)
Definition: golang.c:160
static ut32 core_recover_golang_functions_go_1_16(RzCore *core, GoPcLnTab *pclntab)
Definition: golang.c:235
#define GO_1_16
Definition: golang.c:9
#define IS_GOPCLNTAB_1_2_BE(x)
Definition: golang.c:13
#define IS_GOPCLNTAB_1_18_LE(x)
Definition: golang.c:16
#define IS_GOPCLNTAB_1_16_LE(x)
Definition: golang.c:14
RZ_API void rz_core_notify_begin(RZ_NONNULL RzCore *core, RZ_NONNULL const char *format,...)
Prints a message definining the beginning of a task.
Definition: core.c:33
#define header(is_bt, len_min, ret_op)
#define rz_return_val_if_fail(expr, val)
Definition: rz_assert.h:108
static ut32 rz_read_be32(const void *src)
Definition: rz_endian.h:87
char * name
Definition: rz_bin.h:675

References go_pc_line_table_t::big_endian, rz_core_t::bin, core_recover_golang_functions_go_1_16(), core_recover_golang_functions_go_1_18(), core_recover_golang_functions_go_1_2(), GO_1_16, GO_1_18, GO_1_2, header, go_pc_line_table_t::io, rz_core_t::io, IS_GOPCLNTAB_1_16_BE, IS_GOPCLNTAB_1_16_LE, IS_GOPCLNTAB_1_18_BE, IS_GOPCLNTAB_1_18_LE, IS_GOPCLNTAB_1_2_BE, IS_GOPCLNTAB_1_2_LE, rz_bin_symbol_t::name, PFMT64x, go_pc_line_table_t::ptrsize, go_pc_line_table_t::quantum, rz_bin_get_sections(), rz_bin_get_symbols(), rz_core_cmd0(), rz_core_notify_begin(), rz_core_notify_done(), rz_core_notify_error(), rz_io_nread_at(), RZ_LOG_ERROR, rz_read_be32(), rz_return_val_if_fail, go_pc_line_table_t::size, rz_bin_symbol_t::size, go_pc_line_table_t::text_start, go_pc_line_table_t::vaddr, rz_bin_symbol_t::vaddr, and go_pc_line_table_t::version.

Referenced by rz_core_analysis_everything(), and rz_recover_all_golang_functions_strings_handler().

◆ rz_core_analysis_resolve_golang_strings()

RZ_API void rz_core_analysis_resolve_golang_strings ( RzCore core)

Attempts to recover all golang string.

Parameters
coreThe RzCore struct to use

Definition at line 1613 of file golang.c.

1613  {
1614  rz_return_if_fail(core && core->analysis && core->analysis->fcns && core->io);
1615  rz_core_notify_begin(core, "Analyze all instructions to recover all strings used in sym.go.*");
1616 
1617  const char *asm_arch = rz_config_get(core->config, "asm.arch");
1618  ut32 asm_bits = rz_config_get_i(core->config, "asm.bits");
1619  RzListIter *it, *it2;
1620  RzAnalysisFunction *func;
1621  RzAnalysisBlock *block;
1622  GoStrRecoverCb recover_cb = NULL;
1623  ut8 *bytes = NULL;
1625  GoStrRecover ctx = { 0 };
1626  ctx.core = core;
1627 
1628  if (!strcmp(asm_arch, "x86")) {
1629  switch (asm_bits) {
1630  case 32:
1631  recover_cb = &golang_recover_string_x86;
1632  break;
1633  case 64:
1634  recover_cb = &golang_recover_string_x64;
1635  break;
1636  default:
1637  break;
1638  }
1639  } else if (!strcmp(asm_arch, "arm")) {
1640  switch (asm_bits) {
1641  case 32:
1642  recover_cb = &golang_recover_string_arm32;
1643  break;
1644  case 64:
1645  recover_cb = &golang_recover_string_arm64;
1646  break;
1647  default:
1648  break;
1649  }
1650  } else if (!strcmp(asm_arch, "mips")) {
1651  switch (asm_bits) {
1652  case 32:
1653  recover_cb = &golang_recover_string_mips32;
1654  break;
1655  case 64:
1656  recover_cb = &golang_recover_string_mips64;
1657  break;
1658  default:
1659  break;
1660  }
1661  } else if (!strcmp(asm_arch, "riscv")) {
1662  switch (asm_bits) {
1663  case 64:
1664  recover_cb = &golang_recover_string_riscv64;
1665  break;
1666  default:
1667  break;
1668  }
1669  } else if (!strcmp(asm_arch, "ppc")) {
1670  switch (asm_bits) {
1671  case 64:
1672  recover_cb = &golang_recover_string_ppc64;
1673  break;
1674  default:
1675  break;
1676  }
1677  } else if (!strcmp(asm_arch, "sysz")) {
1678  // sysz uses strings that are all null terminated
1679  // also they are already handled by rizin.
1680  // example: 'larl %r0, str.XXXX' with the correct length.
1681  rz_core_notify_done(core, "Analyze all instructions to recover all strings used in sym.go.*");
1682  return;
1683  }
1684 
1685  if (!recover_cb) {
1686  rz_core_notify_error(core, "Cannot resolve go strings because arch '%s:%u' is not supported.", asm_arch, asm_bits);
1687  return;
1688  }
1689 
1690  rz_list_foreach (core->analysis->fcns, it, func) {
1691  if (rz_cons_is_breaked()) {
1692  break;
1693  }
1694  rz_list_foreach (func->bbs, it2, block) {
1695  bytes = malloc(block->size);
1696  if (!bytes) {
1697  RZ_LOG_ERROR("Failed allocate basic block bytes buffer\n");
1698  return;
1699  } else if (0 > rz_io_nread_at(core->io, block->addr, bytes, block->size)) {
1700  free(bytes);
1701  RZ_LOG_ERROR("Failed to read function basic block at address %" PFMT64x "\n", block->addr);
1702  return;
1703  }
1704 
1705  for (ut32 i = 0; i < block->size;) {
1706  ctx.pc = block->addr + i;
1707  ctx.bytes = bytes + i;
1708  ctx.size = block->size - i;
1709 
1710  ut32 nlen = recover_cb(&ctx);
1711  i += RZ_MAX(nlen, min_op_size);
1712  }
1713  free(bytes);
1714  }
1715  }
1716 
1717  rz_core_notify_done(core, "Analyze all instructions to recover all strings used in sym.go.*");
1718  rz_core_notify_done(core, "Recovered %d strings from the sym.go.* functions.", ctx.n_recovered);
1719 }
RZ_API int rz_analysis_archinfo(RzAnalysis *analysis, int query)
Definition: analysis.c:449
RZ_API ut64 rz_config_get_i(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:119
RZ_API RZ_BORROW const char * rz_config_get(RzConfig *cfg, RZ_NONNULL const char *name)
Definition: config.c:75
RZ_API bool rz_cons_is_breaked(void)
Definition: cons.c:373
static ut32 golang_recover_string_arm64(GoStrRecover *ctx)
Definition: golang.c:1013
static ut32 golang_recover_string_arm32(GoStrRecover *ctx)
Definition: golang.c:1092
static ut32 golang_recover_string_ppc64(GoStrRecover *ctx)
Definition: golang.c:1465
static ut32 golang_recover_string_mips64(GoStrRecover *ctx)
Definition: golang.c:1348
ut32(* GoStrRecoverCb)(GoStrRecover *ctx)
Definition: golang.c:70
static ut32 golang_recover_string_riscv64(GoStrRecover *ctx)
Definition: golang.c:1585
static ut32 golang_recover_string_mips32(GoStrRecover *ctx)
Definition: golang.c:1213
static ut32 golang_recover_string_x86(GoStrRecover *ctx)
Definition: golang.c:913
static ut32 golang_recover_string_x64(GoStrRecover *ctx)
Definition: golang.c:832
#define RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE
Definition: rz_analysis.h:98
#define rz_return_if_fail(expr)
Definition: rz_assert.h:100
#define RZ_MAX(x, y)
RzList * fcns
Definition: rz_analysis.h:565
RzConfig * config
Definition: rz_core.h:300

References rz_analysis_bb_t::addr, rz_core_t::analysis, rz_analysis_function_t::bbs, bytes, rz_core_t::config, rz_analysis_t::fcns, free(), golang_recover_string_arm32(), golang_recover_string_arm64(), golang_recover_string_mips32(), golang_recover_string_mips64(), golang_recover_string_ppc64(), golang_recover_string_riscv64(), golang_recover_string_x64(), golang_recover_string_x86(), i, rz_core_t::io, malloc(), NULL, PFMT64x, rz_analysis_archinfo(), RZ_ANALYSIS_ARCHINFO_MIN_OP_SIZE, rz_config_get(), rz_config_get_i(), rz_cons_is_breaked(), rz_core_notify_begin(), rz_core_notify_done(), rz_core_notify_error(), rz_io_nread_at(), RZ_LOG_ERROR, RZ_MAX, rz_return_if_fail, and rz_analysis_bb_t::size.

Referenced by rz_core_analysis_everything(), and rz_recover_all_golang_functions_strings_handler().

Variable Documentation

◆ go_arm32_ldr_mov_signature

GoSignature go_arm32_ldr_mov_signature[]
static
Initial value:
= {
}
static RzILOpEffect * ldr(cs_insn *insn, bool is_thumb)
Definition: arm_il32.c:564
static RzILOpEffect * mov(cs_insn *insn, bool is_thumb)
Definition: arm_il32.c:351
static bool decode_val_set_size(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:674
#define go_asm_pattern_name(arch, bits, mnemonic)
Definition: golang.c:658
static bool decode_ldr_set_addr(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:1036

Definition at line 1078 of file golang.c.

Referenced by golang_recover_string_arm32().

◆ go_arm32_ldr_str_mov_signature

GoSignature go_arm32_ldr_str_mov_signature[]
static
Initial value:

Definition at line 1060 of file golang.c.

Referenced by golang_recover_string_arm32().

◆ go_arm32_mov_str_ldr_signature

GoSignature go_arm32_mov_str_ldr_signature[]
static
Initial value:

Definition at line 1069 of file golang.c.

Referenced by golang_recover_string_arm32().

◆ go_arm32_table_signature

GoSignature go_arm32_table_signature[]
static
Initial value:
= {
}
static bool decode_from_table(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:662

Definition at line 1085 of file golang.c.

Referenced by golang_recover_string_arm32().

◆ go_arm64_adrp_add_movz_signature

GoSignature go_arm64_adrp_add_movz_signature[]
static
Initial value:
= {
}
static ut32 adrp(ArmOp *op, ut64 addr, ut32 k)
Definition: armass64.c:853
static bool decode_val_add_addr(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:698
static bool decode_ptr_set_addr(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:710
static int add(char *argv[])
Definition: ziptool.c:84

Definition at line 995 of file golang.c.

Referenced by golang_recover_string_arm64().

◆ go_arm64_adrp_add_orr_signature

GoSignature go_arm64_adrp_add_orr_signature[]
static
Initial value:

Definition at line 986 of file golang.c.

Referenced by golang_recover_string_arm64().

◆ go_arm64_adrp_add_str_movz_signature

GoSignature go_arm64_adrp_add_str_movz_signature[]
static
Initial value:

Definition at line 953 of file golang.c.

Referenced by golang_recover_string_arm64().

◆ go_arm64_adrp_add_str_orr_signature

GoSignature go_arm64_adrp_add_str_orr_signature[]
static
Initial value:

Definition at line 942 of file golang.c.

Referenced by golang_recover_string_arm64().

◆ go_arm64_movz_str_adrp_add_signature

GoSignature go_arm64_movz_str_adrp_add_signature[]
static
Initial value:

Definition at line 975 of file golang.c.

Referenced by golang_recover_string_arm64().

◆ go_arm64_orr_str_adrp_add_signature

GoSignature go_arm64_orr_str_adrp_add_signature[]
static
Initial value:

Definition at line 964 of file golang.c.

Referenced by golang_recover_string_arm64().

◆ go_arm64_table_signature

GoSignature go_arm64_table_signature[]
static
Initial value:

Definition at line 1004 of file golang.c.

Referenced by golang_recover_string_arm64().

◆ go_mipsbe32_addiu_sw_lui_addiu_signature

GoSignature go_mipsbe32_addiu_sw_lui_addiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 32, addiu), &decode_val_set_size },
{ &go_asm_pattern_name(mips, 32, any), NULL },
{ &go_asm_pattern_name(mipsbe, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 32, addiu), &decode_val_add_addr },
}
static bool decode_lui_set_addr(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:1112

Definition at line 1184 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsbe32_lui_addiu_addiu_signature

GoSignature go_mipsbe32_lui_addiu_addiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 32, addiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mipsbe, 32, addiu), &decode_val_set_size },
}

Definition at line 1195 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsbe32_lui_addiu_sw_addiu_signature

GoSignature go_mipsbe32_lui_addiu_sw_addiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 32, addiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mips, 32, any), NULL },
{ &go_asm_pattern_name(mipsbe, 32, addiu), &decode_val_set_size },
}

Definition at line 1173 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsbe32_table_signature

GoSignature go_mipsbe32_table_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 32, addiu), &decode_val_add_addr },
}

Definition at line 1204 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsbe64_daddiu_sd_lui_daddu_daddiu_signature

GoSignature go_mipsbe64_daddiu_sd_lui_daddu_daddiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 64, move), &decode_val_set_size },
{ &go_asm_pattern_name(mips, 64, any), NULL },
{ &go_asm_pattern_name(mipsbe, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsbe, 64, daddiu), &decode_val_add_addr },
}

Definition at line 1313 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_mipsbe64_lui_daddu_daddiu_daddiu_signature

GoSignature go_mipsbe64_lui_daddu_daddiu_daddiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsbe, 64, daddiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mipsbe, 64, move), &decode_val_set_size },
}

Definition at line 1326 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_mipsbe64_lui_daddu_daddiu_sd_daddiu_signature

GoSignature go_mipsbe64_lui_daddu_daddiu_sd_daddiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsbe, 64, daddiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mips, 64, any), NULL },
{ &go_asm_pattern_name(mipsbe, 64, move), &decode_val_set_size },
}

Definition at line 1300 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_mipsbe64_table_signature

GoSignature go_mipsbe64_table_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsbe, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsbe, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsbe, 64, daddiu), &decode_val_add_addr },
}

Definition at line 1337 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_mipsle32_addiu_sw_lui_addiu_signature

GoSignature go_mipsle32_addiu_sw_lui_addiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 32, addiu), &decode_val_set_size },
{ &go_asm_pattern_name(mips, 32, any), NULL },
{ &go_asm_pattern_name(mipsle, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 32, addiu), &decode_val_add_addr },
}

Definition at line 1143 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsle32_lui_addiu_addiu_signature

GoSignature go_mipsle32_lui_addiu_addiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 32, addiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mipsle, 32, addiu), &decode_val_set_size },
}

Definition at line 1154 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsle32_lui_addiu_sw_addiu_signature

GoSignature go_mipsle32_lui_addiu_sw_addiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 32, addiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mips, 32, any), NULL },
{ &go_asm_pattern_name(mipsle, 32, addiu), &decode_val_set_size },
}

Definition at line 1132 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsle32_table_signature

GoSignature go_mipsle32_table_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 32, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 32, addiu), &decode_val_add_addr },
}

Definition at line 1163 of file golang.c.

Referenced by golang_recover_string_mips32().

◆ go_mipsle64_daddiu_sd_lui_daddu_daddiu_signature

GoSignature go_mipsle64_daddiu_sd_lui_daddu_daddiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 64, move), &decode_val_set_size },
{ &go_asm_pattern_name(mips, 64, any), NULL },
{ &go_asm_pattern_name(mipsle, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsle, 64, daddiu), &decode_val_add_addr },
}

Definition at line 1264 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_mipsle64_lui_daddu_daddiu_daddiu_signature

GoSignature go_mipsle64_lui_daddu_daddiu_daddiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsle, 64, daddiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mipsle, 64, move), &decode_val_set_size },
}

Definition at line 1277 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_mipsle64_lui_daddu_daddiu_sd_daddiu_signature

GoSignature go_mipsle64_lui_daddu_daddiu_sd_daddiu_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsle, 64, daddiu), &decode_val_add_addr },
{ &go_asm_pattern_name(mips, 64, any), NULL },
{ &go_asm_pattern_name(mipsle, 64, move), &decode_val_set_size },
}

Definition at line 1251 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_mipsle64_table_signature

GoSignature go_mipsle64_table_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(mipsle, 64, lui), &decode_lui_set_addr },
{ &go_asm_pattern_name(mipsle, 64, daddu), NULL },
{ &go_asm_pattern_name(mipsle, 64, daddiu), &decode_val_add_addr },
}

Definition at line 1288 of file golang.c.

Referenced by golang_recover_string_mips64().

◆ go_ppcbe64_li_std_lis_addi_signature

GoSignature go_ppcbe64_li_std_lis_addi_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppc, 64, any), NULL },
{ &go_asm_pattern_name(ppcbe, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcbe, 64, addi), &decode_val_add_addr },
}
static bool decode_val_set_addr(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:686

Definition at line 1436 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_ppcbe64_lis_addi_li_signature

GoSignature go_ppcbe64_lis_addi_li_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppcbe, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcbe, 64, addi), &decode_val_add_addr },
}

Definition at line 1447 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_ppcbe64_lis_addi_std_li_signature

GoSignature go_ppcbe64_lis_addi_std_li_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppcbe, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcbe, 64, addi), &decode_val_add_addr },
{ &go_asm_pattern_name(ppc, 64, any), NULL },
}

Definition at line 1425 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_ppcbe64_table_signature

GoSignature go_ppcbe64_table_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppcbe, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcbe, 64, addi), &decode_val_add_addr },
}

Definition at line 1456 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_ppcle64_li_std_lis_addi_signature

GoSignature go_ppcle64_li_std_lis_addi_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppc, 64, any), NULL },
{ &go_asm_pattern_name(ppcle, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcle, 64, addi), &decode_val_add_addr },
}

Definition at line 1395 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_ppcle64_lis_addi_li_signature

GoSignature go_ppcle64_lis_addi_li_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppcle, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcle, 64, addi), &decode_val_add_addr },
}

Definition at line 1406 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_ppcle64_lis_addi_std_li_signature

GoSignature go_ppcle64_lis_addi_std_li_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppcle, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcle, 64, addi), &decode_val_add_addr },
{ &go_asm_pattern_name(ppc, 64, any), NULL },
}

Definition at line 1384 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_ppcle64_table_signature

GoSignature go_ppcle64_table_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(ppcle, 64, lis), &decode_val_set_addr },
{ &go_asm_pattern_name(ppcle, 64, addi), &decode_val_add_addr },
}

Definition at line 1415 of file golang.c.

Referenced by golang_recover_string_ppc64().

◆ go_riscv64_addiw_sd_auipc_add_signature

GoSignature go_riscv64_addiw_sd_auipc_add_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(riscv, 64, addiw), &decode_val_set_size },
{ &go_asm_pattern_name(riscv, 64, any), NULL },
{ &go_asm_pattern_name(riscv, 64, auipc), &decode_auipc_set_addr },
{ &go_asm_pattern_name(riscv, 64, addi), &decode_val_add_addr },
}
static bool decode_auipc_set_addr(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:1496

Definition at line 1547 of file golang.c.

Referenced by golang_recover_string_riscv64().

◆ go_riscv64_auipc_add_addiw_signature

GoSignature go_riscv64_auipc_add_addiw_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(riscv, 64, auipc), &decode_auipc_set_addr },
{ &go_asm_pattern_name(riscv, 64, addi), &decode_val_add_addr },
{ &go_asm_pattern_name(riscv, 64, addiw), &decode_val_set_size },
}

Definition at line 1558 of file golang.c.

Referenced by golang_recover_string_riscv64().

◆ go_riscv64_auipc_add_li_signature

GoSignature go_riscv64_auipc_add_li_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(riscv, 64, auipc), &decode_auipc_set_addr },
{ &go_asm_pattern_name(riscv, 64, addi), &decode_val_add_addr },
}

Definition at line 1567 of file golang.c.

Referenced by golang_recover_string_riscv64().

◆ go_riscv64_auipc_add_sd_addiw_signature

GoSignature go_riscv64_auipc_add_sd_addiw_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(riscv, 64, auipc), &decode_auipc_set_addr },
{ &go_asm_pattern_name(riscv, 64, addi), &decode_val_add_addr },
{ &go_asm_pattern_name(riscv, 64, any), NULL },
{ &go_asm_pattern_name(riscv, 64, addiw), &decode_val_set_size },
}

Definition at line 1514 of file golang.c.

Referenced by golang_recover_string_riscv64().

◆ go_riscv64_auipc_add_sd_li_signature

GoSignature go_riscv64_auipc_add_sd_li_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(riscv, 64, auipc), &decode_auipc_set_addr },
{ &go_asm_pattern_name(riscv, 64, addi), &decode_val_add_addr },
{ &go_asm_pattern_name(riscv, 64, any), NULL },
}

Definition at line 1525 of file golang.c.

Referenced by golang_recover_string_riscv64().

◆ go_riscv64_li_sd_auipc_add_signature

GoSignature go_riscv64_li_sd_auipc_add_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(riscv, 64, any), NULL },
{ &go_asm_pattern_name(riscv, 64, auipc), &decode_auipc_set_addr },
{ &go_asm_pattern_name(riscv, 64, addi), &decode_val_add_addr },
}

Definition at line 1536 of file golang.c.

Referenced by golang_recover_string_riscv64().

◆ go_riscv64_table_signature

GoSignature go_riscv64_table_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(riscv, 64, auipc), &decode_auipc_set_addr },
{ &go_asm_pattern_name(riscv, 64, addi), &decode_val_add_addr },
{ &go_asm_pattern_name(riscv, 64, any), &decode_from_table },
}

Definition at line 1576 of file golang.c.

Referenced by golang_recover_string_riscv64().

◆ go_x64_lea_mov0_mov_signature

GoSignature go_x64_lea_mov0_mov_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(x86, 64, mov_reg0), NULL },
}

Definition at line 744 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_lea_mov0_signature

GoSignature go_x64_lea_mov0_signature[]
static
Initial value:

Definition at line 762 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_lea_mov1_mov_signature

GoSignature go_x64_lea_mov1_mov_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(x86, 64, mov_reg1), NULL },
}

Definition at line 753 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_lea_mov1_signature

GoSignature go_x64_lea_mov1_signature[]
static
Initial value:

Definition at line 769 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_lea_mov2_signature

GoSignature go_x64_lea_mov2_signature[]
static
Initial value:

Definition at line 776 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_lea_mov3_signature

GoSignature go_x64_lea_mov3_signature[]
static
Initial value:

Definition at line 783 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_mov0_lea_signature

GoSignature go_x64_mov0_lea_signature[]
static
Initial value:

Definition at line 790 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_mov1_lea_signature

GoSignature go_x64_mov1_lea_signature[]
static
Initial value:

Definition at line 797 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_mov2_lea_signature

GoSignature go_x64_mov2_lea_signature[]
static
Initial value:

Definition at line 804 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_mov3_lea_signature

GoSignature go_x64_mov3_lea_signature[]
static
Initial value:

Definition at line 811 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_table0_signature

GoSignature go_x64_table0_signature[]
static
Initial value:

Definition at line 818 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x64_table1_signature

GoSignature go_x64_table1_signature[]
static
Initial value:

Definition at line 825 of file golang.c.

Referenced by golang_recover_string_x64().

◆ go_x86_lea_mov0_mov_signature

GoSignature go_x86_lea_mov0_mov_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(x86, 32, mov_reg0), NULL },
}
static bool decode_disp_set_addr(RzCore *core, GoStrInfo *info, ut64 pc, const ut8 *buffer, const ut32 size)
Definition: golang.c:722

Definition at line 867 of file golang.c.

Referenced by golang_recover_string_x86().

◆ go_x86_lea_mov0_signature

GoSignature go_x86_lea_mov0_signature[]
static
Initial value:

Definition at line 885 of file golang.c.

Referenced by golang_recover_string_x86().

◆ go_x86_lea_mov1_mov_signature

GoSignature go_x86_lea_mov1_mov_signature[]
static
Initial value:
= {
{ &go_asm_pattern_name(x86, 32, mov_reg1), NULL },
}

Definition at line 876 of file golang.c.

Referenced by golang_recover_string_x86().

◆ go_x86_lea_mov1_signature

GoSignature go_x86_lea_mov1_signature[]
static
Initial value:

Definition at line 892 of file golang.c.

Referenced by golang_recover_string_x86().

◆ go_x86_mov_lea_signature

GoSignature go_x86_mov_lea_signature[]
static
Initial value:

Definition at line 899 of file golang.c.

Referenced by golang_recover_string_x86().

◆ go_x86_table_signature

GoSignature go_x86_table_signature[]
static
Initial value:

Definition at line 906 of file golang.c.

Referenced by golang_recover_string_x86().