Skip to content

Commit

Permalink
Remove bin.laddr config variable and provider api for it ##bin
Browse files Browse the repository at this point in the history
  • Loading branch information
radare committed Dec 9, 2024
1 parent 6c7e6bf commit d06616c
Show file tree
Hide file tree
Showing 6 changed files with 1,621 additions and 5 deletions.
4 changes: 3 additions & 1 deletion libr/core/cbin.c
Original file line number Diff line number Diff line change
Expand Up @@ -4744,7 +4744,9 @@ R_API bool r_core_bin_info(RCore *core, int action, PJ *pj, int mode, int va, RC
R_RETURN_VAL_IF_FAIL (core, false);
const char *name = (filter && filter->name)? filter->name : NULL;
bool ret = true;
ut64 at = UT64_MAX, loadaddr = r_bin_get_laddr (core->bin);
const char *name = NULL;
ut64 at = UT64_MAX;
ut64 loadaddr = r_bin_get_laddr (core->bin);
if (filter && filter->offset) {
at = filter->offset;
}
Expand Down
1 change: 0 additions & 1 deletion libr/core/cconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -3921,7 +3921,6 @@ R_API int r_core_config_init(RCore *core) {
SETCB ("bin.demangle.usecmd", "false", &cb_bdc, "run xcrun swift-demangle and similar if available (SLOW) (see bin.demangle.trylib)");
SETBPREF ("bin.demangle.pfxlib", "false", "show library name on demangled symbols names");
SETI ("bin.baddr", -1, "base address of the binary");
SETI ("bin.laddr", 0, "base address for loading library ('*.so')");
SETCB ("bin.dbginfo", "true", &cb_bindbginfo, "load debug information at startup if available");
SETBPREF ("bin.relocs", "true", "load relocs information at startup if available");
SETBPREF ("bin.relocs.apply", "false", "apply reloc information");
Expand Down
33 changes: 31 additions & 2 deletions libr/core/cfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,33 @@ static void load_gp(RCore *core) {
}
}

R_API ut64 r_core_get_cur_laddr(RCore *core) {
RListIter *iter;
RIOMap *map;
ut64 laddr = 0;
RIODesc *odesc = core->io ? core->io->desc : NULL;
if (odesc) {
RList *maps = r_io_map_get_by_fd (core->io, odesc->fd);
r_list_foreach (maps, iter, map) {
if (map->delta) {
continue;
}
if (map->itv.addr && (!laddr || map->itv.addr < laddr)) {
laddr = map->itv.addr;
}
}
}
return laddr;
}

R_API bool r_core_file_reopen(RCore *core, const char *args, int perm, int loadbin) {
const bool isdebug = r_config_get_b (core->config, "cfg.debug");
char *path;
ut64 laddr = r_config_get_i (core->config, "bin.laddr");
RIODesc *odesc = core->io ? core->io->desc : NULL;
RBinFile *bf = odesc ? r_bin_file_find_by_fd (core->bin, odesc->fd) : NULL;
char *ofilepath = NULL, *obinfilepath = (bf && bf->file)? strdup (bf->file): NULL;
ut64 laddr = r_core_get_cur_laddr (core);

bool ret = false;
ut64 origoff = core->offset;
if (odesc) {
Expand Down Expand Up @@ -648,7 +668,14 @@ static bool linkcb(void *user, void *data, ut32 id) {
R_API bool r_core_bin_load(RCore *r, const char *filenameuri, ut64 baddr) {
R_RETURN_VAL_IF_FAIL (r && r->io, false);
R_CRITICAL_ENTER (r);
#if 0
ut64 laddr = r_config_get_i (r->config, "bin.laddr");
#else
ut64 laddr = r_core_get_cur_laddr (r);
#endif
RBinFile *binfile = NULL;
RBinPlugin *plugin = NULL;
const char *cmd_load;
RIODesc *desc = r->io->desc;
if (!desc && filenameuri) {
desc = r_io_desc_get_byuri (r->io, filenameuri);
Expand Down Expand Up @@ -987,12 +1014,14 @@ R_API RIODesc *r_core_file_open(RCore *r, const char *file, int flags, ut64 load
}
}
}
#if 0
// used by r_core_bin_load otherwise won't load correctly
// this should be argument of r_core_bin_load <shrug>
if (loadaddr != UT64_MAX) {
r_config_set_i (r->config, "bin.laddr", loadaddr);
}
r_core_cmd0 (r, "=!");
#endif
r_core_cmd0 (r, ":!");
beach:
r->times->file_open_time = r_time_now_mono () - prev;
return fd;
Expand Down
Loading

0 comments on commit d06616c

Please sign in to comment.