Fix #3898 - Persistent section name in project files

This commit is contained in:
pancake 2016-01-03 01:36:16 +01:00
parent 6f346b6d6d
commit a93ecf2b69
2 changed files with 23 additions and 0 deletions

View File

@ -320,6 +320,8 @@ R_API int r_core_project_save(RCore *core, const char *file) {
sdb_file (core->anal->sdb_xrefs, buf);
sdb_sync (core->anal->sdb_xrefs);
}
r_core_cmd (core, "S*", 0);
r_cons_flush ();
r_core_cmd (core, "fV*", 0);
r_cons_flush ();
r_core_cmd (core, "ax*", 0);

View File

@ -30,6 +30,23 @@ R_API RIOSection *r_io_section_get_name(RIO *io, const char *name) {
return NULL;
}
static RIOSection *findMatching (RIO *io, ut64 paddr, ut64 vaddr, ut64 size, ut64 vsize, int rwx, const char *name) {
RListIter *iter;
RIOSection *s;
r_list_foreach (io->sections, iter, s) {
if (s->offset != paddr) continue;
if (s->vaddr != vaddr) continue;
s->size = size;
s->vsize = vsize;
s->rwx = rwx;
if (name && strcmp (name, s->name)) {
strcpy (s->name, name); /// XXX overflow here
}
return s;
}
return NULL;
}
R_API RIOSection *r_io_section_add(RIO *io, ut64 offset, ut64 vaddr, ut64 size, ut64 vsize, int rwx, const char *name, ut32 bin_id, int fd) {
int update = 0;
RIOSection *s;
@ -39,6 +56,10 @@ R_API RIOSection *r_io_section_add(RIO *io, ut64 offset, ut64 vaddr, ut64 size,
size, name, vaddr);
return NULL;
}
s = findMatching (io, offset, vaddr, size, vsize, rwx, name);
if (s) {
return s;
}
s = r_io_section_get_name (io, name);
if (s == NULL) {
s = R_NEW (RIOSection);