Skip to contentSkip to conversation

kern/dl: Disable grub_dl_unload_unneeded

PATCH In review Colin Watson 2 participants 2 messages Mar 20, 2021 – Mar 23, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kern/dl: Disable grub_dl_unload_unneeded

grub_dl_unload_unneeded has been unused by default since de04eecfa9 put its only call within an "#if 0", so there's no point in it sitting around taking up space in the core image. Turn the "#if 0" into "#ifdef GRUB_UNLOAD_UNNEEDED_MODULES" just in case somebody is turning this code back on locally for some reason, and guard all the relevant code with it rather than just the call in grub_memalign.

DOWN: obj/i386-pc/grub-core/kernel.img (31740 > 31708) - change: -32
DOWN: i386-pc core image (biosdisk ext2 part_msdos) (27453 > 27430) - change: -23
DOWN: i386-pc core image (biosdisk ext2 part_msdos diskfilter mdraid09) (32367 > 32334) - change: -33
DOWN: i386-pc core image (biosdisk ext2 part_msdos lvm mdraid1x) (35595 > 35594) - change: -1

---
 grub-core/kern/dl.c | 2 ++
 grub-core/kern/mm.c | 2 +-
 include/grub/dl.h   | 2 ++
 3 files changed, 5 insertions(+), 1 deletion(-)
grub-core/kern/dl.c +2 -0
index 48f8a7907..88cd2fddc 100644
@@ -804,6 +804,7 @@ grub_dl_unload (grub_dl_t mod)
   return 1;
 }
 
+#ifdef GRUB_UNLOAD_UNNEEDED_MODULES
 /* Unload unneeded modules.  */
 void
 grub_dl_unload_unneeded (void)
@@ -823,3 +824,4 @@ grub_dl_unload_unneeded (void)
       p = p->next;
     }
 }
+#endif
grub-core/kern/mm.c +1 -1
index c070afc62..a913d66bf 100644
@@ -360,7 +360,7 @@ grub_memalign (grub_size_t align, grub_size_t size)
       count++;
       goto again;
 
-#if 0
+#ifdef GRUB_UNLOAD_UNNEEDED_MODULES
     case 1:
       /* Unload unneeded modules.  */
       grub_dl_unload_unneeded ();
include/grub/dl.h +2 -0
index b3753c9ca..4a0712406 100644
@@ -203,7 +203,9 @@ grub_dl_t EXPORT_FUNC(grub_dl_load) (const char *name);
 grub_dl_t grub_dl_load_core (void *addr, grub_size_t size);
 grub_dl_t EXPORT_FUNC(grub_dl_load_core_noinit) (void *addr, grub_size_t size);
 int EXPORT_FUNC(grub_dl_unload) (grub_dl_t mod);
+#ifdef GRUB_UNLOAD_UNNEEDED_MODULES
 extern void grub_dl_unload_unneeded (void);
+#endif
 extern int EXPORT_FUNC(grub_dl_ref) (grub_dl_t mod);
 extern int EXPORT_FUNC(grub_dl_unref) (grub_dl_t mod);
 extern int EXPORT_FUNC(grub_dl_ref_count) (grub_dl_t mod);
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · Colin Watson

grub_dl_unload_unneeded has been unused by default since de04eecfa9 put its only call within an "#if 0", so there's no point in it sitting around taking up space in the core image. Turn the "#if 0" into "#ifdef GRUB_UNLOAD_UNNEEDED_MODULES" just in case somebody is turning this code back on locally for some reason, and guard all the relevant code with it rather than just the call in grub_memalign.

I would drop this function entirely. If somebody needs it they can restore it from git history.

Daniel