From e943a97b261e8c98b5a70e5847c85efe6f7e4aee Mon Sep 17 00:00:00 2001 From: Luc Tielen Date: Thu, 13 Apr 2023 15:30:43 +0200 Subject: [PATCH] Conditionally parse mach0 start symbols ##bin --- libr/bin/format/mach0/mach0.c | 7 ++++++- libr/bin/format/mach0/mach0.h | 2 ++ libr/bin/p/bin_mach0.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/libr/bin/format/mach0/mach0.c b/libr/bin/format/mach0/mach0.c index b5a231814f..9ceed51ade 100644 --- a/libr/bin/format/mach0/mach0.c +++ b/libr/bin/format/mach0/mach0.c @@ -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) { diff --git a/libr/bin/format/mach0/mach0.h b/libr/bin/format/mach0/mach0.h index ac57bcad69..17265c1d75 100644 --- a/libr/bin/format/mach0/mach0.h +++ b/libr/bin/format/mach0/mach0.h @@ -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; diff --git a/libr/bin/p/bin_mach0.c b/libr/bin/p/bin_mach0.c index eff779e4af..d58268ec2e 100644 --- a/libr/bin/p/bin_mach0.c +++ b/libr/bin/p/bin_mach0.c @@ -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) {