@@ -3796,13 +3796,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,
@@ -3826,11 +3819,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
@@ -37,6 +37,7 @@
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
struct cu;
+struct cus;
enum load_steal_kind {
LSK__KEEPIT,
@@ -59,6 +60,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
@@ -107,6 +115,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
@@ -168,8 +177,6 @@ struct conf_fprintf {
uint8_t skip_emitting_modifier:1;
};
-struct cus;
-
struct cus *cus__new(void);
void cus__delete(struct cus *cus);
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@pm.me> --- dwarf_loader.c | 14 +++++++------- dwarves.h | 11 +++++++++-- 2 files changed, 16 insertions(+), 9 deletions(-)