]> git.feebdaed.xyz Git - 0xmirror/radare2.git/commitdiff
Remove anal.a2f and the a2f core plugin, it's in anal already ##analysis
authorpancake <pancake@nowsecure.com>
Mon, 22 Dec 2025 20:12:03 +0000 (21:12 +0100)
committerGitHub <noreply@github.com>
Mon, 22 Dec 2025 20:12:03 +0000 (21:12 +0100)
31 files changed:
dist/plugins-cfg/plugins.android.cfg
dist/plugins-cfg/plugins.bin.cfg
dist/plugins-cfg/plugins.cs4.cfg
dist/plugins-cfg/plugins.cs6.cfg
dist/plugins-cfg/plugins.def.cfg
dist/plugins-cfg/plugins.emscripten.cfg
dist/plugins-cfg/plugins.ios-store.cfg
dist/plugins-cfg/plugins.ios.cfg
dist/plugins-cfg/plugins.mingw.cfg
dist/plugins-cfg/plugins.nocs.cfg
dist/plugins-cfg/plugins.nogpl.cfg
dist/plugins-cfg/plugins.sdk.cfg
dist/plugins-cfg/plugins.static.cfg
dist/plugins-cfg/plugins.static.nogpl.cfg
dist/plugins-cfg/plugins.termux.cfg
dist/plugins-cfg/plugins.tiny.cfg
dist/plugins-cfg/plugins.uefi.cfg
dist/plugins-cfg/plugins.vinix.cfg
dist/plugins-cfg/plugins.wasi.cfg
libr/cons/d/bluy
libr/core/canal.c
libr/core/cconfig.c
libr/core/cmd_anal.inc.c
libr/core/meson.build
libr/core/p/Makefile
libr/core/p/a2f.mk [deleted file]
libr/core/p/core_a2f.c [deleted file]
libr/include/r_anal.h
libr/include/r_core.h
libr/meson.build
test/db/cmd/slow

index d539effbec91f69dd1cbd4bf2633a3e25b5860e0..b06dc61965531f2faec8789e1e477e18db57405e 100644 (file)
@@ -54,7 +54,6 @@ bp.bf
 bp.mips
 bp.null
 bp.x86
-core.a2f
 core.agD
 core.java
 muta.aes
index 30dbd2b9a202eb9a79865851238dd90bbe001ac7..ba1d7584a3fb01fce1c93c8f9da4f7382f3da6f5 100644 (file)
@@ -55,7 +55,6 @@ bp.ppc
 bp.x86
 cmd.dummy
 core.agD
-core.a2f
 core.java
 muta.aes
 muta.charset_ascii
index 644277958340c5af6da0c695ecc00a62c839c003..a00e3b432b14794cfc5fdb6d47def5ed3b690da6 100644 (file)
@@ -153,7 +153,6 @@ bp.mips
 bp.ppc
 bp.riscv
 bp.x86
-core.a2f
 core.java
 core.sixref
 codec.aes
index 149e5711fc7660d08c72de11bd578e356f516d93..f86220f792fa03dadb947ede88edd7ca19ac3a42 100644 (file)
@@ -142,7 +142,6 @@ bp.mips
 bp.ppc
 bp.riscv
 bp.x86
-core.a2f
 core.java
 core.sixref
 muta.aes
index 89d253b0758b341afe4a3ecaa730d9bb98b9bae7..8a17ae0c718bef070ea98744383bc58454b0cf6d 100644 (file)
@@ -180,7 +180,6 @@ bp.ppc
 bp.riscv
 bp.x86
 core.agD
-core.a2f
 core.writedwarf
 core.prj
 core.java
index ac7defa355d59cedff3c73ab6a550f7ed63443fb..9eb412947aade1f706fc4039c380be4ada825455 100644 (file)
@@ -19,7 +19,6 @@ cmd.dummy
 egg.xor
 lang.pipe
 core.agD
-core.a2f
 muta.base64
 muta.ed25519
 muta.xor
index 63a30bc1993bfa7a1e772b4db8c838be133d0da9..563388420f9124fcf63ff28f4ca3dbcff5be34c8 100644 (file)
@@ -43,7 +43,6 @@ bp.bf
 bp.x86
 bp.mips
 core.agD
-core.a2f
 core.java
 muta.aes
 muta.ed25519
index 1520623e17bbd2537ce1ae45a6b45d43b749197f..bbbda552e1ee71dd726340467ea31ae94b85dfa3 100644 (file)
@@ -43,7 +43,6 @@ bp.bf
 bp.x86
 bp.mips
 core.agD
-core.a2f
 core.java
 muta.aes
 muta.ed25519
