elfload.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef GRUB_ELFLOAD_HEADER
  19. #define GRUB_ELFLOAD_HEADER 1
  20. #include <grub/err.h>
  21. #include <grub/elf.h>
  22. #include <grub/file.h>
  23. #include <grub/symbol.h>
  24. #include <grub/types.h>
  25. struct grub_elf_file
  26. {
  27. grub_file_t file;
  28. union {
  29. Elf64_Ehdr ehdr64;
  30. Elf32_Ehdr ehdr32;
  31. } ehdr;
  32. void *phdrs;
  33. };
  34. typedef struct grub_elf_file *grub_elf_t;
  35. typedef grub_err_t (*grub_elf32_load_hook_t)
  36. (Elf32_Phdr *phdr, grub_addr_t *addr, int *load, void *);
  37. typedef grub_err_t (*grub_elf64_load_hook_t)
  38. (Elf64_Phdr *phdr, grub_addr_t *addr, int *load, void *);
  39. grub_elf_t grub_elf_open (const char *);
  40. grub_elf_t grub_elf_file (grub_file_t);
  41. grub_err_t grub_elf_close (grub_elf_t);
  42. int grub_elf_is_elf32 (grub_elf_t);
  43. grub_size_t grub_elf32_size (grub_elf_t, Elf32_Addr *);
  44. grub_err_t grub_elf32_load (grub_elf_t, grub_elf32_load_hook_t, void *,
  45. grub_addr_t *, grub_size_t *);
  46. int grub_elf_is_elf64 (grub_elf_t);
  47. grub_size_t grub_elf64_size (grub_elf_t, Elf64_Addr *);
  48. grub_err_t grub_elf64_load (grub_elf_t, grub_elf64_load_hook_t, void *,
  49. grub_addr_t *, grub_size_t *);
  50. #endif /* ! GRUB_ELFLOAD_HEADER */