aout.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*
  2. * aout.h
  3. *
  4. * Copyright (C) 2016 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _AOUT_H_
  20. #define _AOUT_H_
  21. #include <common.h>
  22. #include <thread.h>
  23. #include <filesystem.h>
  24. #include <process.h>
  25. #define OMAGIC 0x0107
  26. #define NMAGIC 0x0108
  27. #define ZMAGIC 0x010B
  28. #define QMAGIC 0x00CC
  29. #define AOUT_TYPE_FIELD(x) ((x) & 0x1E)
  30. #define AOUT_SYM_UNDEFINED 0x00
  31. #define AOUT_SYM_EXTERN 0x01
  32. #define AOUT_SYM_ABSOLUTE 0x02
  33. #define AOUT_SYM_TEXT 0x04
  34. #define AOUT_SYM_DATA 0x06
  35. #define AOUT_SYM_BSS 0x08
  36. #pragma pack(push, 1)
  37. typedef struct
  38. {
  39. dword_t midmag;
  40. dword_t text_size;
  41. dword_t data_size;
  42. dword_t bss_size;
  43. dword_t sym_size;
  44. dword_t entry_point;
  45. dword_t text_reloc_size;
  46. dword_t data_reloc_size;
  47. } aout_header_t;
  48. typedef struct
  49. {
  50. dword_t address;
  51. dword_t symbol_num : 24;
  52. dword_t pc_relative : 1;
  53. dword_t length : 2;
  54. dword_t external : 1;
  55. dword_t base_rel : 1;
  56. dword_t jump_table : 1;
  57. dword_t relative : 1;
  58. dword_t copy : 1;
  59. } aout_reloc_t;
  60. typedef struct
  61. {
  62. union
  63. {
  64. dword_t name_offset;
  65. char *name;
  66. };
  67. byte_t type;
  68. byte_t other;
  69. word_t reserved;
  70. dword_t value;
  71. } aout_symbol_t;
  72. #pragma pack(pop)
  73. #endif