index 2a69cfb065988dc60cf7f7926eef73fdab4ff872..87f6533fc0a3756aeb53b440117b33657fada3bf 100644 (file)
@@ -140,7 +140,6 @@ bp.mips
 bp.ppc
 bp.x86
 core.agD
-core.a2f
 core.sixref
 core.java
 muta.aes
index a86fd7ad0fea827e73e78384f068c1e6b335a210..e3a4afe5249a36c261b407611a61e1a48282e9ef 100644 (file)
@@ -128,7 +128,6 @@ bp.mips
 bp.ppc
 bp.x86
 core.agD
-core.a2f
 core.sixref
 core.java
 muta.aes
index 271228f279d6baa116c5516681fa41fcb17c79df..4b6e718597163778f103d502dcc0928247dddd64 100644 (file)
@@ -66,7 +66,6 @@ bp.mips
 bp.ppc
 bp.x86
 core.agD
-core.a2f
 core.java
 muta.aes
 muta.charset_ascii
index 406fedb479b4b52831fdeb1d89c8c8785924a950..4a86cba19b94ee5c78ca6bfc8693738190d45262 100644 (file)
@@ -178,7 +178,6 @@ bp.ppc
 bp.riscv
 bp.x86
 core.agD
-core.a2f
 core.writedwarf
 core.prj
 core.java
index 1393ef91a4c9a177ddf9d4f9ca069f448876f5ac..f126c32a916c8e2b93540035dc678344f13f6495 100644 (file)
@@ -109,7 +109,6 @@ bp.ppc
 bp.riscv
 bp.x86
 core.agD
-core.a2f
 core.java
 muta.aes
 muta.des
index 83c7975cec5c35fd6c889dbc1067f745063fb083..3b221bc05e6a42f4725ef3fc1783859f731cf5f9 100644 (file)
@@ -92,7 +92,6 @@ bp.bf
 bp.mips
 bp.x86
 core.agD
-core.a2f
 core.java
 muta.aes
 muta.des
index 59515a1e40713c606555ba05fa702026b26d2ea1..d9efb9e6c8cec20da5c82a93c2534a3bc50f5cf9 100644 (file)
@@ -118,7 +118,6 @@ bp.mips
 bp.ppc
 bp.x86
 core.agD
-core.a2f
 core.sixref
 core.java
 muta.aes
index 048fd0f3aef9991f9a37feb1947911507abd04f5..151e57eb4ef36887272e5f1ea911ca91475be1f8 100644 (file)
@@ -42,7 +42,6 @@ bp.bf
 bp.x86
 bp.mips
 core.agD
-core.a2f
 core.java
 muta.aes
 muta.charset_ascii
index a46203bba66b4534b6a7847e70918a0dbda2ec39..19aeb619bfa73d4185fd07cd38bac10602617ed0 100644 (file)
@@ -118,7 +118,6 @@ bp.ppc
 bp.riscv
 bp.x86
 core.agD
-core.a2f
 core.writedwarf
 core.prj
 core.java
index 0b95e087563c2a3011afa852e476b6d5bc9e1ad7..16bf61382d85d33abbc7054d592dae7ff481ce86 100644 (file)
@@ -12,7 +12,6 @@ bin.elf64
 bp.null
 bp.x86
 core.agD
-core.a2f
 muta.aes
 muta.charset_ascii
 muta.charset_ebcdic37
index 553ac1d0b195d7bee8e13d84e78105141635e970..d38c72301d3c223d74abe1d6971c7e21ab2ad505 100644 (file)
@@ -47,7 +47,6 @@ bin.wasm
 bin_xtr.xtr_fatmach0
 bin_xtr.xtr_sep64
 core.agD
-core.a2f
 core.sixref
 bp.null
 bp.arm
index 1d8abb10f09cd5e1fc21b313f006de297b3228b4..811cec300a27887b117b13f97c8990c0936c309e 100644 (file)
@@ -29,6 +29,7 @@ ec jmp white
 ec ujmp white
 ec cjmp white
 ec call rgb:6af
+ec ucall rgb:6af
 ec nop rgb:33a
 ec ret white
 ec trap blue
index 21d428b1e35da9940d522f0d8ac4cbf3917b74b8..10ef9087e1e3bae0c8ae31a1ff434700363eb8a4 100644 (file)
@@ -2184,10 +2184,6 @@ R_API bool r_core_anal_fcn(RCore *core, ut64 at, ut64 from, int reftype, int dep
                        return false;
                }
        }
-       if (r_config_get_b (core->config, "anal.a2f")) {
-               r_core_cmdf (core, ".a2f @ 0x%08"PFMT64x, at);
-               return false;
-       }
        if (use_esil) {
                return r_core_anal_esil_fcn (core, at, from, reftype, depth);
        }
