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.old / linuxelf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-20  |  4.2 KB  |  192 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.  
  75. struct dynamic{
  76.   int d_tag;
  77.   union{
  78.     int d_val;
  79.     char * d_ptr;
  80.   } d_un;
  81. };
  82.  
  83. /* THe following are used with relocations */
  84. #define ELF32_R_SYM(x) ((x) >> 8)
  85. #define ELF32_R_TYPE(x) ((x) & 0xff)
  86.  
  87. #define R_386_NONE    0
  88. #define R_386_32    1
  89. #define R_386_PC32    2
  90. #define R_386_GOT32    3
  91. #define R_386_PLT32    4
  92. #define R_386_COPY    5
  93. #define R_386_GLOB_DAT    6
  94. #define R_386_JMP_SLOT    7
  95. #define R_386_RELATIVE    8
  96. #define R_386_GOTOFF    9
  97. #define R_386_GOTPC    10
  98. #define R_386_NUM    11
  99.  
  100. struct Elf32_Rel{
  101.   unsigned int * offset;
  102.   int info;
  103. };
  104.  
  105. struct Elf32_Rela{
  106.   unsigned int * offset;
  107.   int info;
  108.   int addend;
  109. };
  110.  
  111. struct Elf32_Sym{
  112.   int st_name;
  113.   unsigned int st_value;
  114.   int st_size;
  115.   unsigned char st_info;
  116.   unsigned char st_other;
  117.   short int st_shndx;
  118. };
  119.  
  120. struct elfhdr{
  121.   char    e_ident[16];
  122.   short int e_type;
  123.   short int e_machine;
  124.   int   e_version;
  125.   char *e_entry;  /* Entry point */
  126.   int   e_phoff;
  127.   int   e_shoff;
  128.   int   e_flags;
  129.   short int e_ehsize;
  130.   short int e_phentsize;
  131.   short int e_phnum;
  132.   short int e_shentsize;
  133.   short int e_shnum;
  134.   short int e_shstrndx;
  135. };
  136.  
  137. struct elf_phdr{
  138.   int p_type;
  139.   int p_offset;
  140.   int p_vaddr;
  141.   int p_paddr;
  142.   int p_filesz;
  143.   int p_memsz;
  144.   int p_flags;
  145.   int p_align;
  146. };
  147.  
  148. extern _dl_linux_resolve(void);
  149. extern struct elf_resolve * _dl_load_shared_library(struct dyn_elf *,
  150.                 char * libname);
  151. extern void * _dl_malloc(int size);
  152.  
  153. extern struct elf_resolve * _dl_load_elf_shared_library(char * libname, int);
  154. int _dl_copy_fixups(struct dyn_elf * tpnt);
  155.  
  156. extern int linux_run(int argc, char * argv[]);
  157.  
  158. extern void _dl_parse_lazy_relocation_information(struct elf_resolve * tpnt, int rel_addr,
  159.        int rel_size, int type);
  160.  
  161. extern int _dl_parse_relocation_information(struct elf_resolve * tpnt, int rel_addr,
  162.        int rel_size, int type);
  163. extern int _dl_parse_copy_information(struct dyn_elf * rpnt, int rel_addr,
  164.        int rel_size, int type);
  165.  
  166. extern unsigned int _dl_linux_resolver(int dummy, int i);
  167.  
  168.  
  169. /* This means that we may be forced to manually search for copy fixups
  170.    which were omitted by the linker.  We cannot depend upon the DT_TEXTREL
  171.    to tell us whether there are fixups in a text section or not. */
  172.  
  173. #ifndef SVR4_BUGCOMPAT
  174. #define SVR4_BUGCOMPAT 1
  175. #endif
  176.  
  177. #define PF_R 4
  178. #define PF_W 2
  179. #define PF_X 1
  180.  
  181. /* Convert between the Linux flags for page protections and the
  182.    ones specified in the ELF standard. */
  183.  
  184. #define LXFLAGS(X) ( (((X) & PF_R) ? PROT_READ : 0) | \
  185.             (((X) & PF_W) ? PROT_WRITE : 0) | \
  186.             (((X) & PF_X) ? PROT_EXEC : 0))
  187.  
  188. /* Use BROKEN_LINKER if the SVr4 linker is being used.  It fails to emit
  189.    COPY relocations in some cases */
  190.  
  191. /* #define BROKEN_LINKER */
  192.