mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-14 08:49:50 +00:00
fetches sections starting from the back
This commit is contained in:
parent
0b687439ea
commit
a31d359bf1
@ -386,6 +386,7 @@ R_API RIOSection *r_io_section_get_name(RIO *io, const char *name);
|
||||
R_API RIOSection *r_io_section_get_i(RIO *io, int idx);
|
||||
R_API RIOSection *r_io_section_getv(RIO *io, ut64 vaddr);
|
||||
R_API RIOSection *r_io_section_mget(RIO *io, ut64 maddr);
|
||||
R_API RIOSection *r_io_section_mget_prev(RIO *io, ut64 maddr);
|
||||
R_API RIOSection *r_io_section_vget(RIO *io, ut64 addr);
|
||||
R_API RIOSection *r_io_section_pget(RIO *io, ut64 addr);
|
||||
R_API int r_io_section_set_archbits(RIO *io, ut64 addr, const char *arch, int bits);
|
||||
|
@ -274,6 +274,16 @@ R_API RIOSection *r_io_section_mget(RIO *io, ut64 maddr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
R_API RIOSection *r_io_section_mget_prev(RIO *io, ut64 maddr) {
|
||||
RIOSection *s;
|
||||
RListIter *iter;
|
||||
r_list_foreach_prev (io->sections, iter, s) {
|
||||
if ((maddr >= s->offset && maddr < (s->offset + s->size)))
|
||||
return s;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// XXX: rename this
|
||||
R_API ut64 r_io_section_get_offset(RIO *io, ut64 maddr) {
|
||||
RIOSection *s = r_io_section_mget (io, maddr);
|
||||
@ -340,7 +350,7 @@ R_API ut64 r_io_section_vaddr_to_maddr(RIO *io, ut64 vaddr) {
|
||||
/* returns the conversion from file offset to vaddr if the given offset is
|
||||
* mapped somewhere, UT64_MAX otherwise */
|
||||
R_API ut64 r_io_section_maddr_to_vaddr(RIO *io, ut64 offset) {
|
||||
RIOSection *s = r_io_section_mget (io, offset);
|
||||
RIOSection *s = r_io_section_mget_prev (io, offset);
|
||||
if (s) {
|
||||
io->section = s;
|
||||
return (s->vaddr + offset - s->offset);
|
||||
|
Loading…
Reference in New Issue
Block a user