From f0b8a61f25a9268103f773b5104e43842b10b099 Mon Sep 17 00:00:00 2001 From: pancake Date: Thu, 14 Sep 2023 01:21:59 +0200 Subject: [PATCH] Deprecate RBinPlugin.file_type() field --- doc/cross-compile.md | 6 +++--- libr/bin/bobj.c | 8 +++----- libr/bin/p/bin_cgc.c | 1 - libr/bin/p/bin_elf.c | 1 - libr/bin/p/bin_elf.inc.c | 8 -------- libr/bin/p/bin_elf64.c | 1 - libr/include/r_bin.h | 1 - 7 files changed, 6 insertions(+), 20 deletions(-) diff --git a/doc/cross-compile.md b/doc/cross-compile.md index 57197402c7..9b7365b88e 100644 --- a/doc/cross-compile.md +++ b/doc/cross-compile.md @@ -4,7 +4,7 @@ https://github.com/dockcross/dockcross Here's and example on how changes required for i.e ARMv5 (no hard float) borrowed from `mk/armel.mk`: -``` +```bash ARCH=arm CROSS_ROOT=/usr/bin CROSS_TRIPLET=${ARCH}-linux-gnueabi @@ -34,5 +34,5 @@ $ dockcross make Here is some more context and references: -https://github.com/radareorg/radare2/pull/5060 -https://blogs.nopcode.org/brainstorm/2016/07/26/cross-compiling-with-docker +* https://github.com/radareorg/radare2/pull/5060 +* https://blogs.nopcode.org/brainstorm/2016/07/26/cross-compiling-with-docker diff --git a/libr/bin/bobj.c b/libr/bin/bobj.c index c20244d482..0ff968be4b 100644 --- a/libr/bin/bobj.c +++ b/libr/bin/bobj.c @@ -285,9 +285,9 @@ R_API int r_bin_object_set_items(RBinFile *bf, RBinObject *bo) { int minlen = (bf->rbin->minstrlen > 0) ? bf->rbin->minstrlen : p->minstrlen; bf->bo = bo; - if (p->file_type) { - int type = p->file_type (bf); - if (type == R_BIN_TYPE_CORE) { + bo->info = p->info? p->info (bf): NULL; + if (bo->info->type) { + if (strstr (bo->info->type, "CORE")) { if (p->regstate) { bo->regstate = p->regstate (bf); } @@ -296,7 +296,6 @@ R_API int r_bin_object_set_items(RBinFile *bf, RBinObject *bo) { } } } - // XXX: no way to get info from xtr pluginz? // Note, object size can not be set from here due to potential // inconsistencies @@ -350,7 +349,6 @@ R_API int r_bin_object_set_items(RBinFile *bf, RBinObject *bo) { } } } - bo->info = p->info? p->info (bf): NULL; if (p->libs) { bo->libs = p->libs (bf); } diff --git a/libr/bin/p/bin_cgc.c b/libr/bin/p/bin_cgc.c index 90af51b2b4..8f702dc777 100644 --- a/libr/bin/p/bin_cgc.c +++ b/libr/bin/p/bin_cgc.c @@ -119,7 +119,6 @@ RBinPlugin r_bin_plugin_cgc = { .create = &create, .patch_relocs = &patch_relocs, .write = &r_bin_write_elf, - .file_type = get_file_type, .regstate = regstate, .maps = maps, }; diff --git a/libr/bin/p/bin_elf.c b/libr/bin/p/bin_elf.c index 1897b8709f..a9ac352ca1 100644 --- a/libr/bin/p/bin_elf.c +++ b/libr/bin/p/bin_elf.c @@ -152,7 +152,6 @@ RBinPlugin r_bin_plugin_elf = { .dbginfo = &r_bin_dbginfo_elf, .create = &create, .write = &r_bin_write_elf, - .file_type = &get_file_type, .regstate = ®state, .maps = &maps, }; diff --git a/libr/bin/p/bin_elf.inc.c b/libr/bin/p/bin_elf.inc.c index 0d375cf1e7..498d69d6b3 100644 --- a/libr/bin/p/bin_elf.inc.c +++ b/libr/bin/p/bin_elf.inc.c @@ -10,14 +10,6 @@ static RBinInfo* info(RBinFile *bf); -static int get_file_type(RBinFile *bf) { - ELFOBJ *eo = bf->bo->bin_obj; - char *type = Elf_(get_file_type (eo)); - int res = type? (r_str_startswith (type, "CORE") ? R_BIN_TYPE_CORE : R_BIN_TYPE_DEFAULT) : -1; - free (type); - return res; -} - static RList *maps(RBinFile *bf) { r_return_val_if_fail (bf && bf->bo, NULL); return Elf_(get_maps)(bf->bo->bin_obj); diff --git a/libr/bin/p/bin_elf64.c b/libr/bin/p/bin_elf64.c index 77b6fc0bcf..9241f63d7d 100644 --- a/libr/bin/p/bin_elf64.c +++ b/libr/bin/p/bin_elf64.c @@ -155,7 +155,6 @@ RBinPlugin r_bin_plugin_elf64 = { .create = &create, .write = &r_bin_write_elf64, .get_vaddr = &get_elf_vaddr64, - .file_type = &get_file_type, .regstate = ®state, .maps = &maps, }; diff --git a/libr/include/r_bin.h b/libr/include/r_bin.h index a4bae7c34b..4188329775 100644 --- a/libr/include/r_bin.h +++ b/libr/include/r_bin.h @@ -556,7 +556,6 @@ typedef struct r_bin_plugin_t { // TODO: R2_600 RBuffer* (*create)(RBin *bin, RBinCreateOptions *opt); char* (*demangle)(const char *str); char* (*regstate)(RBinFile *bf); - int (*file_type)(RBinFile *bf); /* default value if not specified by user */ int minstrlen; char strfilter;