home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / elf / d-link / linuxelf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-04  |  4.3 KB  |  199 lines

  1. /* THese constants are for the segment types stored in the image headers */
  2. #define PT_NULL    0
  3. #define PT_LOAD    1
  4. #define PT_DYNAMIC 2
  5. #define PT_INTERP  3
  6. #define PT_NOTE    4
  7. #define PT_SHLIB   5
  8. #define PT_PHDR    6
  9. #define PT_LOPROC  0x70000000
  10. #define PT_HIPROC  0x7fffffff
  11.  
  12. /* These constants define the different elf file types */
  13. #define ET_NONE   0
  14. #define ET_REL    1
  15. #define ET_EXEC   2
  16. #define ET_DYN    3
  17. #define ET_CORE   4
  18. #define ET_LOPROC 5
  19. #define ET_HIPROC 6
  20.  
  21. /* These constants define the various ELF target machines */
  22. #define EM_NONE  0
  23. #define EM_M32   1
  24. #define EM_SPARC 2
  25. #define EM_386   3
  26. #define EM_68K   4
  27. #define EM_88K   5
  28. #define EM_486   6   /* Perhaps disused */
  29. #define EM_860   7
  30.  
  31. /* This is the info that is needed to parse the dynamic section of the file */
  32. #define DT_NULL        0
  33. #define DT_NEEDED    1
  34. #define DT_PLTRELSZ    2
  35. #define DT_PLTGOT    3
  36. #define DT_HASH        4
  37. #define DT_STRTAB    5
  38. #define DT_SYMTAB    6
  39. #define DT_RELA        7
  40. #define DT_RELASZ    8
  41. #define DT_RELAENT    9
  42. #define DT_STRSZ    10
  43. #define DT_SYMENT    11
  44. #define DT_INIT        12
  45. #define DT_FINI        13
  46. #define DT_SONAME    14
  47. #define DT_RPATH     15
  48. #define DT_SYMBOLIC    16
  49. #define DT_REL            17
  50. #define DT_RELSZ    18
  51. #define DT_RELENT    19
  52. #define DT_PLTREL    20
  53. #define DT_DEBUG    21
  54. #define DT_TEXTREL    22
  55. #define DT_JMPREL    23
  56. #define DT_LOPROC    0x70000000
  57. #define DT_HIPROC    0x7fffffff
  58.  
  59. /* This info is needed when parsing the symbol table */
  60. #define STB_LOCAL  0
  61. #define STB_GLOBAL 1
  62. #define STB_WEAK   2
  63.  
  64. #define STT_NOTYPE  0
  65. #define STT_OBJECT  1
  66. #define STT_FUNC    2
  67. #define STT_SECTION 3
  68. #define STT_FILE    4
  69.  
  70. #define ELF32_ST_BIND(x) ((x) >> 4)
  71. #define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
  72.  
  73.  
  74. #if 0
  75. struct dynamic{
  76.   int d_tag;
  77.   union{
  78.     int d_val;
  79.     char * d_ptr;
  80.   } d_un;
  81. };
  82. #endif
  83.  
  84. /* THe following are used with relocations */
  85. #define ELF32_R_SYM(x) ((x) >> 8)
  86. #define ELF32_R_TYPE(x) ((x) & 0xff)
  87.  
  88. #define R_386_NONE    0
  89. #define R_386_32    1
  90. #define R_386_PC32    2
  91. #define R_386_GOT32    3
  92. #define R_386_PLT32    4
  93. #define R_386_COPY    5
  94. #define R_386_GLOB_DAT    6
  95. #define R_386_JMP_SLOT    7
  96. #define R_386_RELATIVE    8
  97. #define R_386_GOTOFF    9
  98. #define R_386_GOTPC    10
  99. #define R_386_NUM    11
  100.  
  101. struct Elf32_Rel{
  102.   unsigned int * offset;
  103.   int info;
  104. };
  105.  
  106. struct Elf32_Rela{
  107.   unsigned int * offset;
  108.   int info;
  109.   int addend;
  110. };
  111.  
  112. struct Elf32_Sym{
  113.   int st_name;
  114.   unsigned int st_value;
  115.   int st_size;
  116.   unsigned char st_info;
  117.   unsigned char st_other;
  118.   short int st_shndx;
  119. };
  120.  
  121. #if 0
  122.  
  123. struct elfhdr{
  124.   char    e_ident[16];
  125.   short int e_type;
  126.   short int e_machine;
  127.   int   e_version;
  128.   char *e_entry;  /* Entry point */
  129.   int   e_phoff;
  130.   int   e_shoff;
  131.   int   e_flags;
  132.   short int e_ehsize;
  133.   short int e_phentsize;
  134.   short int e_phnum;
  135.   short int e_shentsize;
  136.   short int e_shnum;
  137.   short int e_shstrndx;
  138. };
  139.  
  140. struct elf_phdr{
  141.   int p_type;
  142.   int p_offset;
  143.   int p_vaddr;
  144.   int p_paddr;
  145.   int p_filesz;
  146.   int p_memsz;
  147.   int p_flags;
  148.   int p_align;
  149. };
  150.  
  151. #endif
  152.  
  153. extern _dl_linux_resolve(void);
  154. extern struct elf_resolve * _dl_load_shared_library(struct dyn_elf *,
  155.                 char * libname);
  156. extern void * _dl_malloc(int size);
  157.  
  158. extern struct elf_resolve * _dl_load_elf_shared_library(char * libname, int);
  159. int _dl_copy_fixups(struct dyn_elf * tpnt);
  160.  
  161. extern int linux_run(int argc, char * argv[]);
  162.  
  163. extern void _dl_parse_lazy_relocation_information(struct elf_resolve * tpnt, int rel_addr,
  164.        int rel_size, int type);
  165.  
  166. extern int _dl_parse_relocation_information(struct elf_resolve * tpnt, int rel_addr,
  167.        int rel_size, int type);
  168. extern int _dl_parse_copy_information(struct dyn_elf * rpnt, int rel_addr,
  169.        int rel_size, int type);
  170.  
  171. extern unsigned int _dl_linux_resolver(int dummy, int i);
  172.  
  173.  
  174. /* This means that we may be forced to manually search for copy fixups
  175.    which were omitted by the linker.  We cannot depend upon the DT_TEXTREL
  176.    to tell us whether there are fixups in a text section or not. */
  177.  
  178. #ifndef SVR4_BUGCOMPAT
  179. #define SVR4_BUGCOMPAT 1
  180. #endif
  181.  
  182. #define PF_R 4
  183. #define PF_W 2
  184. #define PF_X 1
  185.  
  186. /* Convert between the Linux flags for page protections and the
  187.    ones specified in the ELF standard. */
  188.  
  189. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  190.             (((X) & PF_W) ? PROT_WRITE : 0) | \
  191.             (((X) & PF_X) ? PROT_EXEC : 0))
  192.  
  193. /* Use BROKEN_LINKER if the SVr4 linker is being used.  It fails to emit
  194.    COPY relocations in some cases */
  195.  
  196. #ifdef IBCS_COMPATIBLE
  197. #define BROKEN_LINKER
  198. #endif
  199.