mirror of
https://github.com/radareorg/radare2.git
synced 2025-03-03 11:50:02 +00:00
Fix ood symbol rebasing and add obr command
This commit is contained in:
parent
1dada4f504
commit
40bc4cb751
@ -43,7 +43,7 @@ static int is_data_section(RBinFile *a, RBinSection *s);
|
||||
static RList *get_strings(RBinFile *a, int min, int dump);
|
||||
static void r_bin_object_delete_items(RBinObject *o);
|
||||
static void r_bin_object_free(void /*RBinObject*/ *o_);
|
||||
static int r_bin_object_set_items(RBinFile *binfile, RBinObject *o);
|
||||
// static int r_bin_object_set_items(RBinFile *binfile, RBinObject *o);
|
||||
static int r_bin_file_set_bytes(RBinFile *binfile, const ut8 *bytes, ut64 sz, bool steal_ptr);
|
||||
//static int remove_bin_file_by_binfile (RBin *bin, RBinFile * binfile);
|
||||
//static void r_bin_free_bin_files (RBin *bin);
|
||||
@ -574,7 +574,7 @@ static void r_bin_object_free(void /*RBinObject*/ *o_) {
|
||||
// XXX - change this to RBinObject instead of RBinFile
|
||||
// makes no sense to pass in a binfile and set the RBinObject
|
||||
// kinda a clunky functions
|
||||
static int r_bin_object_set_items(RBinFile *binfile, RBinObject *o) {
|
||||
R_API int r_bin_object_set_items(RBinFile *binfile, RBinObject *o) {
|
||||
RBinObject *old_o;
|
||||
RBinPlugin *cp;
|
||||
int i, minlen;
|
||||
@ -2059,10 +2059,11 @@ R_API int r_bin_object_delete(RBin *bin, ut32 binfile_id, ut32 binobj_id) {
|
||||
RBinObject *obj = NULL;
|
||||
int res = false;
|
||||
|
||||
#if 0
|
||||
if (binfile_id == UT32_MAX && binobj_id == UT32_MAX) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
if (binfile_id == -1) {
|
||||
binfile = r_bin_file_find_by_object_id (bin, binobj_id);
|
||||
obj = binfile? r_bin_file_object_find_by_id (binfile, binobj_id): NULL;
|
||||
|
@ -11,7 +11,9 @@ static inline ut32 find_binfile_id_by_fd (RBin *bin, ut32 fd) {
|
||||
RListIter *it;
|
||||
RBinFile *bf;
|
||||
r_list_foreach (bin->binfiles, it, bf) {
|
||||
if (bf->fd == fd) return bf->id;
|
||||
if (bf->fd == fd) {
|
||||
return bf->id;
|
||||
}
|
||||
}
|
||||
return UT32_MAX;
|
||||
}
|
||||
@ -22,6 +24,7 @@ static void cmd_open_bin(RCore *core, const char *input) {
|
||||
"ob", "", "List opened binary files and objid",
|
||||
"ob", " [fd objid]", "Switch to open binary file by fd number and objid",
|
||||
"obb", " [fd]", "Switch to open binfile by fd number",
|
||||
"obr", " [baddr]", "Rebase current bin object",
|
||||
"ob-", " [fd]", "Delete binfile by fd",
|
||||
"obd", " [objid]", "Delete binary file by objid. Do nothing if only one loaded.",
|
||||
"obo", " [objid]", "Switch to open binary file by objid",
|
||||
@ -36,7 +39,7 @@ static void cmd_open_bin(RCore *core, const char *input) {
|
||||
case '*':
|
||||
r_core_bin_list (core, input[1]);
|
||||
break;
|
||||
case 'b':
|
||||
case 'b': // "obb"
|
||||
{
|
||||
ut32 fd;
|
||||
value = *(input + 3) ? input + 3 : NULL;
|
||||
@ -84,6 +87,10 @@ static void cmd_open_bin(RCore *core, const char *input) {
|
||||
free (v);
|
||||
break;
|
||||
}
|
||||
case 'r':
|
||||
r_core_bin_rebase (core, r_num_math (core->num, input + 3));
|
||||
r_core_cmd0 (core, ".is*");
|
||||
break;
|
||||
case 'o':
|
||||
value = input[3] ? input + 3 : NULL;
|
||||
if (!value) {
|
||||
@ -301,7 +308,10 @@ R_API void r_core_file_reopen_debug (RCore *core, const char *args) {
|
||||
if (old_baddr != new_baddr) {
|
||||
r_bin_set_baddr (core->bin, new_baddr);
|
||||
r_config_set_i (core->config, "bin.baddr", new_baddr);
|
||||
r_core_bin_load (core, newfile, new_baddr);
|
||||
r_core_bin_rebase (core, new_baddr);
|
||||
// r_core_bin_load (core, newfile, new_baddr);
|
||||
// reload symbols with new baddr
|
||||
r_core_cmd0 (core, ".is*");
|
||||
}
|
||||
#endif
|
||||
r_core_cmd0 (core, "sr PC");
|
||||
|
@ -505,6 +505,20 @@ R_API bool r_core_file_loadlib(RCore *core, const char *lib, ut64 libaddr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
R_API int r_core_bin_rebase(RCore *core, ut64 baddr) {
|
||||
if (!core || !core->bin || !core->bin->cur) {
|
||||
return 0;
|
||||
}
|
||||
if (baddr == UT64_MAX) {
|
||||
return 0;
|
||||
}
|
||||
RBinFile *bf = core->bin->cur;
|
||||
bf->o->baddr = baddr;
|
||||
bf->o->loadaddr = baddr;
|
||||
r_bin_object_set_items (bf, bf->o);
|
||||
return 1;
|
||||
}
|
||||
|
||||
R_API int r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) {
|
||||
const char *suppress_warning = r_config_get (r->config, "file.nowarn");
|
||||
RCoreFile *cf = r_core_file_cur (r);
|
||||
|
@ -581,6 +581,7 @@ R_API int r_bin_select(RBin *bin, const char *arch, int bits, const char *name);
|
||||
R_API int r_bin_select_idx(RBin *bin, const char *name, int idx);
|
||||
R_API int r_bin_select_by_ids(RBin *bin, ut32 binfile_id, ut32 binobj_id );
|
||||
R_API int r_bin_object_delete (RBin *bin, ut32 binfile_id, ut32 binobj_id);
|
||||
R_API int r_bin_object_set_items(RBinFile *binfile, RBinObject *o);
|
||||
R_API int r_bin_use_arch(RBin *bin, const char *arch, int bits, const char *name);
|
||||
R_API RBinFile * r_bin_file_find_by_arch_bits(RBin *bin, const char *arch, int bits, const char *name);
|
||||
R_API RBinObject * r_bin_object_find_by_arch_bits (RBinFile *binfile, const char *arch, int bits, const char *name);
|
||||
|
@ -401,6 +401,7 @@ R_API int r_core_bin_set_by_fd (RCore *core, ut64 bin_fd);
|
||||
R_API int r_core_bin_set_by_name (RCore *core, const char *name);
|
||||
R_API int r_core_bin_reload(RCore *core, const char *file, ut64 baseaddr);
|
||||
R_API int r_core_bin_load(RCore *core, const char *file, ut64 baseaddr);
|
||||
R_API int r_core_bin_rebase(RCore *core, ut64 baddr);
|
||||
R_API void r_core_bin_export_info_rad(RCore *core);
|
||||
R_API int r_core_hash_load(RCore *core, const char *file);
|
||||
R_API int r_core_bin_list(RCore *core, int mode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user