Conditionally parse mach0 start symbols ##bin

This commit is contained in:
Luc Tielen 2023-04-13 15:30:43 +02:00 committed by pancake
parent 81f596a4d9
commit e943a97b26
3 changed files with 10 additions and 1 deletions

View File

@ -2213,6 +2213,7 @@ void MACH0_(opts_set_default)(struct MACH0_(opts_t) *options, RBinFile *bf) {
options->symbols_off = 0;
options->verbose = bf->rbin->verbose;
options->maxsymlen = bf->rbin->maxsymlen;
options->parse_start_symbols = false;
}
static void *duplicate_ptr(void *p) {
@ -2238,6 +2239,7 @@ struct MACH0_(obj_t) *MACH0_(mach0_new)(const char *file, struct MACH0_(opts_t)
bin->verbose = options->verbose;
bin->header_at = options->header_at;
bin->symbols_off = options->symbols_off;
bin->parse_start_symbols = options->parse_start_symbols;
}
bin->file = file;
size_t binsz = 0;
@ -2281,6 +2283,7 @@ struct MACH0_(obj_t) *MACH0_(new_buf)(RBuffer *buf, struct MACH0_(opts_t) *optio
bin->header_at = options->header_at;
bin->maxsymlen = options->maxsymlen;
bin->symbols_off = options->symbols_off;
bin->parse_start_symbols = options->parse_start_symbols;
}
bin->size = sz;
if (!init (bin)) {
@ -3148,7 +3151,9 @@ const RVector *MACH0_(load_symbols)(RBinFile *bf, struct MACH0_(obj_t) *bin) {
bool is_debug = _check_if_debug_build (bf, bin);
_parse_symbols (bf, bin, symcache);
_parse_function_start_symbols (bf, bin, symcache);
if (bin->parse_start_symbols) {
_parse_function_start_symbols (bf, bin, symcache);
}
ht_pp_free (symcache);
if (is_debug) {

View File

@ -98,6 +98,7 @@ struct MACH0_(opts_t) {
ut64 header_at;
ut64 symbols_off;
int maxsymlen;
bool parse_start_symbols;
RBinFile *bf;
};
@ -167,6 +168,7 @@ struct MACH0_(obj_t) {
int func_size;
bool verbose;
ut64 header_at;
bool parse_start_symbols;
bool symbols_loaded;
RVector symbols_cache;
ut64 symbols_off;

View File

@ -48,6 +48,8 @@ static bool load_buffer(RBinFile *bf, void **bin_obj, RBuffer *buf, ut64 loadadd
r_return_val_if_fail (bf && bin_obj && buf, false);
struct MACH0_(opts_t) opts;
MACH0_(opts_set_default) (&opts, bf);
opts.parse_start_symbols = true;
struct MACH0_(obj_t) *res = MACH0_(new_buf) (buf, &opts);
if (res) {
if (res->chained_starts) {