if (s->sh_type == SHT_SYMTAB)
break;
+ /* Module without symbol table may still be used to pull in dependencies.
+ We verify at build time that such modules do not contain any relocations
+ that may reference symbol table. */
if (i == e->e_shnum)
- return grub_error (GRUB_ERR_BAD_MODULE, N_("no symbol table"));
+ return GRUB_ERR_NONE;
#ifdef GRUB_MODULES_MACHINE_READONLY
mod->symtab = grub_malloc (s->sh_size);
if (seg)
{
+ if (!mod->symtab)
+ return grub_error (GRUB_ERR_BAD_MODULE, "relocation without symbol table");
+
err = grub_arch_dl_relocate_symbols (mod, ehdr, s, seg);
if (err)
return err;
break;
if (i == grub_target_to_host16 (e->e_shnum))
- grub_util_error ("no symbol table");
+ return NULL;
sym = (Elf_Sym *) ((char *) e + grub_target_to_host (s->sh_offset));
*size = grub_target_to_host (s->sh_size);
Elf_Word size, entsize;
unsigned i;
+ /* Module without symbol table and without .moddeps section is useless
+ at boot time, so catch it early to prevent build errors */
sym = get_symtab (arch, e, &size, &entsize);
+ if (!sym)
+ {
+ Elf_Shdr *s = find_section (arch, e, ".moddeps");
+
+ if (!s)
+ grub_util_error ("no symbol table and no .moddeps section");
+
+ if (!s->sh_size)
+ grub_util_error ("no symbol table and empty .moddeps section");
+
+ return;
+ }
for (i = 0;
i < size / entsize;
Elf_Word symtabsize, symtabentsize;
symtab = get_symtab (arch, ehdr, &symtabsize, &symtabentsize);
+ if (!symtab)
+ grub_util_error ("relocation without symbol table");
for (rel = (Elf_Rel *) ((char *) ehdr + grub_target_to_host (s->sh_offset)),
max = (Elf_Rel *) ((char *) rel + grub_target_to_host (s->sh_size));