machoload.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2009 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_MACHOLOAD_HEADER
  19. #define GRUB_MACHOLOAD_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_macho_file
  26. {
  27. grub_file_t file;
  28. grub_ssize_t offset32;
  29. grub_ssize_t end32;
  30. int ncmds32;
  31. grub_size_t cmdsize32;
  32. grub_uint8_t *cmds32;
  33. grub_ssize_t offset64;
  34. grub_ssize_t end64;
  35. int ncmds64;
  36. grub_size_t cmdsize64;
  37. grub_uint8_t *cmds64;
  38. };
  39. typedef struct grub_macho_file *grub_macho_t;
  40. grub_macho_t grub_macho_open (const char *);
  41. grub_macho_t grub_macho_file (grub_file_t);
  42. grub_err_t grub_macho_close (grub_macho_t);
  43. int grub_macho_contains_macho32 (grub_macho_t);
  44. grub_err_t grub_macho_size32 (grub_macho_t macho, grub_uint32_t *segments_start,
  45. grub_uint32_t *segments_end, int flags);
  46. grub_uint32_t grub_macho_get_entry_point32 (grub_macho_t macho);
  47. int grub_macho_contains_macho64 (grub_macho_t);
  48. grub_err_t grub_macho_size64 (grub_macho_t macho, grub_uint64_t *segments_start,
  49. grub_uint64_t *segments_end, int flags);
  50. grub_uint64_t grub_macho_get_entry_point64 (grub_macho_t macho);
  51. /* Ignore BSS segments when loading. */
  52. #define GRUB_MACHO_NOBSS 0x1
  53. grub_err_t grub_macho_load32 (grub_macho_t macho, char *offset, int flags);
  54. grub_err_t grub_macho_load64 (grub_macho_t macho, char *offset, int flags);
  55. /* Like filesize and file_read but take only 32-bit part
  56. for current architecture. */
  57. grub_size_t grub_macho_filesize32 (grub_macho_t macho);
  58. grub_err_t grub_macho_readfile32 (grub_macho_t macho, void *dest);
  59. grub_size_t grub_macho_filesize64 (grub_macho_t macho);
  60. grub_err_t grub_macho_readfile64 (grub_macho_t macho, void *dest);
  61. void grub_macho_parse32 (grub_macho_t macho);
  62. void grub_macho_parse64 (grub_macho_t macho);
  63. #endif /* ! GRUB_MACHOLOAD_HEADER */