Fix some regressions

This commit is contained in:
alvarofe 2017-08-25 14:33:14 +02:00 committed by pancake
parent b35dbed06b
commit a46b62e220
3 changed files with 15 additions and 10 deletions

View file

@ -961,6 +961,7 @@ int main(int argc, char **argv, char **envp) {
(void)r_core_bin_load (&r, filepath, baddr);
}
} else {
r_io_map_new (r.io, iod->fd, iod->flags, 0LL, 0LL, r_io_desc_size (iod));
if (run_anal < 0) {
// PoC -- must move -rk functionalitiy into rcore
// this may be used with caution (r2 -nn $FILE)

View file

@ -754,7 +754,6 @@ static int cmd_open(void *data, const char *input) {
r_core_file_list (core, 'n');
break;
}
/* fall through */
case ' ':
{
@ -762,18 +761,17 @@ static int cmd_open(void *data, const char *input) {
ut64 ma = 0L;
char *fn = strdup (input + (isn? 2:1));
if (!fn || !*fn) {
eprintf ("Usage: on [file]\n");
if (isn) {
eprintf ("Usage: on [file]\n");
} else {
eprintf ("Usage: o [file] addr\n");
}
free (fn);
break;
}
ptr = strchr (fn, ' ');
if (ptr) {
*ptr++ = '\0';
char *ptr2 = strchr (ptr, ' ');
if (ptr2) {
*ptr2++ = 0;
ba = r_num_math (core->num, ptr2);
}
ma = r_num_math (core->num, ptr);
}
int num = atoi (input + 1);
@ -785,6 +783,9 @@ static int cmd_open(void *data, const char *input) {
// MUST CLEAN BEFORE LOADING
if (!isn) {
r_core_bin_load (core, fn, ba);
} else {
RIODesc *d = r_io_desc_get (core->io, file->fd);
r_io_map_new (core->io, d->fd, d->flags, 0LL, ma, r_io_desc_size (d));
}
} else if (!nowarn) {
eprintf ("Cannot open file '%s'\n", fn);

View file

@ -521,6 +521,7 @@ R_API bool 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);
RIODesc *desc = cf ? r_io_desc_get (r->io, cf->fd) : NULL;
ut64 laddr = r_config_get_i (r->config, "bin.laddr");
RBinFile *binfile = NULL;
RBinPlugin *plugin = NULL;
int is_io_load;
@ -562,7 +563,6 @@ R_API bool r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) {
if ((desc->plugin && desc->plugin->isdbg) || r_config_get_i (r->config, "cfg.debug")) {
r_core_file_do_load_for_debug (r, baddr, filenameuri);
} else {
ut64 laddr = r_config_get_i (r->config, "bin.laddr");
r_core_file_do_load_for_io_plugin (r, baddr, laddr);
}
// Restore original desc
@ -624,8 +624,8 @@ R_API bool r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) {
}
}
//workaround to map correctly malloc:// and raw binaries
if (!plugin || !strcmp (plugin->name, "any") || !desc->plugin || !desc->plugin->isdbg) {
r_io_map_new (r->io, desc->fd, desc->flags, 0LL, 0LL, r_io_desc_size (desc));
if (!plugin || !strcmp (plugin->name, "any") || r_io_desc_is_dbg (desc)) {
r_io_map_new (r->io, desc->fd, desc->flags, 0LL, laddr, r_io_desc_size (desc));
}
return true;
}
@ -812,6 +812,9 @@ R_API RCoreFile *r_core_file_open(RCore *r, const char *file, int flags, ut64 lo
}
r_config_set_i (r->config, "dbg.swstep", swstep);
}
//used by r_core_bin_load otherwise won't load correctly
//this should be argument of r_core_bin_load <shrug>
r_config_set_i (r->config, "bin.laddr", loadaddr);
beach:
r->times->file_open_time = r_sys_now () - prev;
return fh;