MCPcopy Create free account
hub / github.com/F-Stack/f-stack / xen_pvh_parse_symtab

Function xen_pvh_parse_symtab

freebsd/x86/xen/pv.c:473–510  ·  view source on GitHub ↗

* The way Xen loads the symtab is different from the native boot loader, * because it's tailored for NetBSD. So we have to adapt and use the same * method as NetBSD. Portions of the code below have been picked from NetBSD: * sys/kern/kern_ksyms.c CVS Revision 1.71. */

Source from the content-addressed store, hash-verified

471 * sys/kern/kern_ksyms.c CVS Revision 1.71.
472 */
473static void
474xen_pvh_parse_symtab(void)
475{
476 Elf_Ehdr *ehdr;
477 Elf_Shdr *shdr;
478 uint32_t size;
479 int i, j;
480
481 size = end;
482
483 ehdr = (Elf_Ehdr *)(&end + 1);
484 if (memcmp(ehdr->e_ident, ELFMAG, SELFMAG) ||
485 ehdr->e_ident[EI_CLASS] != ELF_TARG_CLASS ||
486 ehdr->e_version > 1) {
487 xc_printf("Unable to load ELF symtab: invalid symbol table\n");
488 return;
489 }
490
491 shdr = (Elf_Shdr *)((uint8_t *)ehdr + ehdr->e_shoff);
492 /* Find the symbol table and the corresponding string table. */
493 for (i = 1; i < ehdr->e_shnum; i++) {
494 if (shdr[i].sh_type != SHT_SYMTAB)
495 continue;
496 if (shdr[i].sh_offset == 0)
497 continue;
498 ksymtab = (uintptr_t)((uint8_t *)ehdr + shdr[i].sh_offset);
499 ksymtab_size = shdr[i].sh_size;
500 j = shdr[i].sh_link;
501 if (shdr[j].sh_offset == 0)
502 continue; /* Can this happen? */
503 kstrtab = (uintptr_t)((uint8_t *)ehdr + shdr[j].sh_offset);
504 break;
505 }
506
507 if (ksymtab == 0 || kstrtab == 0)
508 xc_printf(
509 "Unable to load ELF symtab: could not find symtab or strtab\n");
510}
511#endif
512
513static caddr_t

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected