Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
94fd2f5
Rewrite of RzConfig
wargio Jan 19, 2026
653caee
Cleaning up the mess
wargio Jan 19, 2026
f28b63f
Refactoring and fixing comments
wargio Jan 21, 2026
8baddb3
Improve usage of RzAnalysisRange
wargio Jan 21, 2026
191b425
Fix cbin rz_config_set/set
wargio Jan 21, 2026
c0a28ed
Fix cbounds.c rz_config_get
wargio Jan 21, 2026
e29f7dd
Add search_map to core
wargio Jan 21, 2026
8e4f89a
Add default hardcoded settings on rz_analsys_new
wargio Jan 21, 2026
6ae7654
Add comment on noncode variable
wargio Jan 21, 2026
c72124d
Fix csign.c
wargio Jan 21, 2026
2ca3754
Cleanup cconfig.c
wargio Jan 21, 2026
7927397
Initial work on cconfig_arch.c
wargio Jan 21, 2026
4522d4c
Add cconfig_sign.c
wargio Jan 21, 2026
3814f4e
Use rz_config_iterate_vars
wargio Jan 21, 2026
52d0257
Fix cesil.c
wargio Jan 21, 2026
47da7db
Add "compatibility" mode for certain types
wargio Jan 21, 2026
32ca386
Add rz_config_get_as_string
wargio Jan 21, 2026
598a49e
Add rz_config_set_list2
wargio Jan 21, 2026
afcd9b2
Fix cfile.c
wargio Jan 21, 2026
7332852
Fix cgraph.c
wargio Jan 21, 2026
71ab52b
Fix cil.c
wargio Jan 21, 2026
ad1913d
Fix cio.c
wargio Jan 21, 2026
5268653
Fix core.c
wargio Jan 21, 2026
50da3ed
Fix csearch.c
wargio Jan 21, 2026
13efbdc
Fix ctypes.c
wargio Jan 21, 2026
16ff471
Fix disasm.c
wargio Jan 21, 2026
0a75368
Fix fortune.c
wargio Jan 21, 2026
2ccf83d
Fix golang.c
wargio Jan 21, 2026
a8a00b9
Fix hack.c
wargio Jan 21, 2026
1ddaf01
Fix libs.c
wargio Jan 21, 2026
07d72ab
Fix rop.c
wargio Jan 21, 2026
018918b
Fix project.c
wargio Jan 21, 2026
9b15a86
Fix rtr.c
wargio Jan 21, 2026
5de220a
Fix rtr_http.c
wargio Jan 21, 2026
9f77974
Fix seek.c
wargio Jan 21, 2026
b621bba
Fix linux_heap_jemalloc.c
wargio Jan 21, 2026
08c45f7
Implement rz_config_set_any
wargio Jan 21, 2026
3c48b4b
Fix cmd.c
wargio Jan 21, 2026
0d1bc1c
Fix formatting of colormap
wargio Jan 21, 2026
bc9c28f
Remove dead code
wargio Jan 21, 2026
7695c65
Fixed missing NULL
wargio Jan 21, 2026
a29bfc7
Fix cmd_print.c
wargio Jan 21, 2026
8d644b5
Fix cmd_search.c
wargio Jan 21, 2026
7194931
Fix cmd_search_rop.c
wargio Jan 21, 2026
1699e6b
Fix cmd_analysis.c
wargio Jan 21, 2026
fd76982
Fix cmd_debug.c
wargio Jan 21, 2026
31f30c1
Fix cmd_egg.c
wargio Jan 21, 2026
47aba99
Add rz_config_is_readonly
wargio Jan 21, 2026
c40d6e5
Fix cmd_eval.c
wargio Jan 21, 2026
125b98e
Fix cmd_open.c
wargio Jan 21, 2026
00effd6
Fix cmd_flirt.c
wargio Jan 21, 2026
9891eb3
Fix cmd_seek.c
wargio Jan 21, 2026
32000c2
Fix cmd_info.c
wargio Jan 21, 2026
7213f25
Fix cmd_interactive_panel.c
wargio Jan 21, 2026
109a4b1
Fix cmd_plugins.c
wargio Jan 21, 2026
8b0435d
Fix cmd_project.c
wargio Jan 21, 2026
e67d805
Fix cmd_quit.c
wargio Jan 21, 2026
30b2d72
Fix cmd_system.c
wargio Jan 21, 2026
83600fc
Fix tui/classes.c
wargio Jan 21, 2026
8ed253a
Fix tui/config.c
wargio Jan 21, 2026
2686fe0
remove rz_config_lock
wargio Jan 21, 2026
d183ee6
Fix rz_str_ccpy
wargio Jan 21, 2026
3fe22a3
Fix tui/config.c
wargio Jan 21, 2026
724a360
rz_config_toggle_boolean -> rz_config_toggle_bool
wargio Jan 21, 2026
c8fa3b7
Pass RzConfig to the RzConfigIterator
wargio Jan 21, 2026
dbded81
Fix tui/hud.c
wargio Jan 21, 2026
364a00e
Fix tui/visual.c
wargio Jan 21, 2026
4cb643f
Fix tui/vasm.c
wargio Jan 21, 2026
25aad6f
Fix tui/panels.c
wargio Jan 21, 2026
03a4943
Ensure description is always a valid pointer when iterating
wargio Jan 21, 2026
3651de8
Move rz_core_config_print_all to core_private.h and fix cconfig.c
wargio Jan 21, 2026
db28c23
Move rz_core_esil_cmd in cesil.c
wargio Jan 21, 2026
0442bd1
Fix tests and config
Jan 22, 2026
6c04f50
Fix behavior of rz_list_add_sorted
Jan 22, 2026
7d14e6d
Remove wrong warning
wargio Jan 23, 2026
bc3a61d
Add analysis.timeout
wargio Jan 25, 2026
01f3038
Add analysis.jmp.retpoline
wargio Jan 25, 2026
af786fa
Add analysis.armthumb
wargio Jan 25, 2026
9bf4378
analysis.jmp.after
wargio Jan 25, 2026
306b2cc
analysis.trap.after
wargio Jan 25, 2026
e6e8c4e
analysis.delay
wargio Jan 25, 2026
701bc7d
analysis.graph_depth & analysis.depth
wargio Jan 25, 2026
f81b3e3
Remove useless analysis.sleep
wargio Jan 25, 2026
21f54a3
analysis.ignbithints
wargio Jan 25, 2026
4fac79c
analysis.calls
wargio Jan 25, 2026
9faafc3
analysis.autoname && analysis.hasnext
wargio Jan 25, 2026
a084284
Add analysis.esil analysis.types.verbose analysis.types.constraint an…
wargio Jan 25, 2026
a98e34f
analysis.nonull
wargio Jan 25, 2026
14c0f6b
analysis.types.spec analysis.prelude analysis.prelude.limit analysis.…
wargio Jan 25, 2026
1621ff8
Sorted and add asm variables.
wargio Jan 25, 2026
6cde7d2
Sort everything
wargio Jan 25, 2026
818a0c5
analysis.strings is a terrible idea.
wargio Jan 25, 2026
aa7084c
analysis.vars
wargio Jan 25, 2026
e622130
analysis.norevisit
wargio Jan 25, 2026
d8b96e5
Define all options for later check
wargio Jan 25, 2026
3b7f5ce
analysis.nopskip
wargio Jan 25, 2026
eae2a4d
analysis.hpskip
wargio Jan 25, 2026
07247af
analysis.arch & set opts for analysis.cc/syscc
wargio Jan 25, 2026
a81761b
Add cfg.* options
wargio Jan 25, 2026
ff25cb6
fixconf
wargio Jan 25, 2026
e44cf2a
Initial work on scr.*
wargio Jan 26, 2026
4253fca
Add dir.*
wargio Jan 26, 2026
18b9061
More options src.*
wargio Jan 26, 2026
9ec97e0
Fix autocomplete.
wargio Jan 26, 2026
1fd0ad0
analysis.lines.maxref
wargio Jan 26, 2026
8cbe161
Almost finished with asm.*
wargio Jan 26, 2026
9d71fa1
Many fixes
wargio Feb 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 83 additions & 14 deletions librz/arch/analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,48 @@ RZ_API ut32 rz_analysis_guessed_mem_access_width(RZ_NONNULL const RzAnalysis *an
return analysis->bits / 8;
}

