elf.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*-
  2. * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  3. *
  4. * Copyright (c) 2001 David E. O'Brien
  5. * Copyright (c) 1996-1997 John D. Polstra.
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions
  10. * are met:
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the distribution.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  18. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  21. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * $FreeBSD$
  30. */
  31. #ifndef _MACHINE_ELF_H_
  32. #define _MACHINE_ELF_H_ 1
  33. /*
  34. * EABI ELF definitions for the PowerPC architecture.
  35. * See "PowerPC Embedded Application Binary Interface, 32-Bit Impliementation"
  36. * [ppc-eabi-1995-01.pdf] for details.
  37. */
  38. #ifndef __ELF_WORD_SIZE
  39. #ifdef __powerpc64__
  40. #define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */
  41. #else
  42. #define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */
  43. #endif
  44. #endif
  45. #include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */
  46. #include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */
  47. #include <sys/elf_generic.h>
  48. #if __ELF_WORD_SIZE == 64
  49. #define ELF_ARCH EM_PPC64
  50. #define ELF_MACHINE_OK(x) ((x) == EM_PPC64)
  51. #else
  52. #define ELF_ARCH EM_PPC
  53. #define ELF_ARCH32 EM_PPC
  54. #define ELF_MACHINE_OK(x) ((x) == EM_PPC)
  55. #endif
  56. /*
  57. * Auxiliary vector entries for passing information to the interpreter.
  58. *
  59. * The PowerPC supplement to the SVR4 ABI specification names this "auxv_t",
  60. * but POSIX lays claim to all symbols ending with "_t".
  61. */
  62. typedef struct { /* Auxiliary vector entry on initial stack */
  63. int a_type; /* Entry type. */
  64. union {
  65. #ifdef __powerpc64__
  66. int a_val; /* Integer value */
  67. #else
  68. long a_val; /* Integer value. */
  69. void *a_ptr; /* Address. */
  70. void (*a_fcn)(void); /* Function pointer (not used). */
  71. #endif
  72. } a_un;
  73. } Elf32_Auxinfo;
  74. typedef struct { /* Auxiliary vector entry on initial stack */
  75. long a_type; /* Entry type. */
  76. union {
  77. long a_val; /* Integer value. */
  78. void *a_ptr; /* Address. */
  79. void (*a_fcn)(void); /* Function pointer (not used). */
  80. } a_un;
  81. } Elf64_Auxinfo;
  82. __ElfType(Auxinfo);
  83. /*
  84. * Relocation types.
  85. */
  86. #define R_PPC_COUNT 37 /* Count of defined relocation types. */
  87. /* Count of defined relocation types. */
  88. #define R_PPC_EMB_COUNT (R_PPC_EMB_RELSDA - R_PPC_EMB_NADDR32 + 1)
  89. /* Define "machine" characteristics */
  90. #if BYTE_ORDER == LITTLE_ENDIAN
  91. #define ELF_TARG_DATA ELFDATA2LSB
  92. #else
  93. #define ELF_TARG_DATA ELFDATA2MSB
  94. #endif
  95. #if __ELF_WORD_SIZE == 64
  96. #define ELF_TARG_CLASS ELFCLASS64
  97. #define ELF_TARG_MACH EM_PPC64
  98. #define ELF_TARG_VER 1
  99. #else
  100. #define ELF_TARG_CLASS ELFCLASS32
  101. #define ELF_TARG_MACH EM_PPC
  102. #define ELF_TARG_VER 1
  103. #endif
  104. #define ET_DYN_LOAD_ADDR 0x01010000
  105. #define AT_OLD_NULL AT_NULL
  106. #define AT_OLD_IGNORE AT_IGNORE
  107. #define AT_OLD_EXECFD AT_EXECFD
  108. #define AT_OLD_PHDR AT_PHDR
  109. #define AT_OLD_PHENT AT_PHENT
  110. #define AT_OLD_PHNUM AT_PHNUM
  111. #define AT_OLD_PAGESZ AT_PAGESZ
  112. #define AT_OLD_BASE AT_BASE
  113. #define AT_OLD_FLAGS AT_FLAGS
  114. #define AT_OLD_ENTRY AT_ENTRY
  115. #define AT_OLD_NOTELF AT_NOTELF
  116. #define AT_OLD_UID AT_UID
  117. #define AT_OLD_EUID AT_EUID
  118. #define AT_OLD_EXECPATH 13
  119. #define AT_OLD_CANARY 14
  120. #define AT_OLD_CANARYLEN 15
  121. #define AT_OLD_OSRELDATE 16
  122. #define AT_OLD_NCPUS 17
  123. #define AT_OLD_PAGESIZES 18
  124. #define AT_OLD_PAGESIZESLEN 19
  125. #define AT_OLD_STACKPROT 21
  126. #define AT_OLD_TIMEKEEP AT_TIMEKEEP
  127. #define AT_OLD_EHDRFLAGS AT_EHDRFLAGS
  128. #define AT_OLD_HWCAP AT_HWCAP
  129. #define AT_OLD_HWCAP2 AT_HWCAP2
  130. #define AT_OLD_COUNT 27 /* Count of defined aux entry types. */
  131. #endif /* !_MACHINE_ELF_H_ */