aout.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2008 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. /*-
  19. * Copyright (c) 1992, 1993
  20. * The Regents of the University of California. All rights reserved.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the above copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 4. Neither the name of the University nor the names of its contributors
  31. * may be used to endorse or promote products derived from this software
  32. * without specific prior written permission.
  33. *
  34. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  35. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  36. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  37. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  38. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  39. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  40. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  41. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  42. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  43. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  44. * SUCH DAMAGE.
  45. *
  46. * from: @(#)exec.h 8.1 (Berkeley) 6/11/93
  47. * $FreeBSD$
  48. */
  49. #ifndef GRUB_AOUT_HEADER
  50. #define GRUB_AOUT_HEADER 1
  51. #include <grub/types.h>
  52. #include <grub/file.h>
  53. struct grub_aout32_header
  54. {
  55. grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
  56. grub_uint32_t a_text; /* text segment size */
  57. grub_uint32_t a_data; /* initialized data size */
  58. grub_uint32_t a_bss; /* uninitialized data size */
  59. grub_uint32_t a_syms; /* symbol table size */
  60. grub_uint32_t a_entry; /* entry point */
  61. grub_uint32_t a_trsize; /* text relocation size */
  62. grub_uint32_t a_drsize; /* data relocation size */
  63. };
  64. struct grub_aout64_header
  65. {
  66. grub_uint32_t a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */
  67. grub_uint64_t a_text; /* text segment size */
  68. grub_uint64_t a_data; /* initialized data size */
  69. grub_uint64_t a_bss; /* uninitialized data size */
  70. grub_uint64_t a_syms; /* symbol table size */
  71. grub_uint64_t a_entry; /* entry point */
  72. grub_uint64_t a_trsize; /* text relocation size */
  73. grub_uint64_t a_drsize; /* data relocation size */
  74. };
  75. union grub_aout_header
  76. {
  77. struct grub_aout32_header aout32;
  78. struct grub_aout64_header aout64;
  79. };
  80. #define AOUT_TYPE_NONE 0
  81. #define AOUT_TYPE_AOUT32 1
  82. #define AOUT_TYPE_AOUT64 6
  83. #define AOUT32_OMAGIC 0x107 /* 0407 old impure format */
  84. #define AOUT32_NMAGIC 0x108 /* 0410 read-only text */
  85. #define AOUT32_ZMAGIC 0x10b /* 0413 demand load format */
  86. #define AOUT32_QMAGIC 0xcc /* 0314 "compact" demand load format */
  87. #define AOUT64_OMAGIC 0x1001
  88. #define AOUT64_ZMAGIC 0x1002
  89. #define AOUT64_NMAGIC 0x1003
  90. #define AOUT_MID_ZERO 0 /* unknown - implementation dependent */
  91. #define AOUT_MID_SUN010 1 /* sun 68010/68020 binary */
  92. #define AOUT_MID_SUN020 2 /* sun 68020-only binary */
  93. #define AOUT_MID_I386 134 /* i386 BSD binary */
  94. #define AOUT_MID_SPARC 138 /* sparc */
  95. #define AOUT_MID_HP200 200 /* hp200 (68010) BSD binary */
  96. #define AOUT_MID_SUN 0x103
  97. #define AOUT_MID_HP300 300 /* hp300 (68020+68881) BSD binary */
  98. #define AOUT_MID_HPUX 0x20C /* hp200/300 HP-UX binary */
  99. #define AOUT_MID_HPUX800 0x20B /* hp800 HP-UX binary */
  100. #define AOUT_FLAG_PIC 0x10 /* contains position independent code */
  101. #define AOUT_FLAG_DYNAMIC 0x20 /* contains run-time link-edit info */
  102. #define AOUT_FLAG_DPMASK 0x30 /* mask for the above */
  103. #define AOUT_GETMAGIC(header) ((header).a_midmag & 0xffff)
  104. #define AOUT_GETMID(header) ((header).a_midmag >> 16) & 0x03ff)
  105. #define AOUT_GETFLAG(header) ((header).a_midmag >> 26) & 0x3f)
  106. #ifndef GRUB_UTIL
  107. int EXPORT_FUNC(grub_aout_get_type) (union grub_aout_header *header);
  108. grub_err_t EXPORT_FUNC(grub_aout_load) (grub_file_t file, int offset,
  109. void *load_addr, int load_size,
  110. grub_size_t bss_size);
  111. #endif
  112. #endif /* ! GRUB_AOUT_HEADER */