mirror of
https://github.com/radareorg/radare2.git
synced 2025-02-12 17:48:33 +00:00
Inform the user if the selected arch cannot be set
This commit is contained in:
parent
6d83b07224
commit
1734d6857e
@ -485,7 +485,13 @@ int main(int argc, char **argv, char **envp) {
|
||||
if (asmarch) r_config_set (r.config, "asm.arch", asmarch);
|
||||
if (asmbits) r_config_set (r.config, "asm.bits", asmbits);
|
||||
if (asmos) r_config_set (r.config, "asm.os", asmos);
|
||||
r_core_bin_update_arch_bits (&r);
|
||||
if (!r_core_bin_update_arch_bits (&r)) {
|
||||
eprintf("Something went wrong while trying to set the specified architecture.\n"
|
||||
"If you're trying to open a fat mach-o binary make sure that it has an\n"
|
||||
"image for %sbit %s. Otherwise call help.\n",
|
||||
asmbits, asmarch);
|
||||
return 1;
|
||||
}
|
||||
debug = r.file && r.file->desc && r.file->desc->plugin && \
|
||||
r.file->desc->plugin->debug != NULL;
|
||||
if (debug) {
|
||||
|
@ -1180,23 +1180,27 @@ R_API int r_core_bin_info (RCore *core, int action, int mode, int va, RCoreBinFi
|
||||
|
||||
R_API int r_core_bin_set_arch_bits (RCore *r, const char *name, const char * arch, ut16 bits) {
|
||||
RCoreFile *cf = r_core_file_cur (r);
|
||||
RBinFile *nbinfile = NULL;
|
||||
int res = R_FALSE;
|
||||
name = !name && cf ? cf->filename : name;
|
||||
res = r_asm_is_valid (r->assembler, arch) == R_TRUE;
|
||||
RBinFile *binfile;
|
||||
|
||||
// this check takes place to ensure we can make the change
|
||||
nbinfile = res ? r_bin_file_find_by_arch_bits (r->bin, arch, bits, name) : NULL;
|
||||
if (!nbinfile) return res;
|
||||
if (!name)
|
||||
name = cf ? cf->filename : NULL;
|
||||
if (!name)
|
||||
return R_FALSE;
|
||||
|
||||
res = r_bin_use_arch (r->bin, arch, bits, name);
|
||||
if (res) {
|
||||
r_core_bin_set_cur (r, nbinfile);
|
||||
if (r_asm_is_valid (r->assembler, arch) ) {
|
||||
return r_core_bin_set_env (r, nbinfile);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
/* Check if the arch name is a valid name */
|
||||
if (!r_asm_is_valid (r->assembler, arch))
|
||||
return R_FALSE;
|
||||
|
||||
/* Find a file with the requested name/arch/bits */
|
||||
binfile = r_bin_file_find_by_arch_bits (r->bin, arch, bits, name);
|
||||
if (!binfile)
|
||||
return R_FALSE;
|
||||
|
||||
if (!r_bin_use_arch (r->bin, arch, bits, name))
|
||||
return R_FALSE;
|
||||
|
||||
r_core_bin_set_cur (r, binfile);
|
||||
return r_core_bin_set_env (r, binfile);
|
||||
}
|
||||
|
||||
R_API int r_core_bin_update_arch_bits (RCore *r) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user