简体   繁体   中英

Hot to get the ELF symbols from GRUB2

I'm using the multiboot2 for my kernel, and I'm trying to get the ELF symbols from GRUB2, but I do not know how to do that.

I have set .long MULTIBOOT_TAG_TYPE_ELF_SECTIONS in boot.s, also I got elf type, size, num, entsize and shndx from grub2.

.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];
};

在多重引导信息中搜索type = 9的标记。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM