home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1971 < prev    next >
Internet Message Format  |  1990-12-28  |  30KB

  1. From: loic@adesign.uucp (Loic Dachary)
  2. Newsgroups: alt.sources
  3. Subject: gas-1.36 patches for COFF generation
  4. Message-ID: <LOIC.90Oct16093447@adesign.uucp>
  5. Date: 16 Oct 90 08:34:47 GMT
  6.  
  7. *** /dev/null    Mon Oct 15 09:51:48 1990
  8. --- coff.c    Mon Oct 15 08:53:16 1990
  9. ***************
  10. *** 0 ****
  11. --- 1,367 ----
  12. + #include "oformat.h"
  13. + #include "as.h"
  14. + #include "md.h"
  15. + #include "struc-symbol.h"
  16. + #include "symbols.h"    
  17. + #include "write.h"
  18. + /* Relocation. */
  19. + /*
  20. +  *        emit_relocations()
  21. +  *
  22. +  * Crawl along a fixS chain. Emit the segment's relocations.
  23. +  */
  24. +     
  25. + void
  26. + emit_relocations (fixP, segment_address_in_file)
  27. + register fixS *    fixP;    /* Fixup chain for this segment. */
  28. + relax_addressT    segment_address_in_file;
  29. + {
  30. +     RELOC            ri;
  31. +     register symbolS *        symbolP;
  32. +     
  33. +     bzero((char *)&ri,sizeof(ri));
  34. +     for ( ;  fixP;  fixP = fixP->fx_next) {
  35. +     if (symbolP = fixP->fx_addsy) {
  36. + #if defined(PROCESSOR_68000)
  37. +         ri.r_type = (fixP->fx_pcrel ? 
  38. +              ( fixP->fx_size == 1 ? R_PCRBYTE :
  39. +               fixP->fx_size == 2 ? R_PCRWORD :
  40. +               R_PCRLONG):
  41. +              ( fixP->fx_size == 1 ? R_RELBYTE :
  42. +               fixP->fx_size == 2 ? R_RELWORD :
  43. +               R_RELLONG));
  44. + #elif defined(PROCESSOR_i386)
  45. +         /* !!!! R_OFF8 & R_DIR16 are a vague guess, completly unested. */
  46. +         ri.r_type = (fixP->fx_pcrel ? 
  47. +              ( fixP->fx_size == 1 ? R_PCRBYTE :
  48. +               fixP->fx_size == 2 ? R_PCRWORD :
  49. +               R_PCRLONG):
  50. +              ( fixP->fx_size == 1 ? R_OFF8 :
  51. +               fixP->fx_size == 2 ? R_DIR16 :
  52. +               R_DIR32));
  53. + #else
  54. +         you lose
  55. + #endif /* PROCESSOR_68000 || PROCESSOR_i386 */
  56. +         ri.r_vaddr = fixP->fx_frag->fr_address + fixP->fx_where;
  57. +         /* If symbol associated to relocation entry is a bss symbol 
  58. +            or undefined symbol just remember the index of the symbol.
  59. +            Otherwise store the index of the symbol describing the 
  60. +            section the symbol belong to. This heuristic speeds up ld.
  61. +            */
  62. +         /* Local symbols can generate relocation information. In case
  63. +            of structure return for instance. But they have no symbol
  64. +            number because they won't be emitted in the final object.
  65. +            In the case where they are in the BSS section, this leads
  66. +            to an incorrect r_symndx.
  67. +            Under bsd the loader do not care if the symbol reference is
  68. +            incorrect. But the SYS V ld complains about this. To avoid
  69. +            this we associate the symbol to the associated section, 
  70. +            *even* if it is the BSS section. */
  71. +         /* If someone can tell me why the other symbols of the bss 
  72. +            section are not associated with the .bss section entry, 
  73. +            I'd be gratefull. I guess that it has to do with the special
  74. +            nature of the .bss section. Or maybe this is because the 
  75. +            bss symbols are declared in the common section and can
  76. +            be resized later. Can it break code some where ? */
  77. +         ri.r_symndx =
  78. +     S_GET_SEGMENT(symbolP) == C_TEXT_SECTION ? dot_text_symbol->sy_number :
  79. +     S_GET_SEGMENT(symbolP) == C_DATA_SECTION ? dot_data_symbol->sy_number :
  80. +            (SF_GET_LOCAL(symbolP) ? dot_bss_symbol->sy_number :
  81. +         symbolP->sy_number); /* bss or undefined */
  82. +         
  83. +         /* md_ri_to_chars((char *) &ri, ri);  /* Last step : write md f */
  84. +         append (&next_object_file_charP,
  85. +             (char *)& ri,
  86. +             (unsigned long)RELSZ);
  87. +     }
  88. +     }
  89. + }
  90. + /* Coff file generation & utilities */
  91. + /* Convert a lvalue to machine dependent data */
  92. + #define MD(s,v)   \
  93. +   md_number_to_chars((char *)&(s)->v,(s)->v, sizeof((s)->v))
  94. + void
  95. + c_header_append(aouthdr, filehdr, where)
  96. + AOUTHDR*    aouthdr;
  97. + FILHDR*        filehdr;
  98. + char**        where;
  99. + {
  100. +     /* Eventually swap bytes for cross compilation for file header */
  101. +     MD(filehdr, f_magic);
  102. +     MD(filehdr, f_nscns);
  103. +     MD(filehdr, f_timdat);
  104. +     MD(filehdr, f_symptr);
  105. +     MD(filehdr, f_nsyms);
  106. +     MD(filehdr, f_opthdr);
  107. +     MD(filehdr, f_flags);
  108. +     append(where, (char *)filehdr, FILHSZ);
  109. +     /* Eventually swap bytes for cross compilation for a.out header */
  110. +     MD(aouthdr, magic);
  111. +     MD(aouthdr, vstamp);
  112. +     MD(aouthdr, tsize);
  113. +     MD(aouthdr, dsize);
  114. +     MD(aouthdr, bsize);
  115. +     MD(aouthdr, entry);
  116. +     MD(aouthdr, text_start);
  117. +     MD(aouthdr, data_start);
  118. +     append(where, (char *)aouthdr, sizeof(struct aouthdr));
  119. + }
  120. + /*
  121. +  * Beware ! If you cross compile to another ENDIAN machine,
  122. +  * the symbol table values will not be valid any more.
  123. +  */
  124. + void
  125. + c_symbol_append(symbolP, where)
  126. + symbolS *    symbolP;
  127. + char**        where;
  128. + {
  129. +     SYMENT            *syment    = &symbolP->sy_symbol;
  130. +     char              numaux    = syment->n_numaux;
  131. +     register AUXENT*        auxP    = &symbolP->sy_auxent;
  132. +     register unsigned short    type     = S_GET_DATA_TYPE(symbolP);
  133. +     MD(syment, n_value);
  134. +     MD(syment, n_scnum);
  135. +     MD(syment, n_type);
  136. +     MD(syment, n_sclass);
  137. +     MD(syment, n_numaux);
  138. +     append(where, (char *)syment, SYMESZ);
  139. +     /* Should do the following : if(.file entry) MD(..)... else
  140. +        if(static entry) MD(..)
  141. +      */
  142. +     if(numaux == 1) {
  143. + #if 0 /* This code has never been tested */
  144. +     /* The most common case, x_sym entry. */
  145. +     if((SF_GET(symbolP) & (SF_FILE | SF_STATICS)) == 0) {
  146. +         MD(auxP, x_sym.x_tagndx);
  147. +         if(ISFCN(type))
  148. +         MD(auxP, x_sym.x_misc.x_fsize);
  149. +         else {
  150. +         MD(auxP, x_sym.x_misc.x_lnno);
  151. +         MD(auxP, x_sym.x_misc.x_size);
  152. +         }
  153. +         if(ISARY(type)) {
  154. +         register int index;
  155. +         for(index = 0; index < DIMNUM; index++)
  156. +             MD(auxP, x_sym.x_fcnary.x_ary.x_dimen[index]);
  157. +         } else {
  158. +         MD(auxP, x_sym.x_fcnary.x_fcn.x_lnnoptr);
  159. +         MD(auxP, x_sym.x_fcnary.x_fcn.x_endndx);
  160. +         }
  161. +         MD(auxP, x_sym.x_tvndx);
  162. +     } else if(SF_GET_FILE(symbolP))    /* .file */
  163. +         ;
  164. +     else if(SF_GET_STATICS(symbolP)) { /* .text, .data, .bss symbols */
  165. +         MD(auxP, x_scn.x_scnlen);
  166. +         MD(auxP, x_scn.x_nreloc);
  167. +         MD(auxP, x_scn.x_nlinno);
  168. +     }
  169. + #endif /* 0 */
  170. +     append(where, (char *)auxP, AUXESZ);
  171. +     } else if(numaux > 0)
  172. +     as_warn("more than one auxent for symbol");
  173. +     
  174. +     return;
  175. + }
  176. + void
  177. + c_section_header_append(header, where)
  178. + SCNHDR*        header;
  179. + char**        where;
  180. + {
  181. +     MD(header, s_paddr);
  182. +     MD(header, s_vaddr);
  183. +     MD(header, s_size);
  184. +     MD(header, s_scnptr);
  185. +     MD(header, s_relptr);
  186. +     MD(header, s_lnnoptr);
  187. +     MD(header, s_nreloc);
  188. +     MD(header, s_nlnno);
  189. +     MD(header, s_flags);
  190. +     append(where, (char *)header, SCNHSZ);
  191. +     return;
  192. + }
  193. + void emit_symbols(symbol_rootP, where)
  194. + symbolS *    symbol_rootP;
  195. + char**        where;
  196. + {
  197. +     symbolS *    symbolP;
  198. +     /*
  199. +      * Emit all symbols left in the symbol chain.
  200. +      */
  201. +     for(symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next) {
  202. +     /* Used to save the offset of the name. It is used to point
  203. +        to the string in memory but must be a file offset. */
  204. +     register char *    temp;
  205. +     temp = S_GET_NAME(symbolP);
  206. +     if (SF_GET_STRING(symbolP)) {
  207. +         S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
  208. +         S_SET_ZEROES(symbolP, 0);
  209. +     } else {
  210. +         memset(symbolP->sy_name, '\0', SYMNMLEN);
  211. +         strncpy(symbolP->sy_name, temp, SYMNMLEN);
  212. +     }
  213. +     SYMBOL_OUTPUT(symbolP, where);
  214. +     S_SET_NAME(symbolP,temp);
  215. +     }
  216. + }
  217. + /* Merge a debug symbol containing debug information into a normal
  218. +    symbol. */
  219. + void
  220. + c_symbol_merge(debug, normal)
  221. + symbolS* debug;
  222. + symbolS* normal;
  223. + {
  224. +     S_SET_DATA_TYPE(normal, S_GET_DATA_TYPE(debug));
  225. +     S_SET_STORAGE_CLASS(normal, S_GET_STORAGE_CLASS(debug));
  226. +     S_SET_NUMBER_AUXILIARY(normal, S_GET_NUMBER_AUXILIARY(debug));
  227. +     /* Move all the auxiliary information */
  228. +     if(S_GET_NUMBER_AUXILIARY(debug))
  229. +     memcpy((char*)&normal->sy_auxent, (char*)&debug->sy_auxent,
  230. +            AUXESZ);
  231. +     /* Move the debug flags. */
  232. +     SF_SET_DEBUG_FIELD(normal, SF_GET_DEBUG_FIELD(debug));
  233. + }
  234. + c_dot_file_symbol(filename)
  235. + char*    filename;
  236. + {
  237. +     symbolS* symbolP;
  238. +     symbolS* ante_lastP;
  239. +     ante_lastP = symbol_lastP;
  240. +     
  241. +     symbolP = symbol_new(".file", SEG_DEBUG, 0,
  242. +                    C_FILE, &zero_address_frag);
  243. +     S_SET_NUMBER_AUXILIARY(symbolP, 1);
  244. +     SA_SET_FILE_FNAME(symbolP, filename);
  245. +     SF_SET_DEBUG(symbolP);
  246. +     /* Make sure that the symbol is first on the symbol chain */
  247. +     if(symbol_rootP != symbolP) {
  248. +     symbol_lastP = ante_lastP;
  249. +     symbol_lastP->sy_next = NULL;
  250. +     symbolP->sy_next = symbol_rootP;
  251. +     symbol_rootP = symbolP;
  252. +     }
  253. + }
  254. + /* 
  255. +  * Build a 'section static' symbol.
  256. +  */
  257. + char* 
  258. + c_section_symbol(name, value, length, nreloc, nlnno)
  259. + char* name;
  260. + long value;
  261. + long length;
  262. + unsigned short nreloc;
  263. + unsigned short nlnno;
  264. + {
  265. +     symbolS*    symbolP;
  266. +     symbolP = symbol_new(name,
  267. +                    (name[1] == 't' ? SEG_TEXT : 
  268. +                 name[1] == 'd' ? SEG_DATA :
  269. +                                      SEG_BSS),
  270. +                    value,
  271. +                    C_STAT,
  272. +                    &zero_address_frag);
  273. +     S_SET_NUMBER_AUXILIARY(symbolP, 1);
  274. +     SA_SET_SCN_SCNLEN(symbolP, length);
  275. +     SA_SET_SCN_NRELOC(symbolP, nreloc);
  276. +     SA_SET_SCN_NLINNO(symbolP, nlnno);
  277. +     SF_SET_STATICS(symbolP);
  278. +     return (char*)symbolP;
  279. + }
  280. + void
  281. + c_section_header(header, name, core_address, size,
  282. +          data_ptr, reloc_ptr, lineno_ptr,
  283. +          reloc_number, lineno_number)
  284. + SCNHDR*            header;
  285. + char*            name;
  286. + long            core_address;
  287. + long            size;
  288. + long            data_ptr;
  289. + long            reloc_ptr;
  290. + long            lineno_ptr;
  291. + long            reloc_number;
  292. + long            lineno_number;
  293. + {
  294. +     strncpy(header->s_name, name, 8);
  295. +     header->s_paddr = header->s_vaddr = core_address;
  296. +     header->s_size = size;
  297. +     header->s_scnptr = data_ptr;
  298. +     header->s_relptr = reloc_ptr;
  299. +     header->s_lnnoptr = lineno_ptr;
  300. +     header->s_nreloc = reloc_number;
  301. +     header->s_nlnno = lineno_number;
  302. +     header->s_flags = STYP_REG | ( name[1] == 't' ? STYP_TEXT :
  303. +                                name[1] == 'd' ? STYP_DATA :
  304. +                    name[1] == 'b' ? STYP_BSS  :
  305. +                    STYP_INFO );
  306. +     return ;
  307. + }
  308. + /* Line number handling */
  309. + int text_lineno_number = 0;
  310. + lineno* lineno_rootP = (lineno*)0;
  311. + lineno* lineno_lastP = (lineno*)0;
  312. + lineno*
  313. + c_line_new(paddr, line_number, frag)
  314. + long paddr;
  315. + unsigned short line_number;
  316. + fragS* frag;
  317. + {
  318. +     lineno* new_line = (lineno*)xmalloc(sizeof(lineno));
  319. +     new_line->line.l_addr.l_paddr = paddr;
  320. +     new_line->line.l_lnno = line_number;
  321. +     new_line->frag = (char*)frag;
  322. +     new_line->next = (lineno*)0;
  323. +     if(lineno_rootP == (lineno*)0)
  324. +     lineno_rootP = new_line;
  325. +     else 
  326. +     lineno_lastP->next = new_line;
  327. +     lineno_lastP = new_line;
  328. + }
  329. + void
  330. + emit_lineno(line, where)
  331. + lineno* line;
  332. + char** where;
  333. + {
  334. +     register LINENO* line_entry;
  335. +     for(;line;line = line->next) {
  336. +     line_entry = &line->line;
  337. +     /* No matter which member of the union we process, they are
  338. +        both long. */
  339. +     MD(line_entry, l_addr.l_paddr);
  340. +     MD(line_entry, l_lnno);
  341. +     append(where, (char *)line_entry, LINESZ);
  342. +     }
  343. +     return ;
  344. + }
  345. *** /dev/null    Mon Oct 15 09:51:48 1990
  346. --- m-i386.h    Mon Oct 15 08:14:18 1990
  347. ***************
  348. *** 0 ****
  349. --- 1,10 ----
  350. + /* Machine specific defines for the SCO Unix V.3.2 ODT */
  351. + #define scounix
  352. + #define PROCESSOR_i386
  353. + /* Return true if s (a non null string pointer), points to a local variable
  354. +    name. */
  355. + #define S_LOCAL_NAME(s)  (S_GET_NAME(s)[0] == '.' && S_GET_NAME(s)[1] == 'L')
  356. + /* Compiler does not generate symbol names with a leading underscore. */
  357. + #define STRIP_UNDERSCORE 0
  358. *** /dev/null    Mon Oct 15 09:51:48 1990
  359. --- stack.h    Wed Aug 29 13:17:30 1990
  360. ***************
  361. *** 0 ****
  362. --- 1,13 ----
  363. + typedef struct {
  364. +     unsigned long chunk_size;
  365. +     unsigned long element_size;
  366. +     unsigned long size;
  367. +     char*      data;
  368. +     unsigned long pointer;
  369. + } stack;
  370. + extern stack* stack_init();
  371. + extern void stack_delete();
  372. + extern char* stack_push();
  373. + extern char* stack_pop();
  374. + extern char* stack_top();
  375. *** as.c    Tue Mar 20 19:33:57 1990
  376. --- /lasvegas/spare/usenet/port/gas-1.36/as.c    Mon Oct 15 09:24:35 1990
  377. ***************
  378. *** 35,40 ****
  379. --- 35,41 ----
  380.   #include <signal.h>
  381.   
  382.   #define COMMON
  383. + #include "oformat.h"
  384.   #include "as.h"
  385.   #include "struc-symbol.h"
  386.   #include "write.h"
  387. *** as.h    Wed Mar  1 23:49:37 1989
  388. --- /lasvegas/spare/usenet/port/gas-1.36/as.h    Sat Oct 13 09:29:35 1990
  389. ***************
  390. *** 158,166 ****
  391.                   /* Invented so we don't crash printing */
  392.                   /* error message involving weird segment. */
  393.       SEG_BIG,            /* Bigger than 32 bits constant. */
  394. !     SEG_DIFFERENCE        /* Mythical Segment: absolute difference. */
  395.   }        segT;
  396.   #define SEG_MAXIMUM_ORDINAL (SEG_DIFFERENCE)
  397.   
  398.   typedef unsigned char    subsegT;
  399.   
  400. --- 158,175 ----
  401.                   /* Invented so we don't crash printing */
  402.                   /* error message involving weird segment. */
  403.       SEG_BIG,            /* Bigger than 32 bits constant. */
  404. !     SEG_DIFFERENCE,        /* Mythical Segment: absolute difference. */
  405. ! #ifdef coff
  406. !     SEG_DEBUG,        /* Debug segment */
  407. !     SEG_NTV,        /* Transfert vector preload segment */
  408. !     SEG_PTV,        /* Transfert vector postload segment */
  409. ! #endif /* coff */
  410.   }        segT;
  411. + #ifdef coff
  412. + #define SEG_MAXIMUM_ORDINAL (SEG_PTV)
  413. + #else /* coff */
  414.   #define SEG_MAXIMUM_ORDINAL (SEG_DIFFERENCE)
  415. + #endif /* coff */
  416.   
  417.   typedef unsigned char    subsegT;
  418.   
  419. ***************
  420. *** 176,181 ****
  421. --- 185,207 ----
  422.   extern char    *seg_name[];
  423.   extern int    seg_N_TYPE[];
  424.   extern segT    N_TYPE_seg[];
  425. + #ifdef coff
  426. + #define        segment_name(v)    (seg_name[(v)])
  427. + /* Machine independent -> machine dependent */
  428. + #define        seg_SEG(v)    (seg_N_TYPE[(v)])
  429. + /*
  430. +  * +4 shift the value of the mnemonics from -4, -3, -2, -1, 0, 1, 2, 3
  431. +  * to 0, 1, 2, 3, 4, 5, 6, 7
  432. +  */
  433. + /* Machine dependent -> machine independent */
  434. + #define        SEG_seg(v)    (N_TYPE_seg[(v) + 4])
  435. + #else /* coff */
  436. + #define        segment_name(v)    (seg_name[(v)])
  437. + /* Machine independent -> machine dependent */
  438. + #define        seg_SEG(v)    (seg_N_TYPE[(v)])
  439. + /* Machine dependent -> machine independent */
  440. + #define        SEG_seg(v)    (N_TYPE_seg[(v)])
  441. + #endif /* coff */
  442.   void    subsegs_begin();
  443.   void    subseg_change();
  444.   void    subseg_new();
  445. *** expr.c    Fri Apr  6 17:51:21 1990
  446. --- /lasvegas/spare/usenet/port/gas-1.36/expr.c    Wed Sep 12 09:28:48 1990
  447. ***************
  448. *** 25,30 ****
  449. --- 25,31 ----
  450.    */
  451.   
  452.   #include <ctype.h>
  453. + #include "oformat.h"
  454.   #include "as.h"
  455.   #include "flonum.h"
  456.   #include "read.h"
  457. ***************
  458. *** 84,90 ****
  459.   {
  460.     register char        c;
  461.     register char *name;    /* points to name of symbol */
  462. !   register struct symbol *    symbolP; /* Points to symbol */
  463.   
  464.     extern  char hex_value[];    /* In hex_value.c */
  465.     char    *local_label_name();
  466. --- 85,91 ----
  467.   {
  468.     register char        c;
  469.     register char *name;    /* points to name of symbol */
  470. !   register symbolS *    symbolP; /* Points to symbol */
  471.   
  472.     extern  char hex_value[];    /* In hex_value.c */
  473.     char    *local_label_name();
  474. ***************
  475. *** 249,263 ****
  476.                  */
  477.                 name = local_label_name ((int)number, 0);
  478.                 if ( (symbolP = symbol_table_lookup(name)) /* seen before */
  479. !               && (symbolP -> sy_type & N_TYPE) != N_UNDF /* symbol is defined: OK */
  480. !               )
  481.               {        /* Expected path: symbol defined. */
  482.                 /* Local labels are never absolute. Don't waste time checking absoluteness. */
  483. !               know(   (symbolP -> sy_type & N_TYPE) == N_DATA
  484. !                    || (symbolP -> sy_type & N_TYPE) == N_TEXT );
  485.                 expressionP -> X_add_symbol = symbolP;
  486.                 expressionP -> X_add_number = 0;
  487. !               expressionP -> X_seg          = N_TYPE_seg [symbolP -> sy_type];
  488.               }
  489.                 else
  490.               {        /* Either not seen or not defined. */
  491. --- 250,262 ----
  492.                  */
  493.                 name = local_label_name ((int)number, 0);
  494.                 if ( (symbolP = symbol_table_lookup(name)) /* seen before */
  495. !               && (S_IS_DEFINED(symbolP)))
  496.               {        /* Expected path: symbol defined. */
  497.                 /* Local labels are never absolute. Don't waste time checking absoluteness. */
  498. !               know((S_IS_DATA(symbolP)) || S_IS_TEXT(symbolP));
  499.                 expressionP -> X_add_symbol = symbolP;
  500.                 expressionP -> X_add_number = 0;
  501. !               expressionP -> X_seg = SEG_seg(S_GET_SEGMENT(symbolP));
  502.               }
  503.                 else
  504.               {        /* Either not seen or not defined. */
  505. ***************
  506. *** 288,300 ****
  507.                 if ( symbolP = symbol_table_lookup( name ))
  508.                   {
  509.                     /* We have no need to check symbol properties. */
  510. !                   know(   (symbolP -> sy_type & N_TYPE) == N_UNDF
  511. !                    || (symbolP -> sy_type & N_TYPE) == N_DATA
  512. !                    || (symbolP -> sy_type & N_TYPE) == N_TEXT);
  513.                   }
  514.                 else
  515.                   {
  516. !                   symbolP = symbol_new (name, N_UNDF, 0,0,0, & zero_address_frag);
  517.                     symbol_table_insert (symbolP);
  518.                   }
  519.                 expressionP -> X_add_symbol      = symbolP;
  520. --- 287,305 ----
  521.                 if ( symbolP = symbol_table_lookup( name ))
  522.                   {
  523.                     /* We have no need to check symbol properties. */
  524. !                   know(!S_IS_DEFINED(symbolP) ||
  525. !                    S_IS_DATA(symbolP) || S_IS_TEXT(symbolP));
  526.                   }
  527.                 else
  528.                   {
  529. ! #ifdef coff
  530. !                 symbolP = symbol_new(name, SEG_UNKNOWN,
  531. !                              0, 0,
  532. !                               &zero_address_frag);
  533. ! #else /* coff */
  534. !                   symbolP = symbol_new (name, N_UNDF, 0,0,0, 
  535. !                             & zero_address_frag);
  536. ! #endif /* coff */
  537.                     symbol_table_insert (symbolP);
  538.                   }
  539.                 expressionP -> X_add_symbol      = symbolP;
  540. ***************
  541. *** 357,368 ****
  542.          JF:  '.' is pseudo symbol with value of current location in current
  543.          segment. . .
  544.        */
  545.       symbolP = symbol_new("L0\001",
  546. !              (unsigned char)(seg_N_TYPE[(int)now_seg]),
  547.                0,
  548.                0,
  549.                (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
  550.                frag_now);
  551.       expressionP->X_add_number=0;
  552.       expressionP->X_add_symbol=symbolP;
  553.       expressionP->X_seg = now_seg;
  554. --- 362,378 ----
  555.          JF:  '.' is pseudo symbol with value of current location in current
  556.          segment. . .
  557.        */
  558. + #ifdef coff
  559. +     symbolP = symbol_new("L0\001", now_seg, (valueT)(obstack_next_free(&frags)-
  560. +                  frag_now->fr_literal), 0, frag_now);
  561. + #else /* coff */
  562.       symbolP = symbol_new("L0\001",
  563. !              (unsigned char)(seg_SEG((int)now_seg)),
  564.                0,
  565.                0,
  566.                (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
  567.                frag_now);
  568. + #endif /* coff */
  569.       expressionP->X_add_number=0;
  570.       expressionP->X_add_symbol=symbolP;
  571.       expressionP->X_seg = now_seg;
  572. ***************
  573. *** 383,389 ****
  574.              */
  575.             register segT        seg;
  576.   
  577. !           seg = N_TYPE_seg [(int) symbolP -> sy_type & N_TYPE];
  578.             if ((expressionP -> X_seg = seg) == SEG_ABSOLUTE )
  579.           {
  580.             expressionP -> X_add_number = symbolP -> sy_value;
  581. --- 393,399 ----
  582.              */
  583.             register segT        seg;
  584.   
  585. !           seg = SEG_seg((int)S_GET_SEGMENT(symbolP));
  586.             if ((expressionP -> X_seg = seg) == SEG_ABSOLUTE )
  587.           {
  588.             expressionP -> X_add_number = symbolP -> sy_value;
  589. ***************
  590. *** 398,404 ****
  591. --- 408,418 ----
  592.       {
  593.         expressionP -> X_add_symbol
  594.           = symbolP
  595. + #ifdef coff
  596. +         = symbol_new (name, SEG_UNKNOWN, 0, 0, &zero_address_frag);
  597. + #else /* coff */
  598.           = symbol_new (name, N_UNDF, 0,0,0, & zero_address_frag);
  599. + #endif /* coff */
  600.   
  601.         expressionP -> X_add_number  = 0;
  602.         expressionP -> X_seg         = SEG_UNKNOWN;
  603. ***************
  604. *** 553,578 ****
  605.   
  606.   static segT
  607.   expr_part (symbol_1_PP, symbol_2_P)
  608. !      struct symbol **    symbol_1_PP;
  609. !      struct symbol *    symbol_2_P;
  610.   {
  611.     segT            return_value;
  612.   
  613.     know(    (* symbol_1_PP)                   == NULL
  614. !        || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_TEXT
  615. !        || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_DATA
  616. !        || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_BSS
  617. !        || ((* symbol_1_PP) -> sy_type & N_TYPE) == N_UNDF
  618.          );
  619.     know(      symbol_2_P             == NULL
  620. !        ||    (symbol_2_P   -> sy_type & N_TYPE) == N_TEXT
  621. !        ||    (symbol_2_P   -> sy_type & N_TYPE) == N_DATA
  622. !        ||    (symbol_2_P   -> sy_type & N_TYPE) == N_BSS
  623. !        ||    (symbol_2_P   -> sy_type & N_TYPE) == N_UNDF
  624.          );
  625.     if (* symbol_1_PP)
  626.       {
  627. !       if (((* symbol_1_PP) -> sy_type & N_TYPE) == N_UNDF)
  628.       {
  629.         if (symbol_2_P)
  630.           {
  631. --- 567,592 ----
  632.   
  633.   static segT
  634.   expr_part (symbol_1_PP, symbol_2_P)
  635. !      symbolS **    symbol_1_PP;
  636. !      symbolS *    symbol_2_P;
  637.   {
  638.     segT            return_value;
  639.   
  640.     know(    (* symbol_1_PP)                   == NULL
  641. !        || (S_IS_TEXT(* symbol_1_PP))
  642. !        || (S_IS_DATA(* symbol_1_PP))
  643. !        || (S_IS_BSS(* symbol_1_PP))
  644. !        || (!S_IS_DEFINED(* symbol_1_PP))
  645.          );
  646.     know(      symbol_2_P             == NULL
  647. !        || (S_IS_TEXT(symbol_2_P))
  648. !        || (S_IS_DATA(symbol_2_P))
  649. !        || (S_IS_BSS(symbol_2_P))
  650. !        || (!S_IS_DEFINED(symbol_2_P))
  651.          );
  652.     if (* symbol_1_PP)
  653.       {
  654. !       if (!S_IS_DEFINED(* symbol_1_PP))
  655.       {
  656.         if (symbol_2_P)
  657.           {
  658. ***************
  659. *** 581,587 ****
  660.           }
  661.         else
  662.           {
  663. !           know( ((* symbol_1_PP) -> sy_type & N_TYPE) == N_UNDF)
  664.             return_value = SEG_UNKNOWN;
  665.           }
  666.       }
  667. --- 595,601 ----
  668.           }
  669.         else
  670.           {
  671. !           know(!S_IS_DEFINED(* symbol_1_PP));
  672.             return_value = SEG_UNKNOWN;
  673.           }
  674.       }
  675. ***************
  676. *** 589,595 ****
  677.       {
  678.         if (symbol_2_P)
  679.           {
  680. !           if ((symbol_2_P -> sy_type & N_TYPE) == N_UNDF)
  681.           {
  682.             * symbol_1_PP = NULL;
  683.             return_value = SEG_PASS1;
  684. --- 603,609 ----
  685.       {
  686.         if (symbol_2_P)
  687.           {
  688. !           if (!S_IS_DEFINED(symbol_2_P))
  689.           {
  690.             * symbol_1_PP = NULL;
  691.             return_value = SEG_PASS1;
  692. ***************
  693. *** 598,604 ****
  694.           {
  695.             /* {seg1} - {seg2} */
  696.             as_warn( "Expression too complex, 2 symbols forgotten: \"%s\" \"%s\"",
  697. !               (* symbol_1_PP) -> sy_name, symbol_2_P -> sy_name );
  698.             * symbol_1_PP = NULL;
  699.             return_value = SEG_ABSOLUTE;
  700.           }
  701. --- 612,618 ----
  702.           {
  703.             /* {seg1} - {seg2} */
  704.             as_warn( "Expression too complex, 2 symbols forgotten: \"%s\" \"%s\"",
  705. !               S_GET_NAME(* symbol_1_PP), S_GET_NAME(symbol_2_P));
  706.             * symbol_1_PP = NULL;
  707.             return_value = SEG_ABSOLUTE;
  708.           }
  709. ***************
  710. *** 605,611 ****
  711.           }
  712.         else
  713.           {
  714. !           return_value = N_TYPE_seg [(* symbol_1_PP) -> sy_type & N_TYPE];
  715.           }
  716.       }
  717.       }
  718. --- 619,625 ----
  719.           }
  720.         else
  721.           {
  722. !           return_value = SEG_seg(S_GET_SEGMENT(* symbol_1_PP));
  723.           }
  724.       }
  725.       }
  726. ***************
  727. *** 614,620 ****
  728.         if (symbol_2_P)
  729.       {
  730.         * symbol_1_PP = symbol_2_P;
  731. !       return_value = N_TYPE_seg [(symbol_2_P) -> sy_type & N_TYPE];
  732.       }
  733.         else
  734.       {
  735. --- 628,634 ----
  736.         if (symbol_2_P)
  737.       {
  738.         * symbol_1_PP = symbol_2_P;
  739. !       return_value = SEG_seg(S_GET_SEGMENT(symbol_2_P));
  740.       }
  741.         else
  742.       {
  743. ***************
  744. *** 630,636 ****
  745.          || return_value == SEG_PASS1            
  746.          );
  747.     know(   (* symbol_1_PP) == NULL                
  748. !        || ((* symbol_1_PP) -> sy_type & N_TYPE) == seg_N_TYPE [(int) return_value] );
  749.     return (return_value);
  750.   }                /* expr_part() */
  751.   
  752. --- 644,650 ----
  753.          || return_value == SEG_PASS1            
  754.          );
  755.     know(   (* symbol_1_PP) == NULL                
  756. !        || (S_GET_SEGMENT(* symbol_1_PP) == seg_SEG((int) return_value) ));
  757.     return (return_value);
  758.   }                /* expr_part() */
  759.   
  760. ***************
  761. *** 792,798 ****
  762.              * does not cause any further inaccuracy.
  763.              */
  764.   
  765. !           register struct symbol *    symbolP;
  766.   
  767.             right . X_add_number      = - right . X_add_number;
  768.             symbolP                   = right . X_add_symbol;
  769. --- 806,812 ----
  770.              * does not cause any further inaccuracy.
  771.              */
  772.   
  773. !           register symbolS *    symbolP;
  774.   
  775.             right . X_add_number      = - right . X_add_number;
  776.             symbolP                   = right . X_add_symbol;
  777. ***************
  778. *** 858,865 ****
  779.                 know( resultP -> X_add_symbol      );
  780.                 know( resultP -> X_subtract_symbol );
  781.                 as_warn("Expression too complex: forgetting %s - %s",
  782. !                   resultP -> X_add_symbol      -> sy_name,
  783. !                   resultP -> X_subtract_symbol -> sy_name);
  784.                 resultP -> X_seg = SEG_ABSOLUTE;
  785.                 /* Clean_up_expression() will do the rest. */
  786.               }
  787. --- 872,879 ----
  788.                 know( resultP -> X_add_symbol      );
  789.                 know( resultP -> X_subtract_symbol );
  790.                 as_warn("Expression too complex: forgetting %s - %s",
  791. !                   S_GET_NAME(resultP -> X_add_symbol),
  792. !                   S_GET_NAME(resultP -> X_subtract_symbol));
  793.                 resultP -> X_seg = SEG_ABSOLUTE;
  794.                 /* Clean_up_expression() will do the rest. */
  795.               }
  796. *** frags.c    Thu Aug 17 20:53:21 1989
  797. --- /lasvegas/spare/usenet/port/gas-1.36/frags.c    Wed Sep 12 09:28:49 1990
  798. ***************
  799. *** 17,22 ****
  800. --- 17,23 ----
  801.   along with GAS; see the file COPYING.  If not, write to
  802.   the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  803.   
  804. + #include "oformat.h"
  805.   #include "as.h"
  806.   #include "subsegs.h"
  807.   #include "obstack.h"
  808. *** hash.c    Wed Mar  1 23:49:18 1989
  809. --- /lasvegas/spare/usenet/port/gas-1.36/hash.c    Wed Sep 12 09:28:45 1990
  810. ***************
  811. *** 129,134 ****
  812. --- 129,137 ----
  813.   #define min(a, b)    ((a) < (b) ? (a) : (b))
  814.   
  815.   #include "hash.h"
  816. + #define error    as_fatal
  817.   char *xmalloc();
  818.   
  819.   #define DELETED     ((char *)1)    /* guarenteed invalid address */
  820. *** i386.c    Wed May 16 16:29:04 1990
  821. --- /lasvegas/spare/usenet/port/gas-1.36/i386.c    Sat Oct 13 11:34:21 1990
  822. ***************
  823. *** 37,42 ****
  824. --- 37,43 ----
  825.   #define index strchr
  826.   #endif
  827.   
  828. + #include "oformat.h"
  829.   #include "as.h"
  830.   #include "read.h"
  831.   #include "flonum.h"
  832. ***************
  833. *** 168,176 ****
  834.       { "tfloat",    float_cons,    'x' },
  835.       { "value",      cons,           2 },
  836.       { "ident",      dummy,          0   }, /* ignore these directives */
  837. !     { "def",        dummy,          0   },
  838.       { "version",    dummy,          0   },
  839. !     { "ln",    dummy,          0   },
  840.       { 0, 0, 0 }
  841.   };
  842.   
  843. --- 169,177 ----
  844.       { "tfloat",    float_cons,    'x' },
  845.       { "value",      cons,           2 },
  846.       { "ident",      dummy,          0   }, /* ignore these directives */
  847. ! /*    { "def",        dummy,          0   },*/
  848.       { "version",    dummy,          0   },
  849. ! /*    { "ln",    dummy,          0   },*/
  850.       { 0, 0, 0 }
  851.   };
  852.   
  853. ***************
  854. *** 372,391 ****
  855.     }
  856.   }
  857.   
  858. ! #define SYMBOL_TYPE(t) \
  859. !   (((t&N_TYPE) == N_UNDF) ? "UNDEFINED" : \
  860. !    (((t&N_TYPE) == N_ABS) ? "ABSOLUTE" : \
  861. !     (((t&N_TYPE) == N_TEXT) ? "TEXT" : \
  862. !      (((t&N_TYPE) == N_DATA) ? "DATA" : \
  863. !       (((t&N_TYPE) == N_BSS) ? "BSS" : "Bad n_type!")))))
  864.   
  865.   static void ps (s)
  866.        symbolS *s;
  867.   {
  868.     fprintf (stdout, "%s type %s%s",
  869. !        s->sy_nlist.n_un.n_name,
  870. !        (s->sy_nlist.n_type&N_EXT) ? "EXTERNAL " : "",
  871. !        SYMBOL_TYPE (s->sy_nlist.n_type));
  872.   }
  873.   
  874.   struct type_name {
  875. --- 373,387 ----
  876.     }
  877.   }
  878.   
  879. ! #define SYMBOL_TYPE(t) segment_name(SEG_seg(t))
  880.   
  881.   static void ps (s)
  882.        symbolS *s;
  883.   {
  884.     fprintf (stdout, "%s type %s%s",
  885. !        S_GET_NAME(s),
  886. !        S_IS_EXTERNAL(s) ? "EXTERNAL " : "",
  887. !        SYMBOL_TYPE(S_GET_SEGMENT(s))
  888.   }
  889.   
  890.   struct type_name {
  891. ***************
  892. *** 1543,1549 ****
  893.   int
  894.   md_estimate_size_before_relax (fragP, segment_type)
  895.        register fragS *    fragP;
  896. !      register int    segment_type; /* N_DATA or N_TEXT. */
  897.   {
  898.     register uchar *    opcode;
  899.     register int        old_fr_fix;
  900. --- 1539,1545 ----
  901.   int
  902.   md_estimate_size_before_relax (fragP, segment_type)
  903.        register fragS *    fragP;
  904. !      register int    segment_type; /* DATA or TEXT. */
  905.   {
  906.     register uchar *    opcode;
  907.     register int        old_fr_fix;
  908. ***************
  909. *** 1552,1558 ****
  910.     opcode = (uchar *) fragP -> fr_opcode;
  911.     /* We've already got fragP->fr_subtype right;  all we have to do is check
  912.        for un-relaxable symbols. */
  913. !   if ((fragP -> fr_symbol -> sy_type & N_TYPE) != segment_type) {
  914.       /* symbol is undefined in this segment */
  915.       switch (opcode[0]) {
  916.       case JUMP_PC_RELATIVE:    /* make jmp (0xeb) a dword displacement jump */
  917. --- 1548,1554 ----
  918.     opcode = (uchar *) fragP -> fr_opcode;
  919.     /* We've already got fragP->fr_subtype right;  all we have to do is check
  920.        for un-relaxable symbols. */
  921. !   if (S_GET_SEGMENT(fragP->fr_symbol) != segment_type) {
  922.       /* symbol is undefined in this segment */
  923.       switch (opcode[0]) {
  924.       case JUMP_PC_RELATIVE:    /* make jmp (0xeb) a dword displacement jump */
  925. ***************
  926. *** 1605,1611 ****
  927.     opcode = (uchar *) fragP -> fr_opcode;
  928.   
  929.     /* Address we want to reach in file space. */
  930. !   target_address = fragP->fr_symbol->sy_value + fragP->fr_offset;
  931.   
  932.     /* Address opcode resides at in file space. */
  933.     opcode_address = fragP->fr_address + fragP->fr_fix;
  934. --- 1601,1607 ----
  935.     opcode = (uchar *) fragP -> fr_opcode;
  936.   
  937.     /* Address we want to reach in file space. */
  938. !   target_address = S_GET_VALUE(fragP->fr_symbol) + fragP->fr_offset;
  939.   
  940.     /* Address opcode resides at in file space. */
  941.     opcode_address = fragP->fr_address + fragP->fr_fix;
  942. ***************
  943. *** 1684,1690 ****
  944.     long offset;
  945.   
  946.     if (flagseen['m']) {
  947. !     offset = to_addr - to_symbol->sy_value;
  948.       md_number_to_chars (ptr, 0xe9, 1); /* opcode for long jmp */
  949.       md_number_to_chars (ptr + 1, offset, 4);
  950.       fix_new (frag, (ptr+1) - frag->fr_literal, 4,
  951. --- 1680,1686 ----
  952.     long offset;
  953.   
  954.     if (flagseen['m']) {
  955. !     offset = to_addr - S_GET_VALUE(to_symbol);
  956.       md_number_to_chars (ptr, 0xe9, 1); /* opcode for long jmp */
  957.       md_number_to_chars (ptr + 1, offset, 4);
  958.       fix_new (frag, (ptr+1) - frag->fr_literal, 4,
  959. ***************
  960. *** 1833,1838 ****
  961. --- 1829,1837 ----
  962.     return retval;
  963.   }
  964.   
  965. + /* Not needed for coff since relocation structure does not 
  966. +    contain bitfields. */
  967. + #ifdef aout
  968.   void md_ri_to_chars(ri_p, ri)
  969.        struct relocation_info *ri_p, ri;
  970.   {
  971. ***************
  972. *** 1849,1854 ****
  973. --- 1848,1854 ----
  974.     /* now put it back where you found it */
  975.     bcopy (the_bytes, (char *)ri_p, sizeof(struct relocation_info));
  976.   }
  977. + #endif /* aout */
  978.   
  979.   
  980.   #define MAX_LITTLENUMS 6
  981. --
  982. Loic Dachary     loic@adesign.uucp or loic@afp.uucp 
  983. Voice        +33 1 40 35 20 20
  984.