mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-08 02:53:29 +00:00
Kill io.sectonly and make io.va work as expected
This commit is contained in:
parent
e3510cdb65
commit
0771170ae6
@ -1398,6 +1398,7 @@ int
|
||||
hexagon_get_opcode_mach
|
||||
(int bfd_mach, int big_p)
|
||||
{
|
||||
#if 0
|
||||
static int mach_type_map [] =
|
||||
{
|
||||
HEXAGON_MACH_V2,
|
||||
@ -1406,6 +1407,7 @@ hexagon_get_opcode_mach
|
||||
HEXAGON_MACH_V5,
|
||||
/* Leaving space for future cores */
|
||||
};
|
||||
#endif
|
||||
// v6 not supported :(
|
||||
// XXX hardcoded to v5
|
||||
return HEXAGON_MACH_V5;
|
||||
@ -1838,8 +1840,10 @@ hexagon_reg_num
|
||||
continue;
|
||||
|
||||
*input = regs + len - (*name? 1: 0);
|
||||
// unused result . thank you gnu
|
||||
return ((int) (aliasn? *aliasn = i: i), (int) regn);
|
||||
if (aliasn) {
|
||||
*aliasn = i;
|
||||
}
|
||||
return regn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1018,6 +1018,7 @@ R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, RIODesc *desc, ut64 baseaddr,
|
||||
RBinFile *binfile = NULL;
|
||||
RIODesc *tdesc = NULL;
|
||||
ut8 is_debugger = desc && desc->plugin && desc->plugin->isdbg;
|
||||
const bool oiova = io->va;
|
||||
|
||||
if (!io || !desc) {
|
||||
return false;
|
||||
@ -1044,9 +1045,11 @@ R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, RIODesc *desc, ut64 baseaddr,
|
||||
//from the memory
|
||||
if (tdesc) {
|
||||
buf_bytes = calloc (1, sz + 1);
|
||||
io->va = 0;
|
||||
r_io_desc_seek (tdesc, 0, R_IO_SEEK_SET);
|
||||
r_io_desc_read (tdesc, buf_bytes, sz);
|
||||
iob->close (io, tdesc->fd);
|
||||
io->va = oiova;
|
||||
tdesc = NULL;
|
||||
if (!io->desc) {
|
||||
r_io_use_fd (io, desc->fd);
|
||||
@ -1060,9 +1063,11 @@ R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, RIODesc *desc, ut64 baseaddr,
|
||||
return false;
|
||||
}
|
||||
ut64 seekaddr = is_debugger? baseaddr: loadaddr;
|
||||
io->va = 0;
|
||||
if (!iob->read_at (io, seekaddr, buf_bytes, sz)) {
|
||||
sz = 0;
|
||||
}
|
||||
io->va = 1;
|
||||
}
|
||||
|
||||
if (!name) {
|
||||
@ -1081,8 +1086,10 @@ R_API int r_bin_load_io_at_offset_as_sz(RBin *bin, RIODesc *desc, ut64 baseaddr,
|
||||
if (sz != UT64_MAX) {
|
||||
buf_bytes = calloc (1, sz + 1);
|
||||
if (buf_bytes) {
|
||||
io->va = 0;
|
||||
r_io_desc_seek (tdesc, 0, R_IO_SEEK_SET);
|
||||
r_io_desc_read (tdesc, buf_bytes, sz);
|
||||
io->va = oiova;
|
||||
}
|
||||
}
|
||||
iob->close (io, tdesc->fd);
|
||||
|
@ -1305,13 +1305,6 @@ static int cb_ioenforce(void *user, void *data) {
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cb_iosectonly(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
core->io->sectonly = node->i_value? 1: 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int cb_iobuffer(void *user, void *data) {
|
||||
RCore *core = (RCore *) user;
|
||||
RConfigNode *node = (RConfigNode *) data;
|
||||
@ -2597,7 +2590,6 @@ R_API int r_core_config_init(RCore *core) {
|
||||
/* io */
|
||||
SETICB ("io.enforce", 0, &cb_ioenforce, "Honor IO section permissions for 1=read , 2=write, 0=none");
|
||||
SETCB ("io.buffer", "false", &cb_iobuffer, "Load and use buffer cache if enabled");
|
||||
SETCB ("io.sectonly", "false", &cb_iosectonly, "Only read from sections (if any)");
|
||||
SETI ("io.buffer.from", 0, "Lower address of buffered cache");
|
||||
SETI ("io.buffer.to", 0, "Higher address of buffered cache");
|
||||
SETCB ("io.cache", "false", &cb_iocache, "Enable cache for io changes");
|
||||
|
@ -127,7 +127,6 @@ typedef struct r_io_t {
|
||||
int raised;
|
||||
int va;
|
||||
bool pava;
|
||||
int sectonly;
|
||||
char *referer;
|
||||
char *redirect;
|
||||
/* write mask */
|
||||
|
37
libr/io/io.c
37
libr/io/io.c
@ -482,13 +482,14 @@ R_API int r_io_vread_at(RIO *io, ut64 vaddr, ut8 *buf, int len) {
|
||||
if (!io || !buf) {
|
||||
return 0;
|
||||
}
|
||||
if (!io->va) {
|
||||
return r_io_map_get (io, vaddr) != NULL;
|
||||
}
|
||||
if (len < 1) {
|
||||
return 0;
|
||||
}
|
||||
if (!r_io_is_valid_offset (io, vaddr, 0)) {
|
||||
if (io->ff) {
|
||||
memset (buf, 0xff, len);
|
||||
}
|
||||
if (io->ff && !r_io_is_valid_offset (io, vaddr, 0)) {
|
||||
memset (buf, 0xff, len);
|
||||
}
|
||||
if (!io->maps) {
|
||||
return r_io_pread_at (io, vaddr, buf, len);
|
||||
@ -496,6 +497,9 @@ R_API int r_io_vread_at(RIO *io, ut64 vaddr, ut8 *buf, int len) {
|
||||
if (io->debug) {
|
||||
paddr = vaddr;
|
||||
} else {
|
||||
if (r_io_map_get (io, vaddr)) {
|
||||
return 0;
|
||||
}
|
||||
ut64 maddr = UT64_MAX;
|
||||
int count = 0;
|
||||
//XXX UGLY hack to find mapped dir
|
||||
@ -997,8 +1001,10 @@ R_API bool r_io_is_valid_offset(RIO *io, ut64 offset, int hasperm) {
|
||||
r_sys_backtrace ();
|
||||
return false;
|
||||
}
|
||||
bool io_sectonly = io->sectonly;
|
||||
bool io_va = io->va;
|
||||
if (io->debug) {
|
||||
// in debugger-mode we want to allow the debugger decide whats valid and whats not
|
||||
return true;
|
||||
}
|
||||
if (!io->files) {
|
||||
eprintf ("r_io_is_valid_offset: io->files is NULL\n");
|
||||
r_sys_backtrace ();
|
||||
@ -1009,22 +1015,20 @@ R_API bool r_io_is_valid_offset(RIO *io, ut64 offset, int hasperm) {
|
||||
r_sys_backtrace ();
|
||||
return false;
|
||||
}
|
||||
if (r_list_empty (io->sections)) {
|
||||
if ((r_io_map_exists_for_offset (io, offset))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!io_va) {
|
||||
if (!io->va) {
|
||||
if ((r_io_map_exists_for_offset (io, offset))) {
|
||||
return true;
|
||||
}
|
||||
return (offset < r_io_size (io));
|
||||
}
|
||||
if (io->debug) {
|
||||
// TODO check debug maps here
|
||||
return true;
|
||||
if (r_list_empty (io->sections)) {
|
||||
if ((r_io_map_exists_for_offset (io, offset))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (io_sectonly) {
|
||||
#if 0
|
||||
// unused after removing sectonly
|
||||
if (!io->va) {
|
||||
if (r_list_empty (io->sections)) {
|
||||
return true;
|
||||
}
|
||||
@ -1033,6 +1037,7 @@ R_API bool r_io_is_valid_offset(RIO *io, ut64 offset, int hasperm) {
|
||||
if (!io_va && r_io_map_exists_for_offset (io, offset)) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
return r_io_section_exists_for_vaddr (io, offset, hasperm);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare2 - LGPL - Copyright 2008-2016 - pancake, nibble */
|
||||
/* radare2 - LGPL - Copyright 2008-2017 - pancake, nibble */
|
||||
|
||||
#include "r_io.h"
|
||||
// no link
|
||||
|
Loading…
Reference in New Issue
Block a user