Add sys/profiling.sh

This commit is contained in:
pancake 2023-03-07 10:53:18 +01:00
parent c7211654f0
commit e8e1548870
4 changed files with 56 additions and 50 deletions

View File

@ -2782,7 +2782,8 @@ static void fill_exports_list(struct MACH0_(obj_t) *bin, const char *name, ut64
const RList *MACH0_(get_symbols_list)(struct MACH0_(obj_t) *bin) {
struct symbol_t *symbols;
size_t i, j, s, symbols_size, symbols_count;
ut32 to, from;
ut32 to = UT32_MAX;
ut32 from = UT32_MAX;
r_return_val_if_fail (bin, NULL);
if (bin->symbols_cache) {
@ -2812,7 +2813,7 @@ const RList *MACH0_(get_symbols_list)(struct MACH0_(obj_t) *bin) {
/* parse dynamic symbol table */
symbols_count = (bin->dysymtab.nextdefsym + \
bin->dysymtab.nlocalsym + \
bin->dysymtab.nundefsym );
bin->dysymtab.nundefsym);
symbols_count += bin->nsymtab;
ut64 tmp = symbols_count + 1;
if (SZT_MUL_OVFCHK (symbols_count + 1, 2)) {
@ -2994,9 +2995,12 @@ static void assign_export_symbol_t(struct MACH0_(obj_t) *bin, const char *name,
}
const struct symbol_t *MACH0_(get_symbols)(struct MACH0_(obj_t) *bin) {
r_return_val_if_fail (bin, NULL);
struct symbol_t *symbols;
int j, s, stridx, symbols_size, symbols_count;
ut32 to, from, i;
int j = 0, s, stridx, symbols_size, symbols_count;
ut32 to = UT32_MAX;
ut32 from = UT32_MAX;
ut32 i;
if (bin->symbols) {
return bin->symbols;
@ -3007,7 +3011,6 @@ const struct symbol_t *MACH0_(get_symbols)(struct MACH0_(obj_t) *bin) {
return NULL;
}
r_return_val_if_fail (bin, NULL);
int n_exports = walk_exports (bin, NULL, NULL);
symbols_count = n_exports;

View File

@ -216,7 +216,7 @@ static void siguza_xrefs_chunked(RCore *core, ut64 search, int lenbytes) {
addref (core, addr, addr + off, R_ANAL_REF_TYPE_CODE);
// r_cons_printf ("ax 0x%"PFMT64x" 0x%"PFMT64x"\n", addr + off, addr);
} else if (addr + off == search) {
const char *cond;
const char *cond = "al";
switch(v & 0xf)
{
case 0x0: cond = "eq"; break;
@ -236,7 +236,7 @@ static void siguza_xrefs_chunked(RCore *core, ut64 search, int lenbytes) {
case 0xe: cond = "al"; break;
case 0xf: cond = "nv"; break;
}
r_cons_printf("%#"PFMT64x": b.%s %#"PFMT64x"\n", addr, cond, search);
r_cons_printf ("%#"PFMT64x": b.%s %#"PFMT64x"\n", addr, cond, search);
}
}
else if ((v & 0x7e000000) == 0x34000000) // cbz and cbnz

View File

@ -278,38 +278,36 @@ static int rabin_dump_symbols(RBin *bin, int len) {
}
static bool __dumpSections(RBin *bin, const char *scnname, const char *output, const char *file, bool raw) {
RList *sections;
RListIter *iter;
RBinSection *section;
ut8 *buf;
char *ret;
int r;
if (!(sections = r_bin_get_sections (bin))) {
RList *sections = r_bin_get_sections (bin);
if (!sections || r_list_empty (sections)) {
R_LOG_WARN ("No sections to dump");
return false;
}
r_list_foreach (sections, iter, section) {
if (r_str_glob (section->name, scnname)) {
if (!(buf = malloc (section->size))) {
if (!r_str_glob (section->name, scnname)) {
continue;
}
const size_t ss = section->size;
if ((ss * 2) + 1 < ss) {
return false;
}
if ((section->size * 2) + 1 < section->size) {
free (buf);
return false;
}
if (!(ret = malloc (section->size*2+1))) {
free (buf);
return false;
}
if (section->paddr > r_buf_size (bin->cur->buf) ||
section->paddr + section->size > r_buf_size (bin->cur->buf)) {
ut8 *buf = malloc (ss);
char *ret = malloc (ss * 2 + 1);
if (R_UNLIKELY (!buf || !ret)) {
free (buf);
free (ret);
return false;
}
r = r_buf_read_at (bin->cur->buf, section->paddr,
buf, section->size);
if (section->paddr > r_buf_size (bin->cur->buf) ||
section->paddr + ss > r_buf_size (bin->cur->buf)) {
free (buf);
free (ret);
return false;
}
int r = r_buf_read_at (bin->cur->buf, section->paddr, buf, ss);
if (r < 1) {
free (buf);
free (ret);
@ -317,12 +315,14 @@ static bool __dumpSections(RBin *bin, const char *scnname, const char *output, c
}
//it does mean the user specified an output file
if (strcmp (output, file)) {
r_file_dump (output, buf, section->size, 0);
r_file_dump (output, buf, ss, 0);
} else {
if (raw) {
write (1, buf, section->size);
if (write (1, buf, ss) != ss) {
R_LOG_WARN ("write truncated");
}
} else {
r_hex_bin2str (buf, section->size, ret);
r_hex_bin2str (buf, ss, ret);
printf ("%s\n", ret);
}
}
@ -330,7 +330,6 @@ static bool __dumpSections(RBin *bin, const char *scnname, const char *output, c
free (ret);
break;
}
}
return true;
}

4
sys/profiling.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
export CFLAGS="-pg -g -O1 -no-pie"
export LDFLAGS="$CFLAGS"
sys/install.sh