boot: use multiboot2 symbol table
This commit is contained in:
parent
1dea3c9e43
commit
02136a28b5
@ -31,8 +31,7 @@
|
||||
|
||||
extern char _kernel_start, _kernel_end;
|
||||
|
||||
//static struct multiboot_tag_mmap *multiboot_tag_mmap;
|
||||
//static struct multiboot_tag_elf_sections *multiboot_tag_sections;
|
||||
static struct elf_sections elf_sections;
|
||||
static uintptr_t initrd_phys_start;
|
||||
static size_t initrd_size;
|
||||
|
||||
@ -87,9 +86,10 @@ static void entry_multiboot(void) {
|
||||
case MULTIBOOT_TAG_TYPE_CMDLINE:
|
||||
multiboot_tag_cmdline = (struct multiboot_tag_string *) tag;
|
||||
break;
|
||||
//case MULTIBOOT_TAG_TYPE_ELF_SECTIONS:
|
||||
// multiboot_tag_sections = (struct multiboot_tag_elf_sections *) tag;
|
||||
// break;
|
||||
case MULTIBOOT_TAG_TYPE_ELF_SECTIONS:
|
||||
elf_sections.kind = KSYM_TABLE_MULTIBOOT2;
|
||||
elf_sections.tables.multiboot2 = (struct multiboot_tag_elf_sections *) tag;
|
||||
break;
|
||||
case MULTIBOOT_TAG_TYPE_MMAP:
|
||||
multiboot_tag_mmap = (struct multiboot_tag_mmap *) tag;
|
||||
break;
|
||||
@ -221,9 +221,9 @@ void kernel_early_init(uint64_t entry_method) {
|
||||
|
||||
vesa_add_display();
|
||||
|
||||
//if (multiboot_tag_sections) {
|
||||
// ksym_set_multiboot2(multiboot_tag_sections);
|
||||
//}
|
||||
if (elf_sections.kind != KSYM_TABLE_NONE) {
|
||||
ksym_set(&elf_sections);
|
||||
}
|
||||
|
||||
if (rs232_avail & (1 << 0)) {
|
||||
rs232_add_tty(0);
|
||||
|
@ -2,10 +2,18 @@
|
||||
#include "sys/types.h"
|
||||
#include "sys/elf.h"
|
||||
|
||||
struct multiboot_tag_elf_sections;
|
||||
struct elf_sections {
|
||||
enum {
|
||||
KSYM_TABLE_NONE,
|
||||
KSYM_TABLE_MULTIBOOT2,
|
||||
} kind;
|
||||
union {
|
||||
struct multiboot_tag_elf_sections *multiboot2;
|
||||
} tables;
|
||||
};
|
||||
|
||||
void ksym_set_tables(uintptr_t symtab, uintptr_t strtab, size_t symtab_size, size_t strtab_size);
|
||||
void ksym_set_multiboot2(struct multiboot_tag_elf_sections *tag);
|
||||
void ksym_set(struct elf_sections *sections);
|
||||
Elf64_Sym *ksym_lookup(const char *name);
|
||||
int ksym_find_location(uintptr_t addr, const char **name, uintptr_t *base);
|
||||
|
||||
|
12
sys/syms.c
12
sys/syms.c
@ -16,7 +16,7 @@ static size_t g_strtab_size = 0;
|
||||
static struct hash g_symtab_hash;
|
||||
|
||||
// Multiboot2-loaded sections are misaligned for some reason
|
||||
void ksym_set_multiboot2(struct multiboot_tag_elf_sections *tag) {
|
||||
static void ksym_set_multiboot2(struct multiboot_tag_elf_sections *tag) {
|
||||
kinfo("Loading kernel symbols\n");
|
||||
kinfo("%u section headers:\n", tag->num);
|
||||
size_t string_section_offset = tag->shndx * tag->entsize;
|
||||
@ -61,6 +61,16 @@ void ksym_set_multiboot2(struct multiboot_tag_elf_sections *tag) {
|
||||
}
|
||||
}
|
||||
|
||||
void ksym_set(struct elf_sections *sections) {
|
||||
switch (sections->kind) {
|
||||
case KSYM_TABLE_MULTIBOOT2:
|
||||
ksym_set_multiboot2(sections->tables.multiboot2);
|
||||
break;
|
||||
default:
|
||||
__builtin_unreachable();
|
||||
}
|
||||
}
|
||||
|
||||
void ksym_set_tables(uintptr_t s0, uintptr_t s1, size_t z0, size_t z1) {
|
||||
Elf64_Sym *sym;
|
||||
Elf64_Word type, bind;
|
||||
|
Loading…
x
Reference in New Issue
Block a user