type.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* type.h - types for linker */
  2. /* Copyright (C) 1994 Bruce Evans */
  3. typedef int bool_pt;
  4. typedef unsigned char bool_t;
  5. typedef unsigned short u2_t;
  6. typedef unsigned u2_pt;
  7. typedef unsigned long u4_t;
  8. typedef unsigned long u4_pt;
  9. #ifdef HOST_8BIT
  10. typedef char fastin_t;
  11. #else
  12. typedef int fastin_t;
  13. #endif
  14. typedef int fastin_pt;
  15. typedef unsigned flags_t; /* unsigned makes shifts logical */
  16. #ifdef LONG_OFFSETS
  17. typedef unsigned long bin_off_t;
  18. #else
  19. typedef unsigned bin_off_t;
  20. #endif
  21. #ifdef OBJ_H /* obj.h is included */
  22. struct entrylist /* list of entry symbols */
  23. {
  24. struct entrylist *elnext; /* next on list */
  25. struct symstruct *elsymptr; /* entry on list */
  26. };
  27. struct modstruct /* module table entry format */
  28. {
  29. char *filename; /* file containing this module */
  30. char *archentry; /* name of component file for archives */
  31. char *modname; /* name of module */
  32. unsigned long textoffset; /* offset to module text in file */
  33. char class; /* class of module */
  34. char loadflag; /* set if module to be loaded */
  35. char segmaxsize[NSEG / 4]; /* |SF|SE|..|S0|, 2 bits for seg max size */
  36. /* 00 = 1, 01 = 2, 10 = 3, 11 = 4 */
  37. char segsizedesc[NSEG / 4]; /* |SF|SE|..|S0|, 2 bits for #bytes for size */
  38. /* 00 = 0, 01 = 1, 10 = 2, 11 = 4 */
  39. struct symstruct **symparray; /* ^array of ptrs to referenced syms */
  40. struct modstruct *modnext; /* next module in order of initial reading */
  41. char segsize[1]; /* up to 64 size bytes begin here */
  42. }; /* careful with sizeof( struct modstruct )!! */
  43. struct redlist /* list of redefined (exported) symbols */
  44. {
  45. struct redlist *rlnext; /* next on list */
  46. struct symstruct *rlsymptr; /* to symbol with same name, flags */
  47. struct modstruct *rlmodptr; /* module for this redefinition */
  48. bin_off_t rlvalue; /* value for this redefinition */
  49. };
  50. struct symstruct /* symbol table entry format */
  51. {
  52. struct modstruct *modptr; /* module where symbol is defined */
  53. bin_off_t value; /* value of symbol */
  54. flags_t flags; /* see below (unsigned makes shifts logical) */
  55. struct symstruct *next; /* next symbol with same hash value */
  56. char name[1]; /* name is any string beginning here */
  57. }; /* don't use sizeof( struct symstruct )!! */
  58. #endif /* obj.h is included */
  59. /* prototypes */
  60. #ifndef P
  61. #ifdef __STDC__
  62. #define P(x) x
  63. #else
  64. #define P(x) ()
  65. #endif
  66. #endif
  67. /* dump.c */
  68. void dumpmods P((void));
  69. void dumpsyms P((void));
  70. /* io.c */
  71. void ioinit P((char *progname));
  72. void closein P((void));
  73. void closeout P((void));
  74. void errtrace P((char *name, int level));
  75. void executable P((void));
  76. void flusherr P((void));
  77. void openin P((char *filename));
  78. void openout P((char *filename));
  79. void putstr P((char *message));
  80. void put08x P((bin_off_t num));
  81. void put08lx P((bin_off_t num));
  82. void putbstr P((unsigned width, char *str));
  83. void putbyte P((int ch));
  84. int readchar P((void));
  85. void readin P((char *buf, unsigned count));
  86. bool_pt readineofok P((char *buf, unsigned count));
  87. void seekin P((unsigned long offset));
  88. void seekout P((unsigned long offset));
  89. void seektrel P((unsigned long offset));
  90. void writechar P((int c));
  91. void writedrel P((char *buf, unsigned count));
  92. void writeout P((char *buf, unsigned count));
  93. void writetrel P((char *buf, unsigned count));
  94. void fatalerror P((char *message));
  95. void inputerror P((char *message));
  96. void input1error P((char *message));
  97. void outofmemory P((void));
  98. void prematureeof P((void));
  99. void redefined P((char *name, char *message, char *archentry,
  100. char *deffilename, char *defarchentry));
  101. void interseg P((char *fname, char *aname, char *name));
  102. void reserved P((char *name));
  103. void size_error P((int seg, bin_off_t count, bin_off_t size));
  104. void undefined P((char *name));
  105. void usage P((void));
  106. void version_msg P((void));
  107. void use_error P((char *message));
  108. /* ld.c */
  109. int main P((int argc, char **argv));
  110. /* readobj.c */
  111. void objinit P((void));
  112. void readsyms P((char *filename, bool_pt trace));
  113. #ifdef OBJ_H
  114. void entrysym P((struct symstruct *symptr));
  115. unsigned segsizecount P((unsigned seg, struct modstruct *modptr));
  116. #endif
  117. bin_off_t readconvsize P((unsigned countindex));
  118. bin_off_t readsize P((unsigned count));
  119. /* table.c */
  120. void syminit P((void));
  121. struct symstruct *addsym P((char *name));
  122. struct symstruct *findsym P((char *name));
  123. char *moveup P((unsigned nbytes));
  124. char *ourmalloc P((unsigned nbytes));
  125. void ourfree P((char *cptr));
  126. char *readstring P((void));
  127. void release P((char *cptr));
  128. int memory_used P((void));
  129. char *stralloc P((char *s));
  130. /* typeconvert.c */
  131. u2_pt c2u2 P((char *buf));
  132. u4_t c4u4 P((char *buf));
  133. u2_pt cnu2 P((char *buf, unsigned count));
  134. u4_t cnu4 P((char *buf, unsigned count));
  135. void u2c2 P((char *buf, u2_pt offset));
  136. void u4c4 P((char *buf, u4_t offset));
  137. void u2cn P((char *buf, u2_pt offset, unsigned count));
  138. void u4cn P((char *buf, u4_t offset, unsigned count));
  139. bool_pt typeconv_init P((bool_pt big_endian, bool_pt long_big_endian));
  140. /* writebin.c */
  141. void writebin P((char *outfilename, bool_pt argsepid, bool_pt argbits32,
  142. bool_pt argstripflag, bool_pt arguzp));
  143. void write_dosemu P((char *outfilename, bool_pt argsepid, bool_pt argbits32,
  144. bool_pt argstripflag, bool_pt arguzp));
  145. /* write_elks.c */
  146. void write_elks P((char *outfilename, bool_pt argsepid, bool_pt argbits32,
  147. bool_pt argstripflag, bool_pt arguzp, bool_pt nsym));
  148. /* linksym.c */
  149. void linksyms P((bool_pt argreloc_output));
  150. /* mkar.c */
  151. void ld86r P((int argc, char ** argv));