* 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. */
| 471 | * sys/kern/kern_ksyms.c CVS Revision 1.71. |
| 472 | */ |
| 473 | static void |
| 474 | xen_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 | |
| 513 | static caddr_t |
no outgoing calls
no test coverage detected