我正在为我的内核使用 multiboot2,我正在尝试从 GRUB2 获取 ELF 符号,但我不知道该怎么做。
我已经.long MULTIBOOT_TAG_TYPE_ELF_SECTIONS
在 boot.s 中设置了,我还从 grub2 获得了 elf 类型、大小、num、entsize 和 shndx。
.section .multiboot_header
.align 8
multiboot_header:
.long MULTIBOOT2_HEADER_MAGIC
.long MULTIBOOT_ARCHITECTURE_I386
.long multiboot_header_end - multiboot_header
.long -(MULTIBOOT2_HEADER_MAGIC + MULTIBOOT_ARCHITECTURE_I386 + multiboot_header_end - multiboot_header)
# multiboot2 information request
.align 8
mbi_tag_start:
.short MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST
.short MULTIBOOT_HEADER_TAG_OPTIONAL
.long mbi_tag_end - mbi_tag_start
.long MULTIBOOT_TAG_TYPE_CMDLINE
.long MULTIBOOT_TAG_TYPE_MODULE
.long MULTIBOOT_TAG_TYPE_BOOTDEV
.long MULTIBOOT_TAG_TYPE_MMAP
.long MULTIBOOT_TAG_TYPE_ELF_SECTIONS
.long MULTIBOOT_TAG_TYPE_APM
.align 8
mbi_tag_end:
.short MULTIBOOT_HEADER_TAG_END
.short 0
.long 8
multiboot_header_end:
struct multiboot_tag_elf_sections {
multiboot_uint32_t type;
multiboot_uint32_t size;
multiboot_uint32_t num;
multiboot_uint32_t entsize;
multiboot_uint32_t shndx;
char sections[0];
};