dl: Provide a fake grub_dl_set_persistent() and grub_dl_is_persistent() for the emu target

Trying to start grub-emu with a module that calls grub_dl_set_persistent()
and grub_dl_is_persistent() will crash because grub-emu fakes modules and
passes NULL to the module init function.

Provide an empty function for the emu case.

Fixes: ee7808e219 (dl: Add support for persistent modules)

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Daniel Axtens
2025-06-26 17:19:25 +02:00
committed by Daniel Kiper
parent 409e72cedf
commit ba8eadde6b
+20 -1
View File
@@ -242,6 +242,25 @@ grub_dl_get (const char *name)
return 0;
}
#ifdef GRUB_MACHINE_EMU
/*
* Under grub-emu, modules are faked and NULL is passed to GRUB_MOD_INIT.
* So we fake this out to avoid a NULL deref.
*/
static inline void
grub_dl_set_persistent (grub_dl_t mod __attribute__((unused)))
{
}
/*
* Under grub-emu, modules are faked and NULL is passed to GRUB_MOD_INIT.
* So we fake this out to avoid a NULL deref.
*/
static inline int
grub_dl_is_persistent (grub_dl_t mod __attribute__((unused)))
{
}
#else
static inline void
grub_dl_set_persistent (grub_dl_t mod)
{
@@ -253,7 +272,7 @@ grub_dl_is_persistent (grub_dl_t mod)
{
return mod->persistent;
}
#endif
#endif
grub_err_t grub_dl_register_symbol (const char *name, void *addr,