Use separate counters for init, fini, preinit entries (#12441)

This commit is contained in:
Khairul Azhar Kasmiran 2018-12-10 21:35:41 +08:00 committed by radare
parent 9a91f96101
commit 2ebd956fdd

View File

@ -1083,7 +1083,7 @@ static int bin_entry(RCore *r, int mode, ut64 laddr, int va, bool inifin) {
RListIter *iter;
RListIter *last_processed = NULL;
RBinAddr *entry = NULL;
int i = 0;
int i = 0, init_i = 0, fini_i = 0, preinit_i = 0;
ut64 baddr = r_bin_get_baddr (r->bin);
if (IS_MODE_RAD (mode)) {
@ -1129,11 +1129,11 @@ static int bin_entry(RCore *r, int mode, ut64 laddr, int va, bool inifin) {
if (IS_MODE_SET (mode)) {
r_flag_space_set (r->flags, "symbols");
if (entry->type == R_BIN_ENTRY_TYPE_INIT) {
snprintf (str, R_FLAG_NAME_SIZE, "entry%i.init", i);
snprintf (str, R_FLAG_NAME_SIZE, "entry%i.init", init_i);
} else if (entry->type == R_BIN_ENTRY_TYPE_FINI) {
snprintf (str, R_FLAG_NAME_SIZE, "entry%i.fini", i);
snprintf (str, R_FLAG_NAME_SIZE, "entry%i.fini", fini_i);
} else if (entry->type == R_BIN_ENTRY_TYPE_PREINIT) {
snprintf (str, R_FLAG_NAME_SIZE, "entry%i.preinit", i);
snprintf (str, R_FLAG_NAME_SIZE, "entry%i.preinit", preinit_i);
} else {
snprintf (str, R_FLAG_NAME_SIZE, "entry%i", i);
}
@ -1159,11 +1159,11 @@ static int bin_entry(RCore *r, int mode, ut64 laddr, int va, bool inifin) {
} else if (IS_MODE_RAD (mode)) {
char *name = NULL;
if (entry->type == R_BIN_ENTRY_TYPE_INIT) {
name = r_str_newf ("entry%i.init", i);
name = r_str_newf ("entry%i.init", init_i);
} else if (entry->type == R_BIN_ENTRY_TYPE_FINI) {
name = r_str_newf ("entry%i.fini", i);
name = r_str_newf ("entry%i.fini", fini_i);
} else if (entry->type == R_BIN_ENTRY_TYPE_PREINIT) {
name = r_str_newf ("entry%i.preinit", i);
name = r_str_newf ("entry%i.preinit", preinit_i);
} else {
name = r_str_newf ("entry%i", i);
}
@ -1192,7 +1192,15 @@ static int bin_entry(RCore *r, int mode, ut64 laddr, int va, bool inifin) {
}
r_cons_printf (" type=%s\n", type);
}
i++;
if (entry->type == R_BIN_ENTRY_TYPE_INIT) {
init_i++;
} else if (entry->type == R_BIN_ENTRY_TYPE_FINI) {
fini_i++;
} else if (entry->type == R_BIN_ENTRY_TYPE_PREINIT) {
preinit_i++;
} else {
i++;
}
last_processed = iter;
}
if (IS_MODE_SET (mode)) {
@ -1204,7 +1212,7 @@ static int bin_entry(RCore *r, int mode, ut64 laddr, int va, bool inifin) {
r_cons_printf ("]");
r_cons_newline ();
} else if (IS_MODE_NORMAL (mode)) {
r_cons_printf ("\n%i entrypoints\n", i);
r_cons_printf ("\n%i entrypoints\n", init_i + fini_i + preinit_i + i);
}
return true;
}