Add a function pointer to conf_load, which is called immediately after Elf is extracted from Dwfl_Module in cus__proces_dwflmod. This is a preparation for making elf_functions table shared between encoders. Shared table can be built as soon as the relevant Elf is available. Signed-off-by: Ihor Solodrai <ihor.solodrai@xxxxx> --- dwarf_loader.c | 14 +++++++------- dwarves.h | 11 +++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/dwarf_loader.c b/dwarf_loader.c index e54a16c..83a7f54 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,11 +3746,18 @@ static int cus__process_dwflmod(Dwfl_Module *dwflmod, Dwarf *dw = dwfl_module_getdwarf(dwflmod, &dwbias); int err = DWARF_CB_OK; + if (parms->conf->pre_load_module) { + err = parms->conf->pre_load_module(dwflmod, 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); } + /* * XXX We will fall back to try finding other debugging * formats (CTF), so no point in telling this to the user diff --git a/dwarves.h b/dwarves.h index f147b2b..eb3be6e 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 @@ -106,6 +114,7 @@ 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_load_module)(Dwfl_Module *mod, Elf *elf); }; /** struct conf_fprintf - hints to the __fprintf routines @@ -167,8 +176,6 @@ struct conf_fprintf { uint8_t skip_emitting_modifier:1; }; -struct cus; - struct cus *cus__new(void); void cus__delete(struct cus *cus); -- 2.43.0