diff mbox series

[dwarves,v2,03/10] dwarf_loader: introduce pre_load_module hook to conf_load

Message ID 20241213223641.564002-4-ihor.solodrai@pm.me (mailing list archive)
State Not Applicable
Headers show
Series pahole: shared ELF and faster reproducible BTF encoding | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Ihor Solodrai Dec. 13, 2024, 10:36 p.m. UTC
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>

Link: https://lore.kernel.org/dwarves/20241128012341.4081072-5-ihor.solodrai@pm.me/
---
 dwarf_loader.c | 6 ++++++
 dwarves.h      | 1 +
 2 files changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/dwarf_loader.c b/dwarf_loader.c
index 598fde4..bd65c56 100644
--- a/dwarf_loader.c
+++ b/dwarf_loader.c
@@ -3826,6 +3826,12 @@  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,
diff --git a/dwarves.h b/dwarves.h
index 1cb0d62..d516d52 100644
--- a/dwarves.h
+++ b/dwarves.h
@@ -107,6 +107,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