Preparation for making btf_encoder.functions table shared between encoders. Shared table can be built as soon as Elf struct is extracted from Dwfl_Module, which happens in cus__proces_dwflmod. Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx> --- dwarf_loader.c | 21 ++++++++++++++------- dwarves.h | 18 ++++++++++++++++-- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/dwarf_loader.c b/dwarf_loader.c index e54a16c..fb42eb5 100644 --- a/dwarf_loader.c +++ b/dwarf_loader.c @@ -3723,13 +3723,6 @@ static int cus__load_module(struct cus *cus, struct conf_load *conf, return DWARF_CB_OK; } -struct process_dwflmod_parms { - struct cus *cus; - struct conf_load *conf; - const char *filename; - uint32_t nr_dwarf_sections_found; -}; - static int cus__process_dwflmod(Dwfl_Module *dwflmod, void **userdata __maybe_unused, const char *name __maybe_unused, @@ -3753,10 +3746,24 @@ static int cus__process_dwflmod(Dwfl_Module *dwflmod, Dwarf *dw = dwfl_module_getdwarf(dwflmod, &dwbias); int err = DWARF_CB_OK; + if (parms->conf->pre_cus__load_module) { + err = parms->conf->pre_cus__load_module(parms, dwflmod, dw, elf); + if (err) + return DWARF_CB_ABORT; + } + if (dw != NULL) { ++parms->nr_dwarf_sections_found; err = cus__load_module(cus, parms->conf, dwflmod, dw, elf, parms->filename); + if (err) + return err; + } + + if (parms->conf->post_cus__load_module) { + err = parms->conf->post_cus__load_module(parms, dwflmod, dw, elf); + if (err) + return DWARF_CB_ABORT; } /* * XXX We will fall back to try finding other debugging diff --git a/dwarves.h b/dwarves.h index f58e1d0..1b16f0c 100644 --- a/dwarves.h +++ b/dwarves.h @@ -36,6 +36,7 @@ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) struct cu; +struct cus; enum load_steal_kind { LSK__KEEPIT, @@ -58,6 +59,13 @@ typedef uint32_t type_id_t; struct btf; struct conf_fprintf; +struct process_dwflmod_parms { + struct cus *cus; + struct conf_load *conf; + const char *filename; + uint32_t nr_dwarf_sections_found; +}; + /** struct conf_load - load configuration * @thread_exit - called at the end of a thread, 1st user: BTF encoder dedup * @extra_dbg_info - keep original debugging format extra info @@ -105,6 +113,14 @@ struct conf_load { struct conf_fprintf *conf_fprintf; int (*threads_prepare)(struct conf_load *conf, int nr_threads, void **thr_data); int (*threads_collect)(struct conf_load *conf, int nr_threads, void **thr_data, int error); + int (*pre_cus__load_module)(struct process_dwflmod_parms *parms, + Dwfl_Module *mod, + Dwarf *dw, + Elf *elf); + int (*post_cus__load_module)(struct process_dwflmod_parms *parms, + Dwfl_Module *mod, + Dwarf *dw, + Elf *elf); }; /** struct conf_fprintf - hints to the __fprintf routines @@ -166,8 +182,6 @@ struct conf_fprintf { uint8_t skip_emitting_modifier:1; }; -struct cus; - struct cus *cus__new(void); void cus__delete(struct cus *cus); -- 2.34.1