Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finish the last NEW_ABI code blocks #23679

Merged
merged 3 commits into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 1 addition & 8 deletions libr/anal/fcn.c
Original file line number Diff line number Diff line change
Expand Up @@ -624,11 +624,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int
};
const char *arch = anal->config? anal->config->arch: R_SYS_ARCH;
bool arch_destroys_dst = does_arch_destroys_dst (arch);
#if R2_USE_NEW_ABI
const bool flagends = anal->opt.flagends;
#else
const bool flagends = anal->coreb.cfggeti (anal->coreb.core, "anal.flagends");
#endif
const bool is_arm = r_str_startswith (arch, "arm");
const bool is_mips = !is_arm && r_str_startswith (arch, "mips");
const bool is_v850 = is_arm ? false: (arch && (!strncmp (arch, "v850", 4) || !strncmp (anal->coreb.cfgGet (anal->coreb.core, "asm.cpu"), "v850", 4)));
Expand Down Expand Up @@ -1122,10 +1118,7 @@ static int fcn_recurse(RAnal *anal, RAnalFunction *fcn, ut64 addr, ut64 len, int
// R2R db/anal/arm db/esil/apple
//v1 = UT64_MAX; // reset v1 jmptable pointer value for mips only
// on stm8 this must be disabled.. but maybe we need a global option to disable icod refs
bool want_icods = true;
#if R2_USE_NEW_ABI
// want_icods = anal->opt.icods;
#endif
bool want_icods = anal->opt.icods;
{
const char *arch = R_UNWRAP3 (anal, config, arch);
if (r_str_startswith (arch, "stm8")) {
Expand Down
6 changes: 0 additions & 6 deletions libr/bin/bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -1687,13 +1687,7 @@ R_API char *r_bin_attr_tostring(ut64 attr, bool singlechar) {
return r_strbuf_drain (sb);
}

// TODO : not implemented yet
#if R2_USE_NEW_ABI
R_API ut64 r_bin_attr_fromstring(const char *s, bool compact) {
#else
R_API ut64 r_bin_attr_fromstring(const char *s) {
const bool compact = false;
#endif
size_t i;
ut64 bits = 0LL;
const char *word;
Expand Down
2 changes: 0 additions & 2 deletions libr/bin/dbginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ R_API R_NULLABLE char *r_bin_addr2text(RBin *bin, ut64 addr, int origin) {
}
char *res = NULL;
char *filename = strdup (di->file);
#if R2_USE_NEW_ABI
if (R_STR_ISNOTEMPTY (bin->srcdir_base) && r_str_startswith (filename, bin->srcdir_base)) {
char *fn = strdup (filename + strlen (bin->srcdir_base));
free (filename);
filename = fn;
}
#endif
char *basename = strdup (r_file_basename (di->file));
#if __APPLE__
// early optimization because mac's home is slow
Expand Down
4 changes: 0 additions & 4 deletions libr/bin/p/bin_mach0.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,7 @@ static RList* patch_relocs(RBinFile *bf) {
static RBuffer *swizzle_io_read(RBinFile *bf, struct MACH0_(obj_t) *obj, RIO *io) {
R_RETURN_VAL_IF_FAIL (io && io->desc && io->desc->plugin, NULL);
RFixupRebaseContext ctx = {0};
#if R2_USE_NEW_ABI
RBuffer *nb = r_buf_new_with_cache (obj->b, false);
#else
RBuffer *nb = r_buf_new_with_buf (obj->b);
#endif
RBuffer *ob = obj->b;
obj->b = nb;
ut64 count = r_buf_size (obj->b);
Expand Down
5 changes: 3 additions & 2 deletions libr/core/canal.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#include <r_vec.h>
#include <sdb/ht_uu.h>

// 128M
#define MAX_SCAN_SIZE 0x7ffffff

HEAPTYPE (ut64);

R_VEC_TYPE (RVecAnalRef, RAnalRef);
Expand All @@ -17,8 +20,6 @@ enum {
R2_ARCH_ARM64,
R2_ARCH_MIPS
};
// 128M
#define MAX_SCAN_SIZE 0x7ffffff

static void loganal(ut64 from, ut64 to, int depth) {
r_cons_clear_line (1);
Expand Down
14 changes: 8 additions & 6 deletions libr/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,16 @@ static bool cb_debug_hitinfo(void *user, void *data) {
}

static bool cb_anal_flagends(void *user, void *data) {
#if R2_USE_NEW_ABI
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
core->anal->opt.flagends = node->i_value;
#endif
return true;
}

static bool cb_anal_icods(void *user, void *data) {
RCore *core = (RCore*) user;
RConfigNode *node = (RConfigNode*) data;
core->anal->opt.icods = node->i_value;
return true;
}

Expand Down Expand Up @@ -1422,7 +1427,6 @@ static bool cb_dirsrc(void *user, void *data) {
return true;
}

#if R2_USE_NEW_ABI
static bool cb_dirsrc_base(void *user, void *data) {
RConfigNode *node = (RConfigNode*) data;
RCore *core = (RCore *)user;
Expand All @@ -1434,7 +1438,6 @@ static bool cb_dirsrc_base(void *user, void *data) {
}
return true;
}
#endif

static bool cb_cfgsanbox_grain(void *user, void *data) {
RConfigNode *node = (RConfigNode*) data;
Expand Down Expand Up @@ -3552,6 +3555,7 @@ R_API int r_core_config_init(RCore *core) {
NULL);
SETI ("anal.timeout", 0, "stop analyzing after a couple of seconds");
SETCB ("anal.flagends", "true", &cb_anal_flagends, "end function when a flag is found");
SETCB ("anal.icods", "true", &cb_anal_icods, "analyze indirect code references");
SETCB ("anal.jmp.retpoline", "true", &cb_anal_jmpretpoline, "analyze retpolines, may be slower if not needed");
SETCB ("anal.jmp.tailcall", "true", &cb_anal_jmptailcall, "consume a branch as a call if delta is a function");
SETICB ("anal.jmp.tailcall.delta", 0, &cb_anal_jmptailcall_delta, "consume a branch as a call if delta is big");
Expand Down Expand Up @@ -3995,9 +3999,7 @@ R_API int r_core_config_init(RCore *core) {
SETPREF ("dir.plugins", path, "path to plugin files to be loaded at startup");
free (path);
}
#if R2_USE_NEW_ABI
SETCB ("dir.source.base", "", &cb_dirsrc_base, "path to trim out from the one in dwarf");
#endif
SETCB ("dir.source", "", &cb_dirsrc, "path to find source files");
SETPREF ("dir.types", "/usr/include", "default colon-separated list of paths to find C headers to cparse types");
SETPREF ("dir.libs", "", "specify path to find libraries to load when bin.libs=true");
Expand Down
21 changes: 10 additions & 11 deletions libr/core/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -6349,10 +6349,9 @@ R_API int r_core_cmd(RCore *core, const char *cstr, bool log) {
return ret;
}

// R2_600 return bool
R_API int r_core_cmd_lines(RCore *core, const char *lines) {
R_API bool r_core_cmd_lines(RCore *core, const char *lines) {
R_RETURN_VAL_IF_FAIL (core && lines, false);
int r, ret = true;
int r;
char *data, *odata;

if (R_STR_ISEMPTY (lines)) {
Expand All @@ -6362,6 +6361,7 @@ R_API int r_core_cmd_lines(RCore *core, const char *lines) {
if (!odata) {
return false;
}
bool ret = true;
size_t line_count = r_str_char_count (lines, '\n');
const bool istty = r_cons_is_tty ();
const bool show_progress_bar = core->print->enable_progressbar \
Expand All @@ -6384,13 +6384,13 @@ R_API int r_core_cmd_lines(RCore *core, const char *lines) {
r = r_core_cmd (core, data, 0);
if (r < 0) {
data = nl + 1;
ret = -1;
ret = true; // -1;
break;
}
r_cons_flush ();
if (data[0] == 'q') {
if (data[1] == '!') {
ret = -1;
ret = true; // -1;
} else {
R_LOG_WARN ("'q': quit ignored. Use 'q!'");
}
Expand All @@ -6406,7 +6406,7 @@ R_API int r_core_cmd_lines(RCore *core, const char *lines) {
r_cons_newline ();
}
}
if (ret >= 0 && R_STR_ISNOTEMPTY (data)) {
if (ret && R_STR_ISNOTEMPTY (data)) {
r_core_cmd (core, data, 0);
r_cons_flush ();
r_core_task_yield (&core->tasks);
Expand All @@ -6415,8 +6415,7 @@ R_API int r_core_cmd_lines(RCore *core, const char *lines) {
return ret;
}

// R2_600 - return bool
R_API int r_core_cmd_file(RCore *core, const char *file) {
R_API bool r_core_cmd_file(RCore *core, const char *file) {
R_RETURN_VAL_IF_FAIL (core && file, false);
char *data = r_file_abspath (file);
if (!data) {
Expand All @@ -6436,16 +6435,16 @@ R_API int r_core_cmd_file(RCore *core, const char *file) {
return true;
}

R_API int r_core_cmd_command(RCore *core, const char *command) {
R_API bool r_core_cmd_command(RCore *core, const char *command) {
R_RETURN_VAL_IF_FAIL (core && command, -1);
char *cmd = r_core_sysenv_begin (core, command);
int len;
char *buf = r_sys_cmd_str (cmd, 0, &len);
if (!buf) {
free (cmd);
return -1;
return false;
}
int ret = r_core_cmd_lines (core, buf);
bool ret = r_core_cmd_lines (core, buf);
r_core_sysenv_end (core, command);
free (buf);
return ret;
Expand Down
6 changes: 4 additions & 2 deletions libr/core/cmd_info.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2164,8 +2164,10 @@ static int cmd_info(void *data, const char *input) {
}
input = input + strlen (input) - 1;
break;
case 'a': // "iA"
if (input[1] == 'j') {
case 'a': // "ia"
if (r_str_startswith (input, "iaito")) {
R_LOG_ERROR ("Missing plugin. Run: r2pm -ci r2iaito");
} else if (input[1] == 'j') {
pj_o (pj); // weird
r_bin_list_archs (core->bin, pj, 'j');
pj_end (pj);
Expand Down
4 changes: 0 additions & 4 deletions libr/core/disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2235,22 +2235,18 @@ static void ds_show_functions(RDisasmState *ds) {
RAnalVar *var;
RListIter *iter;

#if R2_USE_NEW_ABI
int skipped = 0;
if (f->addr == core->offset) {
skipped = core->skiplines;
}
#endif
RList *all_vars = vars_cache.rvars;
r_list_join (all_vars, vars_cache.bvars);
r_list_join (all_vars, vars_cache.svars);
r_list_foreach (all_vars, iter, var) {
#if R2_USE_NEW_ABI
if (skipped > 0) {
skipped--;
continue;
}
#endif
ds_begin_line (ds);
int idx;
RAnal *anal = ds->core->anal;
Expand Down
13 changes: 1 addition & 12 deletions libr/include/r_bin.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,9 +463,7 @@ struct r_bin_t {
char strfilter; // string filtering
char *strpurge; // purge false positive strings
char *srcdir; // dir.source
#if R2_USE_NEW_ABI
char *srcdir_base; // dir.source.base
#endif
char *prefix; // bin.prefix
char *strenc;
ut64 filter_rules;
Expand Down Expand Up @@ -603,14 +601,9 @@ typedef struct r_bin_class_t {
int index; // should be unsigned?
ut64 addr;
char *ns; // namespace // maybe RBinName?
#if R2_USE_NEW_ABI
// Use RVec here
RList *methods; // <RBinSymbol>
RList *fields; // <RBinField>
#else
// R2_600 - Use RVec here
RList *methods; // <RBinSymbol>
RList *fields; // <RBinField>
#endif
// RList *interfaces; // <char *>
RBinAttribute attr;
ut64 lang;
Expand Down Expand Up @@ -914,11 +907,7 @@ R_API void r_bin_name_filtered(RBinName *bn, const char *fname);
R_API void r_bin_name_free(RBinName *bn);

R_API char *r_bin_attr_tostring(ut64 attr, bool singlechar);
#if R2_USE_NEW_ABI
R_API ut64 r_bin_attr_fromstring(const char *s, bool compact);
#else
R_API ut64 r_bin_attr_fromstring(const char *s);
#endif

/* filter.c */
typedef struct HtSU_t HtSU;
Expand Down
8 changes: 3 additions & 5 deletions libr/include/r_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,7 @@ typedef struct {
int y;
} VisualMark;

#if R2_USE_NEW_ABI
typedef struct RCorePriv RCorePriv;
#endif

struct r_core_t {
RBin *bin;
Expand Down Expand Up @@ -514,9 +512,9 @@ R_API R_MUSTUSE char *r_core_cmd_strf(RCore *core, const char *fmt, ...) R_PRINT
R_API R_MUSTUSE char *r_core_cmd_strf_at(RCore *core, ut64 addr, const char *fmt, ...) R_PRINTF_CHECK(3, 4);
R_API R_MUSTUSE char *r_core_cmd_str_pipe(RCore *core, const char *cmd);
R_API R_MUSTUSE RBuffer *r_core_cmd_tobuf(RCore *core, const char *cmd);
R_API int r_core_cmd_file(RCore *core, const char *file);
R_API int r_core_cmd_lines(RCore *core, const char *lines);
R_API int r_core_cmd_command(RCore *core, const char *command);
R_API bool r_core_cmd_file(RCore *core, const char *file);
R_API bool r_core_cmd_lines(RCore *core, const char *lines);
R_API bool r_core_cmd_command(RCore *core, const char *command);
R_API void r_core_af(RCore *core, ut64 addr, const char *name, bool anal_calls);
R_API bool r_core_run_script(RCore *core, const char *file);
R_API bool r_core_seek(RCore *core, ut64 addr, bool rb);
Expand Down
3 changes: 0 additions & 3 deletions libr/include/r_core_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef R2_CORE_PRIV_H
#define R2_CORE_PRIV_H

#if R2_USE_NEW_ABI
#ifdef __cplusplus
extern "C" {
#endif
Expand All @@ -19,5 +18,3 @@ typedef struct {
#endif

#endif

#endif
15 changes: 0 additions & 15 deletions libr/include/r_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,8 @@ R_API void r_list_split(RList *list, void *ptr);
R_API void r_list_split_iter(RList *list, RListIter *iter);
R_API int r_list_join(RList *list1, RList *list2);
R_API void *r_list_get_n(const RList *list, int n);
#if R2_USE_NEW_ABI
R_API RListIter *r_list_get_nth(const RList *list, int n);
#else
static inline RListIter *r_list_get_nth(const RList *list, int n) {
RListIter *it;
int i;
for (it = list->head, i = 0; it && it->data; it = it->n, i++) {
if (i == n) {
return it;
}
}
return NULL;
}
#endif
R_API int r_list_del_n(RList *list, int n);
R_DEPRECATE R_API void *r_list_get_top(const RList *list);
R_DEPRECATE R_API void *r_list_get_bottom(const RList *list);
R_API void r_list_iter_to_top(RList *list, RListIter *iter);
R_API void *r_list_pop(RList *list);
R_API void *r_list_pop_head(RList *list);
Expand Down
2 changes: 0 additions & 2 deletions libr/include/r_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,7 @@ typedef struct r_run_profile_t {
int _timeout;
int _timeout_sig;
int _nice;
#if R2_USE_NEW_ABI
bool _stderrout;
#endif
} RRunProfile;

R_API RRunProfile *r_run_new(R_NULLABLE const char *str);
Expand Down
2 changes: 0 additions & 2 deletions libr/include/r_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ int gettimeofday (struct timeval* p, void* tz);
#include "r_util/r_axml.h"
// requires io, core, ... #include "r_util/r_print.h"

#if R2_USE_NEW_ABI
R_API int r_lz4_compress(ut8 *obuf, ut8 *buf, size_t buf_size, const int max_chain);
R_API ut8 *r_lz4_decompress(const ut8* input, size_t input_size, size_t *output_size);
#endif

#ifdef __cplusplus
extern "C" {
Expand Down
3 changes: 0 additions & 3 deletions libr/include/r_util/r_base32.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@
extern "C" {
#endif

#if R2_USE_NEW_ABI

#include <r_util/r_base32.h>

R_API char *r_base32_encode(const ut8 *data, size_t input_length, size_t *output_length);
R_API ut8 *r_base32_decode(const char *data, size_t input_length, size_t *output_length);
R_API char *base32_encode_ut64(ut64 input);
R_API ut64 base32_decode_ut64(const char *input);
#endif

#ifdef __cplusplus
}
Expand Down
Loading
Loading