@@ -6761,10 +6757,8 @@ R_API void r_core_anal_inflags(RCore *core, const char * R_NULLABLE glob) {
        R_RETURN_IF_FAIL (core);
        RList *addrs = r_list_newf (free);
        RListIter *iter;
-       const bool a2f = r_config_get_b (core->config, "anal.a2f");
        char *anal_in = strdup (r_config_get (core->config, "anal.in"));
        r_config_set (core->config, "anal.in", "block");
-       // aaFa = use a2f instead of af+
        bool simple = (!glob || *glob != 'a');
        glob = r_str_trim_head_ro (glob);
        char *addr;
@@ -6804,11 +6798,7 @@ R_API void r_core_anal_inflags(RCore *core, const char * R_NULLABLE glob) {
                        if (fcn) {
                                eprintf ("%s  %s %"PFMT64d"    # %s\n", addr, "af", sz, fcn->name);
                        } else {
-                               if (a2f) {
-                                       r_core_cmdf (core, "a2f@%s!%s-%s", addr, addr2, addr);
-                               } else {
-                                       r_core_cmdf (core, "af@%s!%s-%s", addr, addr2, addr);
-                               }
+                               r_core_cmdf (core, "af@%s!%s-%s", addr, addr2, addr);
                                fcn = r_anal_get_fcn_in (core->anal, r_num_math (core->num, addr), 0);
                                eprintf ("%s  %s %.4"PFMT64d"   # %s\n", addr, "aab", sz, fcn?fcn->name: "");
                        }
index dbda7268783a303060b684ce156d2671793f69fe..25c613600d5d3b85c3b636a74ec9b4a012ad4153 100644 (file)
@@ -3804,7 +3804,6 @@ R_API int r_core_config_init(RCore *core) {
        SETCB ("anal.syscc", analsyscc? analsyscc: "", (RConfigCallback)&cb_analsyscc, "specify default syscall calling convention");
        SETCB ("anal.verbose", "false", &cb_analverbose, "show RAnal warnings when analyzing code");
        SETB ("anal.mask", "false", "use the smart aobm command to compute the binary mask of the instruction"); // TODO: must be true by default
-       SETB ("anal.a2f", "false", "use the new WIP analysis algorithm (core/p/a2f), anal.depth ignored atm");
        SETCB ("anal.roregs", "gp,zero", (RConfigCallback)&cb_anal_roregs, "comma separated list of register names to be readonly");
        SETICB ("anal.cs", 0, (RConfigCallback)&cb_anal_cs, "set the value for the x86-16 CS segment register (see asm.addr.segment and asm.addr.segment.bits)");
        SETICB ("anal.gp", 0, (RConfigCallback)&cb_anal_gp, "set the value of the GP register (MIPS)");
index 7076ae37c06e626cefa0fe7a6ce31f85b28af269..c78aa437a01a1f21f3a03581828b8d8d95498ee1 100644 (file)
@@ -196,7 +196,7 @@ static RCoreHelpMessage help_msg_aa = {
        "aaef", "", "analyze references with ESIL in all functions",
        "aaf", "[?][efrt] ", "analyze all functions relationships with flags, type matching and consecutive",
        "aaF", " [sym*]", "set anal.in=block for all the spaces between flags matching glob",
-       "aaFa", " [sym*]", "same as aaF but uses af/a2f instead of af+/afb+ (slower but more accurate)",
+       "aaFa", " [sym*]", "same as aaF but uses af instead of af+/afb+ (slower but more accurate)",
        "aai", "[j]", "show info of all analysis parameters",
        "aaj", " ", "analyze all jumps",
        "aan", "[?][fgr]", "autoname functions (aang = golang, aanr = noreturn propagation, aanf = afna@@F)",
index e87c0284746a3262614193d59493517fc8de6fdc..6d8115a970b5844e6ca6c193ecd27384aa194afc 100644 (file)
@@ -46,8 +46,9 @@ r_core_sources = [
   'vmenus_zigns.c',
   'yank.c',
   'p/core_agD.c',
-  'p/core_a2f.c',
   'p/core_sixref.c',
+  'p/core_writedwarf.c',
+  'p/core_prj.c',
   'p/core_java.c'
 ]
 
index 25f6238aa095b03dc7b19b35b7649fd04d9cc7a7..6059649b3e5930dbfe076d2b7b0fed66394152a1 100644 (file)
@@ -26,7 +26,7 @@ ifeq ($(WITHPIC),1)
 all: ${ALL_TARGETS}
 
 ALL_TARGETS=
-PLUGS=java.mk a2f.mk sixref.mk agD.mk
+PLUGS=java.mk sixref.mk agD.mk
 include $(PLUGS)
 
 clean:
diff --git a/libr/core/p/a2f.mk b/libr/core/p/a2f.mk
deleted file mode 100644 (file)
index 9977ef6..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-CORE_OBJ_A2F=core_a2f.o
-
-STATIC_OBJ+=${CORE_OBJ_A2F}
-CORE_TARGET_A2F=core_a2f.${EXT_SO}
-
-ifeq ($(WITHPIC),1)
-ALL_TARGETS+=${CORE_TARGET_A2F}
-
-${CORE_TARGET_A2F}: ${CORE_OBJ_A2F}
-       ${CC} $(call libname,core_anal) ${CFLAGS} \
-               -o core_a2f.${EXT_SO} \
-               $(SHLR)/../subprojects/sdb/src/libsdb.a \
-               -L$(LIBR)/muta -lr_muta \
-               ${CORE_OBJ_A2F}
-endif
diff --git a/libr/core/p/core_a2f.c b/libr/core/p/core_a2f.c
deleted file mode 100644 (file)
index 5f55209..0000000
+++ /dev/null
@@ -1,439 +0,0 @@
-/* radare - Copyright 2014-2025 - pancake, defragger */
-
-#define R_LOG_ORIGIN "a2f"
-
-#include <r_core.h>
-
-#define MAXFCNSIZE 4096
-
-#define Fbb(x) r_strf("bb.%"PFMT64x,x)
-#define Fhandled(x) r_strf("handled.%"PFMT64x,x)
-#define FbbTo(x) r_strf("bb.%"PFMT64x".to",x)
-
-static ut64 getCrossingBlock(Sdb *db, const char *key, ut64 start, ut64 end) {
-       r_strf_buffer (64);
-       ut64 nearest_start = UT64_MAX;
-       const char *s = sdb_const_get (db, key, NULL);
-       if (!s) {
-               return UT64_MAX;
-       }
-       const char *ptr = s;
-       const char *next = NULL;
-       do {
-               next = sdb_const_anext (ptr);
-               const ut64 block_start = sdb_atoi (ptr);
-
-               if (start == block_start) { // case 5
-                       return start;
-               }
-
-               const ut64 block_end = sdb_num_get (db, Fbb (block_start), NULL);
-               if (block_end) {
-                       if (start > block_start && start < block_end) { // case 2
-                               // start is inside the block
-                               return block_start;
-                       }
-                       if (start < block_start && end >= block_end) {
-                               // crossing the start of the block
-                               if (nearest_start > block_start) {
-                                       nearest_start = block_start;
-                               }
-                       }
-               }
-               ptr = next;
-       } while (next);
-
-       return nearest_start;
-}
-
-/*
- bb.<addr-of-basic-block>=<end-address-of-basic-block>
- bb.<addr-of-basic-block>.to=array,of,destination,addresses
-*/
-
-static int bbAdd(Sdb *db, ut64 from, ut64 to, ut64 jump, ut64 fail) {
-       r_strf_buffer (64);
-       ut64 block_start = getCrossingBlock (db, "bbs", from, to);
-       bool add = true;
-       if (block_start == UT64_MAX) {
-               // add = 1;
-       } else if (block_start == from) {
-               // check if size is the same,
-               add = false;
-       } else {
-               /*
-                  from = start address of new basic block
-                  to = end address of new basic block
-                  jump = destination basic block
-                  fail = fallback jump of basic block
-                  addr = previous closer basic block start address
-                  addr_end = previous closer basic block start address
-                */
-               // found a possible block
-               if (from > block_start) {
-                       // from inside
-                       // RESIZE this
-                       r_strf_var (bbst, 64, "bb.%"PFMT64x, block_start);
-                       r_strf_var (bben, 64, "bb.%"PFMT64x".to", block_start);
-                       sdb_num_set (db, bbst, from, 0);
-                       sdb_num_set (db, bben, from, 0);
-                       sdb_array_set_num (db, bben, 0, from, 0);
-                       sdb_array_set_num (db, bben, 1, UT64_MAX, 0);
-               } else {
-                       // < the current runs into a known block
-                       to = block_start;
-                       jump = block_start;
-                       fail = UT64_MAX;
-               }
-       }
-       if (add) {
-               sdb_array_add_num (db, "bbs", from, 0);
-               sdb_num_set (db, Fbb (from), to, 0);
-               sdb_array_set_num (db, FbbTo (from), 0, jump, 0);
-               sdb_array_set_num (db, FbbTo (from), 1, fail, 0);
-               sdb_num_min (db, "min", from, 0);
-               sdb_num_max (db, "max", to, 0);
-       }
-       return 0;
-}
-
-void addTarget(RCore *core, RStack *stack, Sdb *db, ut64 addr) {
-       r_strf_buffer (64);
-       if (sdb_num_get (db, Fhandled (addr), NULL)) {
-               // already set
-               return;
-       }
-       ut64* value = (ut64*) calloc (1, sizeof (ut64));
-       if (!value) {
-               R_LOG_DEBUG ("Failed to allocate memory for address stack");
-               return;
-       }
-       *value = addr;
-       if (!r_stack_push (stack, (void*)value)) {
-               R_LOG_DEBUG ("Failed to push address on stack");
-               free (value);
-               return;
-       }
-       sdb_num_set (db, Fhandled (addr), 1, 0);
-}
-
-static ut64 analyzeStackBased(RCore *core, Sdb *db, ut64 addr, RList *delayed_commands) {
-#define addCall(x) sdb_array_add_num (db, "calls", x, 0);
-#define addUcall(x) sdb_array_add_num (db, "ucalls", x, 0);
-#define addUjmp(x) sdb_array_add_num (db, "ujmps", x, 0);
-#define addCjmp(x) sdb_array_add_num (db, "cjmps", x, 0);
-#define addRet(x) sdb_array_add_num (db, "rets", x, 0);
-#define bbAddOpcode(x) sdb_array_insert_num (db, r_strf ("bb.%"PFMT64x, addr+cur), -1, x, 0);
-       r_strf_buffer (32);
-       ut64 oaddr = addr;
-       ut64 *value = NULL;
-       RAnalOp *op;
-       int cur = 0;
-       bool block_end = false;
-       RStack *stack = r_stack_newf (10, free);
-       addTarget (core, stack, db, addr);
-       const ut64 maxfcnsize = 1024 * 32;
-
-       while (!r_stack_is_empty (stack)) {
-               block_end = false;
-               value = (ut64*) r_stack_pop (stack);
-               if (!value) {
-                       R_LOG_ERROR ("Failed to pop next address from stack");
-                       break;
-               }
-
-               addr = *value;
-               free (value);
-               cur = 0;
-               while (!block_end && cur < maxfcnsize) {
-                       op = r_core_anal_op (core, addr + cur, R_ARCH_OP_MASK_BASIC | R_ARCH_OP_MASK_DISASM);
-                       if (!op || !op->mnemonic) {
-                               R_LOG_DEBUG ("Cannot analyze opcode at 0x%"PFMT64x, addr+cur);
-                               oaddr = UT64_MAX;
-                               break;
-                       }
-                       if (op->mnemonic[0] == '?') {
-                               R_LOG_DEBUG ("Cannot analyze opcode at 0x%"PFMT64x, addr+cur);
-                               oaddr = UT64_MAX;
-                               break;
-                       }
-
-                       bbAddOpcode (addr + cur);
-                       switch (op->type) {
-                       case R_ANAL_OP_TYPE_NOP:
-                               // skip nops
-                               if (cur == 0) {
-                                       cur -= op->size;
-                                       addr += op->size;
-                                       oaddr += op->size;
-                               }
-                               break;
-                       case R_ANAL_OP_TYPE_CALL:
-                               /* A call instruction implies that the destination
-                                * is a new function unless the address is inside
-                                * the same range than the current function */
-                               addCall (op->jump);
-                               r_list_append (delayed_commands, r_str_newf ("axC %"PFMT64d" %"PFMT64d, op->jump, addr + cur));
-                               break;
-                       case R_ANAL_OP_TYPE_UCALL:
-                       case R_ANAL_OP_TYPE_ICALL:
-                       case R_ANAL_OP_TYPE_RCALL:
-                       case R_ANAL_OP_TYPE_IRCALL:
-                       case R_ANAL_OP_TYPE_CCALL:
-                       case R_ANAL_OP_TYPE_UCCALL:
-                               /* unknown calls depend on ESIL or DEBUG tracing
-                                * information to know the destination, we can mark
-                                * those 'calls' for later adding tracepoints in
-                                * there to record all possible destinations */
-                               addUcall (addr + cur);
-                               if (op->ptr != UT64_MAX) {
-                                       r_list_append (delayed_commands, r_str_newf ("axC %"PFMT64d" %"PFMT64d, op->ptr, addr + cur));
-                               }
-                               break;
-                       case R_ANAL_OP_TYPE_MJMP:
-                       case R_ANAL_OP_TYPE_MCJMP:
-                       case R_ANAL_OP_TYPE_UCJMP:
-                       case R_ANAL_OP_TYPE_UJMP:
-                       case R_ANAL_OP_TYPE_RJMP:
-                       case R_ANAL_OP_TYPE_IJMP:
-                       case R_ANAL_OP_TYPE_IRJMP:
-                               /* an unknown jump use to go into computed destinations
-                                * outside the current function, but it may result
-                                * on an antidisasm trick */
-                               addUjmp (addr + cur);
-                               /* An unknown jump breaks the basic blocks */
-                               block_end = true; // XXX more investigation here
-                               break;
-                       case R_ANAL_OP_TYPE_TRAP:
-                               if (cur == 0) {
-                                       // skip leading int3
-                                       cur -= op->size;
-                                       addr += op->size;
-                                       oaddr += op->size;
-                               } else {
-                                       block_end = true;
-                               }
-                               break;
-                       case R_ANAL_OP_TYPE_CRET:
-                       case R_ANAL_OP_TYPE_RET:
-                               addRet (addr + cur);
-                               bbAdd (db, addr, addr + cur + op->size, UT64_MAX, UT64_MAX);
-                               block_end = true;
-                               break;
-                       case R_ANAL_OP_TYPE_CJMP:
-                               addCjmp (addr+cur);
-                               bbAdd (db, addr, addr + cur + op->size, op->jump, addr + cur + op->size);
-                               addTarget (core, stack, db, op->jump);
-                               addTarget (core, stack, db, addr + cur + op->size);
-                               block_end = true;
-                               r_list_append (delayed_commands, r_str_newf ("axc %"PFMT64d" %"PFMT64d, op->jump, addr + cur));
-                               break;
-                       case R_ANAL_OP_TYPE_JMP:
-                               addUjmp (addr+cur);
-                               bbAdd (db, addr, addr + cur + op->size, op->jump, UT64_MAX);
-                               addTarget (core, stack, db, op->jump);
-                               block_end = true;
-                               r_list_append (delayed_commands, r_str_newf ("axc %"PFMT64d" %"PFMT64d, op->jump, addr + cur));
-                               break;
-                       case R_ANAL_OP_TYPE_UNK:
-                       case R_ANAL_OP_TYPE_ILL:
-                               R_LOG_DEBUG ("Invalid instruction");
-                               block_end = true;
-                               break;
-                       default:
-                               if (op->ptr != UT64_MAX) {
-                                       r_list_append (delayed_commands, r_str_newf ("axd %"PFMT64d" %"PFMT64d, op->ptr, addr + cur));
-                               }
-                               break;
-                       }
-                       cur += op->size;
-                       r_anal_op_free (op);
-                       op = NULL;
-               }
-       }
-       if (block_end) {
-               bbAdd (db, addr, addr + cur, UT64_MAX, UT64_MAX);
-       }
-       r_stack_free (stack);
-       return oaddr;
-}
-
-static ut64 getFunctionSize(Sdb *db) {
-       r_strf_buffer (64);
-       ut64 min = UT64_MAX, max = 0;
-       char *c, *bbs = sdb_get (db, "bbs", NULL);
-       bool first = true;
-       sdb_aforeach (c, bbs) {
-               ut64 addr = sdb_atoi (c);
-               ut64 addr_end = sdb_num_get (db, Fbb (addr), NULL);
-               if (first) {
-                       min = addr;
-                       max = addr_end;
-                       first = false;
-               } else {
-                       if (addr < min) {
-                               min = addr;
-                       }
-                       if (addr_end > max) {
-                               max = addr_end;
-                       }
-               }
-               sdb_aforeach_next (c);
-       }
-       free (bbs);
-       return max - min;
-}
-
-static bool analyzeFunction(RCore *core, ut64 addr) {
-       r_strf_buffer (64);
-       Sdb *db = sdb_new0 ();
-       RFlagItem *fi;
-       RListIter *iter;
-       ut64 loc_addr = 0;
-       char *command = NULL;
-       char *function_label;
-       bool vars = r_config_get_b (core->config, "anal.vars");
-       if (!db) {
-               R_LOG_ERROR ("Cannot create db");
-               return false;
-       }
-
-       RList *delayed_commands = r_list_newf (free);
-       if (!delayed_commands) {
-               sdb_free (db);
-               return false;
-       }
-
-       ut64 a = analyzeStackBased (core, db, addr, delayed_commands);
-       if (addr == UT64_MAX) {
-               R_LOG_ERROR ("Initial analysis failed");
-               return false;
-       }
-       if (a != UT64_MAX) {
-               addr = a;
-       }
-       sdb_num_set (db, "addr", addr, 0);
-
-       //TODO add the possible addresses to the analysis stack
-       //TODO add xrefs
-       //eprintf ("addr: %s\n", sdb_const_get (db, "addr", NULL));
-       //eprintf ("calls: %s\n", sdb_const_get (db, "calls", NULL));
-       //eprintf ("ucalls: %s\n", sdb_const_get (db, "ucalls", NULL));
-       //eprintf ("cjmps: %s\n", sdb_const_get (db, "cjmps", NULL));
-       //eprintf ("ujmps: %s\n", sdb_const_get (db, "ujmps", NULL));
-       //eprintf ("rets: %s\n", sdb_const_get (db, "rets", NULL));
-       //eprintf ("bbs: %s\n", sdb_const_get (db, "bbs", NULL));
-
-       // fcnfit to get fcn size
-       sdb_num_set (db, "size", getFunctionSize (db), 0);
-
-       // receiving a possible flag to label the new function
-       fi = r_flag_get_at (core->flags, addr, false);
-       if (fi && fi->name && strncmp (fi->name, "sect", 4)) {
-               function_label = strdup (fi->name);
-       } else {
-               function_label = r_str_newf ("fcn.%08"PFMT64x, addr);
-       }
-       // loc_addr = core->addr; // sdb_num_get (db, "addr", NULL);
-       loc_addr = sdb_num_get (db, "addr", NULL);
-       RAnalFunction *fcn_at_addr = r_anal_get_function_at (core->anal, loc_addr);
-       if (fcn_at_addr) {
-               return false;
-       }
-
-       // eprintf ("af+ 0x%08"PFMT64x" %s\n", loc_addr, function_label);
-       r_core_cmdf (core, "af+ 0x%08"PFMT64x" %s", loc_addr, function_label);
-       {
-               char *c, *bbs = sdb_get (db, "bbs", NULL);
-               sdb_aforeach (c, bbs) {
-                       ut64 addr = sdb_atoi (c);
-                       ut64 addr_end = sdb_num_get (db, Fbb (addr), NULL);
-                       // check if call destination is inside the function boundaries
-                       ut64 jump = sdb_array_get_num (db, FbbTo (addr), 0, NULL);
-                       ut64 fail = sdb_array_get_num (db, FbbTo (addr), 1, NULL);
-
-                       // eprintf ("afb+ 0x%"PFMT64x" 0x%"PFMT64x" %d 0x%"PFMT64x" 0x%"PFMT64x"\n",
-                       //      loc_addr, addr, (int)(addr_end - addr), jump, fail);
-                       r_core_cmdf (core, "afb+ 0x%"PFMT64x" 0x%"PFMT64x" %d 0x%"PFMT64x" 0x%"PFMT64x,
-                               loc_addr, addr, (int)(addr_end - addr), jump, fail);
-                       sdb_aforeach_next (c);
-               }
-               if (vars) {
-                       // handling arguments
-                       RAnalFunction *fcn = r_anal_get_function_at (core->anal, addr);
-                       if (fcn && !r_list_empty (fcn->bbs)) {
-                               r_core_cmdf (core, "afva @ 0x%"PFMT64x, addr);
-                       }
-               }
-               free (bbs);
-               free (function_label);
-       }
-       r_list_foreach (delayed_commands, iter, command) {
-               if (command) {
-                       r_core_cmd0 (core, command);
-                       command = NULL;
-               }
-       }
-       // TODO
-       // xrefs are added but are not mentioned in afi
-       // analyze next calls
-       //      {
-       //              char *c, *calls = sdb_get (db, "calls", NULL);
-       //              sdb_aforeach (c, calls) {
-       //                      ut64 addr = sdb_atoi (c);
-       //                      eprintf ("a2f @ 0x%"PFMT64x"\n", addr);
-       //                      sdb_aforeach_next (c);
-       //              }
-       //              free (calls);
-       //      }
-       r_list_free (delayed_commands);
-       sdb_free (db);
-       return true;
-}
-
-static RCoreHelpMessage help_msg_a2f = {
-       "Usage:", "a2f", "Experimental function analysis",
-       "a2f", "", "like af, but with an experimental engine. see anal.a2f",
-       NULL
-};
-
-static bool r_cmd_anal_call(RCorePluginSession *cps, const char *input) {
-       RCore *core = cps->core;
-       if (r_str_startswith (input, "a2")) {
-               switch (input[2]) {
-               case 'f':
-                       if (input[3] == '?') {
-                               r_core_cmd_help (core, help_msg_a2f);
-                               return true;
-                       }
-                       if (!analyzeFunction (core, core->addr)) {
-                               R_LOG_DEBUG ("Failed to analyze function at 0x%08"PFMT64x, core->addr);
-                       }
-                       break;
-               default:
-                       r_core_cmd_help (core, help_msg_a2f);
-                       break;
-               }
-               return true;
-       }
-       return false;
-}
-
-// PLUGIN Definition Info
-RCorePlugin r_core_plugin_a2f = {
-       .meta = {
-               .name = "a2f",
-               .desc = "The reworked analysis from scratch thing",
-               .author = "pancake",
-               .license = "MIT",
-       },
-       .call = r_cmd_anal_call,
-};
-
-#ifndef R2_PLUGIN_INCORE
-R_API RLibStruct radare_plugin = {
-       .type = R_LIB_TYPE_CORE,
-       .data = &r_core_plugin_a2f,
-       .version = R2_VERSION
-};
-#endif
index 1742d593e3c5b3a083781a253f2d016e658b412c..d1a563233223a05fcf001dd9cb42a4d24c778dbf 100644 (file)
@@ -1681,9 +1681,9 @@ R_API void r_anal_backtrace_fini(RAnal *a);
 R_API void r_anal_backtrace_list(RAnal *a, ut64 addr, int opt);
 
 /* plugin pointers */
-extern RAnalPlugin r_anal_plugin_a2f;
 extern RAnalPlugin r_anal_plugin_blaze;
 extern RAnalPlugin r_anal_plugin_null;
+extern RAnalPlugin r_anal_plugin_a2f;
 extern RAnalPlugin r_anal_plugin_path;
 extern RAnalPlugin r_anal_plugin_sbpf;
 extern RAnalPlugin r_anal_plugin_tcc;
index b12480e7393bf8cf3819cf64526b704c17cd9b29..93ee86d3c31cd029ec7083ae99e12a30d3793348 100644 (file)
@@ -1016,7 +1016,6 @@ R_API void r_core_anal_propagate_noreturn(RCore *core, ut64 addr);
 
 /* PLUGINS */
 extern RCorePlugin r_core_plugin_java;
-extern RCorePlugin r_core_plugin_a2f;
 extern RCorePlugin r_core_plugin_prj;
 extern RCorePlugin r_core_plugin_writedwarf;
 extern RCorePlugin r_core_plugin_sixref;
index 0ee5b6d444a2268850c676bf9d96619223e276d7..41d0647c7f78bd11010c408ca9d80a4e433c25c7 100644 (file)
@@ -17,7 +17,7 @@ if get_option('use_zip')
 endif
 bp_plugins = [ 'null' ]
 muta_plugins = [ 'null' ]
-core_plugins = [ 'a2f', 'agD' ]
+core_plugins = [ 'prj', 'writedwarf', 'agD' ]
 egg_plugins = [ 'xor' ]
 debug_plugins = [ 'null', 'io', 'esil', 'rap' ]
 lang_plugins = [ 'lib', 'pipe', 'qjs', 'tsc', 'spp' ]
@@ -304,7 +304,6 @@ if get_option('plugins') == ''
   ]
 
   core_plugins += [
-    'a2f',
     'agD',
     'java'
   ]
index 65932b34e672b26f39859aef5bd55e3411b2e206..c44348df2d968037dfc0265c6809c2f1be04db11 100644 (file)
 NAME=MZ: unzip.exe - open
 FILE=bins/mz/unzip.exe
 CMDS=<<EOF
-?e === aa
+?e === aa-hasnext
 af-*
 e anal.hasnext=false
-e anal.a2f=false
 aa
 aflc
 ?e === aa+hasnext
 e anal.hasnext=true
 aa
 aflc
-?e === aac+a2f+next
+?e === aac-next
 af-*
-e anal.a2f=true
-e anal.hasnext=true
+e anal.hasnext=false
 aac
 aflc
-?e === aac-a2f+next
+?e === aac+next
 af-*
-e anal.a2f=false
 e anal.hasnext=true
 aac
 aflc
-?e === aac-a2f-next
-af-*
-e anal.a2f=false
-e anal.hasnext=false
-aac
-aflc
 EOF
 EXPECT=<<EOF
-=== aa
+=== aa-hasnext
 1
 === aa+hasnext
 34
-=== aac+a2f+next
-194
-=== aac-a2f+next
-294
-=== aac-a2f-next
+=== aac-next
 199
-EOF
-EXPECT_ERR=<<EOF
-WARN: Relocs has not been applied. Please use `-e bin.relocs.apply=true` or `-e bin.cache=true` next time
-INFO: Analyze all flags starting with sym. and entry0 (aa)
-INFO: Analyze imports (af@@@i)
-INFO: Analyze entrypoint (af@ entry0)
-INFO: Analyze symbols (af@@@s)
-INFO: Recovering variables (afva@@F)
-INFO: Analyze all functions arguments/locals (afva@@F)
-INFO: Analyze all flags starting with sym. and entry0 (aa)
-INFO: Analyze imports (af@@@i)
-INFO: Analyze entrypoint (af@ entry0)
-\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\rINFO: Analyze symbols (af@@@s)
-INFO: Recovering variables (afva@@F)
-INFO: Analyze all functions arguments/locals (afva@@F)
-ERROR: afb+: Cannot add basic block at 0x0001fc4c with size 1
-ERROR: afb+: Cannot add basic block at 0x0001dfcf with size 1
-\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\r\e[2K\rERROR: Cannot find basic block
-ERROR: Cannot find basic block
-ERROR: Cannot find basic block
-ERROR: Cannot find basic block
-ERROR: Cannot find basic block
-ERROR: Cannot find basic block
+=== aac+next
+294
 EOF
 RUN