RZ_API void rz_analysis_set_limits(RzAnalysis *analysis, ut64 from, ut64 to) {
free(analysis->limit);
analysis->limit = RZ_NEW0(RzAnalysisRange);
if (analysis->limit) {
analysis->limit->from = from;
analysis->limit->to = to;
/**
* \brief Sets the limits of the analysis range [from : to]
*
* \param analysis The current RzAnalysis in use.
* \param[in] from The from address to set
* \param[in] to The to address to set
*/
RZ_API void rz_analysis_set_limits(RZ_NONNULL RzAnalysis *analysis, ut64 from, ut64 to) {
rz_return_if_fail(analysis);
if (from > to) {
RZ_LOG_WARN("analysis: invalid limits from (%" PFMT64x ") > to (%" PFMT64x ")\n", from, to);
}

analysis->limit.from = from;
analysis->limit.to = to;
}

/**
* \brief Sets the limits of the analysis range [from : to]
*
* \param analysis The current RzAnalysis in use.
* \param[in] from The from address to get.
* \param[in] to The to address to get.
*/
RZ_API void rz_analysis_get_limits(RZ_NONNULL RzAnalysis *analysis, RZ_NULLABLE ut64 *from, RZ_NULLABLE ut64 *to) {
rz_return_if_fail(analysis);
if (from) {
*from = analysis->limit.from;
}
if (to) {
*to = analysis->limit.to;
}
}

RZ_API void rz_analysis_unset_limits(RzAnalysis *analysis) {
RZ_FREE(analysis->limit);
RZ_API void rz_analysis_enable_limits(RZ_NONNULL RzAnalysis *analysis, bool enabled) {
rz_return_if_fail(analysis);
analysis->limit.enabled = enabled;
}

RZ_API bool rz_analysis_are_limits_enabled(RZ_NONNULL RzAnalysis *analysis) {
rz_return_val_if_fail(analysis, false);
return analysis->limit.enabled;
}

static void meta_unset_for(RzEvent *ev, int type, void *user, void *data) {
Expand Down Expand Up @@ -104,15 +135,45 @@ RZ_API RzAnalysis *rz_analysis_new(RZ_NULLABLE const char *sdb_types_path) {
analysis->ht_name_fun = ht_sp_new(HT_STR_DUP, NULL, NULL);
analysis->os = rz_str_dup(RZ_SYS_OS);
analysis->esil_goto_limit = RZ_ANALYSIS_ESIL_GOTO_LIMIT;
analysis->opt.nopskip = true; // skip nops in code analysis
analysis->opt.hpskip = false; // skip `mov reg,reg` and `lea reg,[reg]`
analysis->gp = 0LL;
analysis->sdb = sdb_new0();
analysis->cpp_abi = RZ_ANALYSIS_CPP_ABI_ITANIUM;
analysis->opt.depth = 32;
analysis->recursive_noreturn = false;
analysis->maxreflines = 0; // maximum number of reflines to be analyzed
analysis->pcalign = 1; // instruction alignment (must be a power of 2).
analysis->lineswidth = 7; // number of columns for program flow arrows
// RzAnalysisOptions
analysis->opt.afterjmp = true; // continue analysis after jmp/ujmp
analysis->opt.aftertrap = false; // continue analysis after trap instructions
analysis->opt.armthumb = false; // computes arm/thumb changes
analysis->opt.bb_max_size = RZ_ANALYSIS_BLOCK_MAX_SIZE; // maximum basic block size
analysis->opt.cjmpref = false; // create references for conditional jumps
analysis->opt.delay = true; // delay slot analysis when supported by the arch
analysis->opt.depth = 64; // max depth at code analysis
analysis->opt.fcn_max_size = 256 * 1024; // maximum function size
analysis->opt.followbrokenfcnsrefs = false; // follow function references even if function analysis has failed
analysis->opt.followdatarefs = false; // follow data references for code coverage
analysis->opt.graph_depth = 256; // max depth for path search
analysis->opt.hpskip = false; // skip `mov reg,reg` and `lea reg,[reg]`
analysis->opt.ignbithints = false; // ignore the ahb hints (only obey asm.bits)
analysis->opt.ijmp = false; // follow the indirect jumps in function analysis
analysis->opt.jmpabove = true; // jump above function pointer
analysis->opt.jmpmid = true; // continue analysis after jump to middle of instruction (x86 only)
analysis->opt.jmpref = true; // create references for unconditional jumps
analysis->opt.jmptbl = true; // analyze jump tables in switch statements
analysis->opt.jmptbl_maxcount = 512; // maximum amount of entries to analyze in jump tables
analysis->opt.jmptbl_maxoffset = 4096; // maximum offset from the jump table jump instruction to consider it valid
analysis->opt.loads = false; // define as dword/string/qword when analyzing load instructions
analysis->opt.noncode = false; // do not analyze data by default
analysis->opt.bb_max_size = RZ_ANALYSIS_BLOCK_MAX_SIZE;
analysis->opt.fcn_max_size = 256 * 1024;
analysis->opt.nonull = 0; // do not analyze regions of N null bytes (0 is disabled)
analysis->opt.nopskip = true; // skip nops in code analysis
analysis->opt.norevisit = false; // do not visit function analysis twice
analysis->opt.pushret = false; // analyze push+ret as jmp
analysis->opt.recont = false; // end block after splitting a basic block instead of error
analysis->opt.retpoline = true; // analyze retpoline
analysis->opt.searchstringrefs = false; // search string references in data references
analysis->opt.trycatch = false; // honor `try.X.Y.{from,to,catch}` flags
analysis->opt.vars = true; // analyze local variables and arguments
rz_spaces_init(&analysis->meta_spaces, "CS");
rz_event_hook(analysis->meta_spaces.event, RZ_SPACE_EVENT_UNSET, meta_unset_for, NULL);
rz_event_hook(analysis->meta_spaces.event, RZ_SPACE_EVENT_COUNT, meta_count_for, NULL);
Expand Down Expand Up @@ -161,6 +222,12 @@ RZ_API RzAnalysis *rz_analysis_new(RZ_NULLABLE const char *sdb_types_path) {
analysis->lea_jmptbl_ip = UT64_MAX;
analysis->gnu_thumb1_case_uqi_addr = 0;
analysis->ht_virtual_xrefs = ht_sp_new(HT_STR_DUP, NULL, (HtSPFreeValue)rz_set_u_free);

// default settings.
rz_analysis_enable_limits(analysis, false);
rz_analysis_set_limits(analysis, UT64_MAX, UT64_MAX);
rz_analysis_set_triplet(analysis, RZ_SYS_OS, RZ_SYS_ARCH, (RZ_SYS_BITS << 3));
rz_analysis_set_cpu(analysis, RZ_SYS_ARCH);
return analysis;
}

Expand Down Expand Up @@ -389,9 +456,11 @@ RZ_API int rz_analysis_get_address_bits(RzAnalysis *analysis) {
}

RZ_API void rz_analysis_set_cpu(RzAnalysis *analysis, const char *cpu) {
if (RZ_STR_EQ(cpu, analysis->cpu)) {
rz_return_if_fail(analysis);
if (cpu && analysis->cpu && RZ_STR_EQ(cpu, analysis->cpu)) {
return;
}

free(analysis->cpu);
analysis->cpu = rz_str_dup(cpu);
int v = rz_analysis_archinfo(analysis, RZ_ANALYSIS_ARCHINFO_TEXT_ALIGN);
Expand Down
17 changes: 15 additions & 2 deletions librz/arch/asm.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,11 @@ RZ_API RzAsm *rz_asm_new(void) {
if (!a) {
return NULL;
}
a->pseudo = false; // show pseudo syntax
a->immdisp = true; // hides hashtag (#) for immediates in archs
a->invhex = false; // show invalid instructions as hexadecimal numbers
a->pcalign = 1; // instruction alignment (must be a power of 2).
a->dataalign = 1;
a->bits = RZ_SYS_BITS;
a->bitshift = 0;
a->syntax = RZ_ASM_SYNTAX_INTEL;
a->sdb_opcodes_path = rz_path_new();
Expand All @@ -304,6 +307,8 @@ RZ_API RzAsm *rz_asm_new(void) {
}
rz_asm_plugin_add(a, plugin);
}

rz_asm_set_arch(a, RZ_SYS_ARCH, (RZ_SYS_BITS << 3));
return a;
}

Expand Down Expand Up @@ -432,7 +437,6 @@ RZ_API bool rz_asm_use_assembler(RzAsm *a, const char *name) {
*/
static void set_plugin_configs(RZ_BORROW RzCore *core, const char *plugin_name, RZ_OWN RzConfig *pcfg) {
rz_return_if_fail(pcfg && core);
rz_config_lock(pcfg, 1);
if (!ht_sp_insert(core->plugin_configs, plugin_name, pcfg)) {
RZ_LOG_WARN("Plugin '%s' was already added.\n", plugin_name);
}
Expand Down Expand Up @@ -518,6 +522,15 @@ RZ_DEPRECATE RZ_API void rz_asm_set_cpu(RzAsm *a, const char *cpu) {
}
}

RZ_API RZ_OWN RzList /*<char *>*/ *rz_asm_get_cpus(RZ_NONNULL RzAsm *a) {
rz_return_val_if_fail(a, NULL);
if (!a->cur || !a->cur->cpus) {
return NULL;
}

return rz_str_split_duplist(a->cur->cpus, ",", true);
}

static bool has_bits(RzAsmPlugin *h, int bits) {
return (h && h->bits && (bits & h->bits));
}
Expand Down
2 changes: 1 addition & 1 deletion librz/arch/cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static bool filter_cc(void *user, const SdbKv *kv) {
}

RZ_API RzList /*<char *>*/ *rz_analysis_calling_conventions(RzAnalysis *analysis) {
RzList *ccl = rz_list_new();
RzList *ccl = rz_list_newf(free);
void **iter;
RzPVector *items = sdb_get_items_filter(analysis->sdb_cc, filter_cc, NULL, true);
rz_pvector_foreach (items, iter) {
Expand Down
7 changes: 2 additions & 5 deletions librz/arch/fcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,6 @@ static RzAnalysisBBEndCause run_basic_block_analysis(RzAnalysisTaskItem *item, R
rz_analysis_task_item_new(analysis, tasks, fcn, bb, addr, sp);
return RZ_ANALYSIS_RET_END;
}
if (analysis->sleep) {
rz_sys_usleep(analysis->sleep);
}

// check if address is readable
if (!analysis->iob.is_valid_offset(analysis->iob.io, addr, 0)) {
Expand Down Expand Up @@ -677,7 +674,7 @@ static RzAnalysisBBEndCause run_basic_block_analysis(RzAnalysisTaskItem *item, R
bool last_is_mov_lr_pc = false;
bool last_is_add_lr_pc = false;
ut64 last_push_addr = UT64_MAX;
if (analysis->limit && addr + idx < analysis->limit->from) {
if (analysis->limit.enabled && addr + idx < analysis->limit.from) {
gotoBeach(RZ_ANALYSIS_RET_END);
}
RzAnalysisFunction *tmp_fcn = rz_analysis_get_fcn_in(analysis, addr, 0);
Expand Down Expand Up @@ -717,7 +714,7 @@ static RzAnalysisBBEndCause run_basic_block_analysis(RzAnalysisTaskItem *item, R
free(last_reg_mov_lea_name);
last_reg_mov_lea_name = NULL;
}
if (analysis->limit && analysis->limit->to <= addr + idx) {
if (analysis->limit.enabled && analysis->limit.to <= addr + idx) {
break;
}
repeat:
Expand Down
5 changes: 5 additions & 0 deletions librz/arch/isa/hexagon/hexagon.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,11 @@ typedef struct {
RzPVector /*<RzAsmTokenPattern *>*/ *token_patterns; ///< PVector with token patterns. Priority ordered.
bool utf8_enabled; ///< If set, print UTF-8 characters.
bool might_have_jumped; ///< Is set if a previous IL packet was a branch. Indicates the next decoded packet is valid.

bool imm_hash; ///< Display ## before 32bit immediates and # before immidiates with other width.
bool imm_sign; ///< True: Print them with sign. False: Print signed immediates in unsigned representation.
bool sdk; ///< Print packet syntax in objdump style.
bool reg_alias; ///< Print the alias of registers (Alias from C0 = SA0).
} HexState;

/**
Expand Down
2 changes: 1 addition & 1 deletion librz/arch/isa/hexagon/hexagon_arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ static void hex_set_pkt_info(RZ_INOUT HexInsnContainer *hic, const HexPkt *pkt,
rz_return_if_fail(hic && pkt && state);
bool is_first = (k == 0);
HexPktInfo *hi_pi = &hic->pkt_info;
bool sdk_form = rz_config_get_b(state->cfg, "plugins.hexagon.sdk");
bool sdk_form = state->sdk;

strncpy(hi_pi->text_postfix, "", 16);
// Parse instr. position in pkt
Expand Down
6 changes: 3 additions & 3 deletions librz/arch/isa/hexagon/hexagon_disas.c
Original file line number Diff line number Diff line change
Expand Up @@ -34030,9 +34030,9 @@ static int get_jmp_target_imm_op_index(const HexInsnTemplate *tpl) {
}

static void hex_disasm_with_templates(const HexInsnTemplate *tpl, HexState *state, ut32 hi_u32, RZ_INOUT HexInsn *hi, HexInsnContainer *hic, ut64 addr, HexPkt *pkt) {
bool print_reg_alias = rz_config_get_b(state->cfg, "plugins.hexagon.reg.alias");
bool show_hash = rz_config_get_b(state->cfg, "plugins.hexagon.imm.hash");
bool sign_nums = rz_config_get_b(state->cfg, "plugins.hexagon.imm.sign");
bool print_reg_alias = state->reg_alias;
bool show_hash = state->imm_hash;
bool sign_nums = state->imm_sign;
char signed_imm[HEX_MAX_OPERANDS][32];
// Find the right template
for (; tpl->id; tpl++) {
Expand Down
8 changes: 4 additions & 4 deletions librz/arch/jmptbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ RZ_API bool rz_analysis_walkthrough_casetbl(RZ_NONNULL RzAnalysis *analysis, RZ_
break;
}
}
if (analysis->limit) {
if (jmpptr < analysis->limit->from || jmpptr > analysis->limit->to) {
if (analysis->limit.enabled) {
if (jmpptr < analysis->limit.from || jmpptr > analysis->limit.to) {
break;
}
}
Expand Down Expand Up @@ -235,8 +235,8 @@ RZ_API bool rz_analysis_walkthrough_jmptbl(RZ_NONNULL RzAnalysis *analysis, RZ_N
break;
}
}
if (analysis->limit) {
if (jmpptr < analysis->limit->from || jmpptr > analysis->limit->to) {
if (analysis->limit.enabled) {
if (jmpptr < analysis->limit.from || jmpptr > analysis->limit.to) {
break;
}
}
Expand Down
77 changes: 42 additions & 35 deletions librz/arch/p/asm/asm_hexagon.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,53 +98,60 @@ static RZ_OWN RzPVector /*<RzAsmTokenPattern *>*/ *get_token_patterns() {
return pvec;
}

/**
* \brief Setter for the plugins RzConfig nodes.
*
* \param user The user of the RzConfig node. If this callback is called by Core \p user = RzCore.
* If it is called by the plugins config setup \p user = HexState.
* \param data The node to set. Again, if called by RzCore \p date = Node from RzCore config.
* If it is called by the plugins config setup \p data = a plugins config node.
* \return bool True if the config was set. False otherwise.
*/
static bool hex_cfg_set(void *user, void *data) {
rz_return_val_if_fail(user && data, false);
HexState *state = user;
RzConfig *pcfg = state->cfg;

RzConfigNode *cnode = (RzConfigNode *)data; // Config node from core.
RzConfigNode *pnode = rz_config_node_get(pcfg, cnode->name); // Config node of plugin.
if (pnode == cnode) {
return true;
}
if (cnode) {
pnode->i_value = cnode->i_value;
free(pnode->value);
pnode->value = rz_str_dup(cnode->value);
return true;
}
return false;
}

static bool hexagon_fini(void *user) {
hexagon_state_fini(user);
free(user);
return true;
}

#define hexagon_getter_config(name, variable) \
static bool hexagon_##name(void *user, void *data) { \
bool *value = data; \
HexState *state = user; \
if (!state) { \
return false; \
} \
*value = state->variable; \
return true; \
}

#define hexagon_setter_config(name, variable) \
static bool hexagon_##name(void *user, const void *data) { \
const bool *value = data; \
HexState *state = user; \
if (!state) { \
return false; \
} \
state->variable = *value; \
return true; \
}

#define hexagon_config_callbacks(variable) \
hexagon_setter_config(config_##variable##_set, variable); \
hexagon_getter_config(config_##variable##_get, variable)

hexagon_config_callbacks(imm_hash);
hexagon_config_callbacks(imm_sign);
hexagon_config_callbacks(sdk);
hexagon_config_callbacks(reg_alias);

static bool hexagon_init(void **plugin_data) {
HexState *state = hexagon_state_new();
rz_return_val_if_fail(state, false);

state->cfg = rz_config_new(state);
rz_return_val_if_fail(state->cfg, false);
state->imm_hash = true;
state->imm_sign = true;
state->sdk = false;
state->reg_alias = true;

RzConfig *cfg = state->cfg = rz_config_new(state);
rz_return_val_if_fail(cfg, false);

RzConfig *cfg = state->cfg; // Rename for SETCB macros.
// Add nodes
SETCB("plugins.hexagon.imm.hash", "true", &hex_cfg_set, "Display ## before 32bit immediates and # before immidiates with other width.");
SETCB("plugins.hexagon.imm.sign", "true", &hex_cfg_set, "True: Print them with sign. False: Print signed immediates in unsigned representation.");
SETCB("plugins.hexagon.sdk", "false", &hex_cfg_set, "Print packet syntax in objdump style.");
SETCB("plugins.hexagon.reg.alias", "true", &hex_cfg_set, "Print the alias of registers (Alias from C0 = SA0).");
rz_config_add_b_bind(cfg, "plugins.hexagon.imm.hash", "Display ## before 32bit immediates and # before immidiates with other width.", hexagon_config_imm_hash_get, hexagon_config_imm_hash_set);
rz_config_add_b_bind(cfg, "plugins.hexagon.imm.sign", "True: Print them with sign. False: Print signed immediates in unsigned representation.", hexagon_config_imm_sign_get, hexagon_config_imm_sign_set);
rz_config_add_b_bind(cfg, "plugins.hexagon.sdk", "Print packet syntax in objdump style.", hexagon_config_sdk_get, hexagon_config_sdk_set);
rz_config_add_b_bind(cfg, "plugins.hexagon.reg.alias", "Print the alias of registers (Alias from C0 = SA0).", hexagon_config_reg_alias_get, hexagon_config_reg_alias_set);

if (!state->token_patterns) {
state->token_patterns = get_token_patterns();
Expand Down
4 changes: 2 additions & 2 deletions librz/arch/parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ RZ_API RzParse *rz_parse_new(void) {
p->flagspace = NULL;
p->pseudo = false;
p->subrel = false;
p->subtail = false;
p->minval = 0x100;
p->subtail = false; // Replace addresses with prefix .. syntax
p->minval = 0x100; // minimum value to substitute in instructions
p->localvar_only = false;

const size_t n_plugins = rz_arch_get_n_plugins();
Expand Down
Loading