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

  1. From: loic@adesign.uucp (Loic Dachary)
  2. Newsgroups: alt.sources
  3. Subject: gas-1.36 patches for COFF generation
  4. Message-ID: <LOIC.90Oct16093626@adesign.uucp>
  5. Date: 16 Oct 90 08:36:26 GMT
  6.  
  7. *** write.c    Thu Apr 12 17:23:42 1990
  8. --- /lasvegas/spare/usenet/port/gas-1.36/write.c    Mon Oct 15 12:35:38 1990
  9. ***************
  10. *** 30,35 ****
  11. --- 30,36 ----
  12.      trouble.
  13.    */
  14.   
  15. + #include "oformat.h"
  16.   #include "as.h"
  17.   #include "md.h"
  18.   #include "subsegs.h"
  19. ***************
  20. *** 37,64 ****
  21.   #include "struc-symbol.h"
  22.   #include "write.h"
  23.   #include "symbols.h"
  24.   
  25.   #ifdef SPARC
  26.   #include "sparc.h"
  27.   #endif
  28.   
  29. - void    append();
  30.   #ifdef hpux
  31.   #define EXEC_MACHINE_TYPE HP9000S200_ID
  32.   #endif
  33.   
  34. ! /*
  35. !  * In: length of relocation (or of address) in chars: 1, 2 or 4.
  36. !  * Out: GNU LD relocation length code: 0, 1, or 2.
  37. !  */
  38. ! static unsigned char
  39. ! nbytes_r_length [] = {
  40. !   42, 0, 1, 42, 2
  41. !   };
  42.   
  43.   static struct frag *    text_frag_root;
  44.   static struct frag *    data_frag_root;
  45. --- 38,59 ----
  46.   #include "struc-symbol.h"
  47.   #include "write.h"
  48.   #include "symbols.h"
  49. + #include "append.h"
  50. + #ifdef coff
  51. + #include <sys/types.h>
  52. + #endif /* coff */
  53.   
  54.   #ifdef SPARC
  55.   #include "sparc.h"
  56.   #endif
  57.   
  58.   #ifdef hpux
  59.   #define EXEC_MACHINE_TYPE HP9000S200_ID
  60.   #endif
  61.   
  62. ! #ifdef coff
  63. ! extern time_t        time();
  64. ! #endif /* coff */
  65.   
  66.   static struct frag *    text_frag_root;
  67.   static struct frag *    data_frag_root;
  68. ***************
  69. *** 66,84 ****
  70.   static struct frag *    text_last_frag;    /* Last frag in segment. */
  71.   static struct frag *    data_last_frag;    /* Last frag in segment. */
  72.   
  73. ! static struct exec    the_exec;
  74.   
  75.   static long int string_byte_count;
  76.   
  77.   static char *        the_object_file;
  78.   
  79. - #ifndef SPARC
  80. - static
  81. - #endif
  82.   char *        next_object_file_charP;    /* Tracks object file bytes. */
  83.   
  84. - static long int        size_of_the_object_file; /* # bytes in object file. */
  85.   /* static long int        length; JF unused */    /* String length, including trailing '\0'. */
  86.   
  87.   static void    relax_segment();
  88. --- 61,74 ----
  89.   static struct frag *    text_last_frag;    /* Last frag in segment. */
  90.   static struct frag *    data_last_frag;    /* Last frag in segment. */
  91.   
  92. ! static object_headers    headers;
  93.   
  94.   static long int string_byte_count;
  95.   
  96.   static char *        the_object_file;
  97.   
  98.   char *        next_object_file_charP;    /* Tracks object file bytes. */
  99.   
  100.   /* static long int        length; JF unused */    /* String length, including trailing '\0'. */
  101.   
  102.   static void    relax_segment();
  103. ***************
  104. *** 85,93 ****
  105.   void        emit_segment();
  106.   static relax_addressT    relax_align();
  107.   static long int    fixup_segment();
  108. - #ifndef SPARC
  109. - static void        emit_relocations();
  110. - #endif
  111.    /*
  112.    *            fix_new()
  113.    *
  114. --- 75,80 ----
  115. ***************
  116. *** 144,150 ****
  117.     register struct frchain *    next_frchainP;
  118.     register fragS * *        prev_fragPP;
  119.     register char *        name;
  120. !   register symbolS *        symbolP;
  121.     register symbolS **        symbolPP;
  122.     /* register fixS *        fixP; JF unused */
  123.     unsigned
  124. --- 131,137 ----
  125.     register struct frchain *    next_frchainP;
  126.     register fragS * *        prev_fragPP;
  127.     register char *        name;
  128. !   symbolS *            symbolP;
  129.     register symbolS **        symbolPP;
  130.     /* register fixS *        fixP; JF unused */
  131.     unsigned
  132. ***************
  133. *** 153,158 ****
  134. --- 140,152 ----
  135.       syms_siz,
  136.       tr_siz,
  137.       dr_siz;
  138. + #ifdef coff
  139. +   SCNHDR            text_section_header;
  140. +   SCNHDR            data_section_header;
  141. +   SCNHDR            bss_section_header;
  142. +   symbolS*            last_functionP = (symbolS*)0;
  143. +   symbolS*            last_tagP;
  144. + #endif /* coff */
  145.     void output_file_create();
  146.     void output_file_append();
  147.     void output_file_close();
  148. ***************
  149. *** 160,168 ****
  150. --- 154,168 ----
  151.     void gdb_emit();
  152.     void gdb_end();
  153.   #endif
  154. +   long int object_file_size;
  155.     extern long omagic;        /* JF magic # to write out.  Is different for
  156.                      Suns and Vaxen and other boxes */
  157.   
  158. + #ifdef coff
  159. +   /* Initialize the stack used to keep track of the matching .bb .be */
  160. +   stack* block_stack = stack_init(512, sizeof(symbolS*));
  161. + #endif /* coff */
  162.   #ifdef    VMS
  163.     /*
  164.      *    Under VMS we try to be compatible with VAX-11 "C".  Thus, we
  165. ***************
  166. *** 261,273 ****
  167.      */
  168.   
  169.     know(   text_last_frag -> fr_type   == rs_fill && text_last_frag -> fr_offset == 0 );
  170. !   text_siz=text_last_frag->fr_address;
  171.   #ifdef SPARC
  172. !   text_siz= (text_siz+7)&(~7);
  173. !   text_last_frag->fr_address=text_siz;
  174.   #endif
  175. -   md_number_to_chars((char *)&the_exec.a_text,text_siz, sizeof(the_exec.a_text));
  176. -   /* the_exec . a_text = text_last_frag -> fr_address; */
  177.   
  178.     /*
  179.      * Join the 2 segments into 1 huge segment.
  180. --- 261,272 ----
  181.      */
  182.   
  183.     know(   text_last_frag -> fr_type   == rs_fill && text_last_frag -> fr_offset == 0 );
  184. !   H_SET_TEXT_SIZE(&headers,text_last_frag->fr_address);
  185.   #ifdef SPARC
  186. !   H_SET_TEXT_SIZE(&headers,H_GET_TEXT_SIZE(&headers) + 
  187. !                    (H_GET_TEXT_SIZE(&headers)+7)&(~7));
  188. !   text_last_frag->fr_address=H_GET_TEXT_SIZE(&headers);
  189.   #endif
  190.   
  191.     /*
  192.      * Join the 2 segments into 1 huge segment.
  193. ***************
  194. *** 281,294 ****
  195.         register relax_addressT    slide;
  196.   
  197.         know(   text_last_frag -> fr_type   == rs_fill && text_last_frag -> fr_offset == 0 );
  198. !       data_siz=data_last_frag->fr_address;
  199.   #ifdef SPARC
  200. !       data_siz += (8 - (data_siz % 8)) % 8;
  201. !       data_last_frag->fr_address = data_siz;
  202.   #endif
  203. !       md_number_to_chars((char *)&the_exec.a_data,data_siz,sizeof(the_exec.a_data));
  204. !       /* the_exec . a_data = data_last_frag -> fr_address; */
  205. !       slide = text_siz; /* Address in file of the data segment. */
  206.         for (fragP = data_frag_root;
  207.          fragP;
  208.          fragP = fragP -> fr_next)
  209. --- 280,292 ----
  210.         register relax_addressT    slide;
  211.   
  212.         know(   text_last_frag -> fr_type   == rs_fill && text_last_frag -> fr_offset == 0 );
  213. !       H_SET_DATA_SIZE(&headers,data_last_frag->fr_address);
  214.   #ifdef SPARC
  215. !       H_SET_DATA_SIZE(&headers,(H_GET_DATA_SIZE(&headers) + 
  216. !                 (8 - (H_GET_DATA_SIZE(&headers) % 8)) % 8));
  217. !       data_last_frag->fr_address = H_GET_DATA_SIZE(&headers);
  218.   #endif
  219. !       slide = H_GET_TEXT_SIZE(&headers); /* & in file of the data segment. */
  220.         for (fragP = data_frag_root;
  221.          fragP;
  222.          fragP = fragP -> fr_next)
  223. ***************
  224. *** 298,314 ****
  225.         know( text_last_frag );
  226.         text_last_frag -> fr_next = data_frag_root;
  227.       }
  228. !   else {
  229. !       md_number_to_chars((char *)&the_exec.a_data,0,sizeof(the_exec.a_data));
  230. !       data_siz = 0;
  231. !   }
  232.   
  233. !   bss_address_frag . fr_address = text_siz + data_siz;
  234.   #ifdef SPARC
  235.     local_bss_counter=(local_bss_counter+7)&(~7);
  236.   #endif
  237. !   md_number_to_chars((char *)&the_exec.a_bss,local_bss_counter,sizeof(the_exec.a_bss));
  238.             
  239.     /*
  240.      *
  241. --- 296,310 ----
  242.         know( text_last_frag );
  243.         text_last_frag -> fr_next = data_frag_root;
  244.       }
  245. !   else
  246. !       H_SET_DATA_SIZE(&headers,0);
  247.   
  248. !   bss_address_frag . fr_address = H_GET_TEXT_SIZE(&headers) + 
  249. !                                   H_GET_DATA_SIZE(&headers);
  250.   #ifdef SPARC
  251.     local_bss_counter=(local_bss_counter+7)&(~7);
  252.   #endif
  253. !   H_SET_BSS_SIZE(&headers,local_bss_counter);
  254.             
  255.     /*
  256.      *
  257. ***************
  258. *** 340,380 ****
  259.           symbolP->sy_forward=0;
  260.       }
  261.     }
  262. !   symbolPP = & symbol_rootP;    /* -> last symbol chain link. */
  263.     {
  264. !     register long int        symbol_number;
  265.   
  266. !     symbol_number = 0;
  267.       while (symbolP  = * symbolPP)
  268.         {
  269. !     name = symbolP -> sy_name;
  270. !     if(flagseen['R'] && (symbolP->sy_nlist.n_type&N_DATA)) {
  271. !       symbolP->sy_nlist.n_type&= ~N_DATA;
  272. !       symbolP->sy_nlist.n_type|= N_TEXT;
  273. !     }
  274. !     /* if(symbolP->sy_forward) {
  275. !       symbolP->sy_value += symbolP->sy_forward->sy_value + symbolP->sy_forward->sy_frag->fr_address;
  276. !     } */
  277.       
  278.       symbolP -> sy_value += symbolP -> sy_frag -> fr_address;
  279. -         /* JF the 128 bit is a hack so stabs like
  280. -            "LET_STMT:23. . ."  don't go away */
  281. -     /* CPH: 128 bit hack is moby loser.  N_SO for file "Lower.c"
  282. -        fell through the cracks.  I think that N_STAB should be
  283. -        used instead of 128. */
  284.           /* JF the \001 bit is to make sure that local labels
  285.              ( 1: - 9: don't make it into the symtable either */
  286.   #ifndef    VMS    /* Under VMS we need to keep local symbols */
  287. !     if ( !name || (symbolP->sy_nlist.n_type&N_STAB)
  288. !         || (name[0]!='\001' && (flagseen ['L'] || name [0] != 'L' )))
  289.   #endif    /* not VMS */
  290.         {
  291. -         symbolP -> sy_number = symbol_number ++;
  292.   #ifndef    VMS
  293. !         if (name)
  294.             {            /* Ordinary case. */
  295.           symbolP -> sy_name_offset = string_byte_count;
  296. !         string_byte_count += strlen (symbolP  -> sy_name) + 1;
  297.             }
  298.           else            /* .Stabd case. */
  299.   #endif    /* not VMS */
  300. --- 336,581 ----
  301.           symbolP->sy_forward=0;
  302.       }
  303.     }
  304.     {
  305. !       register int    symbol_number = 0;
  306. ! #if defined(coff)
  307. !       symbolS*        symbol_externP = (symbolS*)0;
  308. !       symbolS*        symbol_extern_lastP = (symbolS*)0;
  309. !       
  310. !   /* The symbol list should be ordered according to the following sequence
  311. !    * order :
  312. !    * . .file symbol
  313. !    * . debug entries for functions
  314. !    * . fake symbols for .text .data and .bss
  315. !    * . defined symbols
  316. !    * . undefined symbols
  317. !    * But this is not mandatory. The only important point is to put the
  318. !    * undefined symbols at the end of the list.
  319. !    */
  320. !       {
  321. !       /* Is there a .file symbol ? If not insert one at the beginning. */
  322. !       if(symbol_rootP == NULL ||
  323. !          S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE)
  324. !           c_dot_file_symbol("fake");
  325. !       
  326. !       /*
  327. !        * Build up static symbols for .text, .data and .bss
  328. !        */
  329. !       dot_text_symbol = (symbolS*)
  330. !           c_section_symbol(".text", 0, H_GET_TEXT_SIZE(&headers),
  331. !              0/*text_relocation_number*/, 0/*text_lineno_number*/);
  332. !       dot_data_symbol = (symbolS*)
  333. !           c_section_symbol(".data", H_GET_TEXT_SIZE(&headers),
  334. !             H_GET_DATA_SIZE(&headers),
  335. !             0/*data_relocation_number*/,
  336. !             0); /* There is no data lineno entries */
  337. !       dot_bss_symbol = (symbolS*)
  338. !           c_section_symbol(".bss", H_GET_TEXT_SIZE(&headers) +
  339. !             H_GET_DATA_SIZE(&headers),
  340. !             H_GET_BSS_SIZE(&headers),
  341. !             0, /* No relocation for a bss section. */
  342. !             0); /* There is no bss lineno entries */
  343. !       }
  344. !           
  345. !       symbolP = symbol_rootP;
  346. !       if(symbolP) {
  347. !        while(symbolP) {
  348. !           /* If the symbol has a tagndx entry, resolve it */
  349. !           if(SF_GET_TAGGED(symbolP)) {
  350. !           SA_SET_SYM_TAGNDX(symbolP,
  351. !                     ((symbolS*)SA_GET_SYM_TAGNDX(symbolP))->sy_number);
  352. !           }
  353. !           /* Debug symbol do not need all this rubbish */
  354. !           if(!SF_GET_DEBUG(symbolP)) {
  355. !           symbolS* real_symbolP;
  356. !           /* L* and C_EFCN symbols never merge. */
  357. !           if(!SF_GET_LOCAL(symbolP) &&
  358. !              (real_symbolP =
  359. !               symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP)) &&
  360. !              real_symbolP != symbolP) {
  361. !               /* Move the debug data from the debug symbol to the
  362. !              real symbol. Do NOT do the oposite (i.e. move from
  363. !              real symbol to symbol and remove real symbol from the
  364. !              list.) Because some pointers refer to the real symbol
  365. !              whereas no pointers refer to the symbol. */
  366. !               c_symbol_merge(symbolP, real_symbolP);
  367. !               /* Replace the current symbol by the real one */
  368. !               /* The symbols will never be the last or the first
  369. !              because : 1st symbol is .file and 3 last symbols are
  370. !              .text, .data, .bss */
  371. !               real_symbolP->sy_previous->sy_next = real_symbolP->sy_next;
  372. !               real_symbolP->sy_next->sy_previous = real_symbolP->sy_previous;
  373. !               symbolP->sy_previous->sy_next = real_symbolP;
  374. !               symbolP->sy_next->sy_previous = real_symbolP;
  375. !               real_symbolP->sy_next = symbolP->sy_next;
  376. !               real_symbolP->sy_previous = symbolP->sy_previous;
  377. !               symbolP = real_symbolP;
  378. !           }
  379. !           if(flagseen['R'] && S_IS_DATA(symbolP))
  380. !               S_SET_TEXT(symbolP);
  381. !           
  382. !           symbolP->sy_value += symbolP->sy_frag->fr_address;
  383. !           
  384. !           if(!S_IS_DEFINED(symbolP))
  385. !               S_SET_EXTERNAL(symbolP);
  386. !           else if(S_GET_STORAGE_CLASS(symbolP) == C_NULL)
  387. !               S_SET_STORAGE_CLASS(symbolP, C_STAT);
  388. !           
  389. !           /* Mainly to speed up if not -g */
  390. !           if(SF_GET_PROCESS(symbolP)) {
  391. !               /* Handle the nested blocks auxiliary info. */
  392. !               if(S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) {
  393. !               if(!strcmp(S_GET_NAME(symbolP), ".bb"))
  394. !                   stack_push(block_stack, &symbolP);
  395. !               else { /* .eb */
  396. !                   register symbolS* begin_symbolP;
  397. !                   begin_symbolP = *(symbolS**)stack_pop(block_stack);
  398. !                   if(begin_symbolP == (symbolS*)0)
  399. !                   as_warn("mismatched .eb");
  400. !                   else
  401. !                   SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number);
  402. !               }
  403. !               }
  404. !               /* If we are able to identify the type of a function, and we
  405. !              are out of a function (last_functionP == 0) then, the
  406. !              function symbol will be associated with an auxiliary
  407. !              entry. */
  408. !               if(last_functionP == (symbolS*)0 &&
  409. !              SF_GET_FUNCTION(symbolP)) {
  410. !               last_functionP = symbolP;
  411. !               S_SET_NUMBER_AUXILIARY(symbolP, 1);
  412. !               /* Clobber possible stale .dim information. */
  413. !               memset(&symbolP->sy_auxent, '\0', sizeof(union auxent));
  414. !               }
  415. !               /* The C_FCN do not need any additional information.
  416. !              I don't even know if this is needed for sdb. But the
  417. !              standard assembler generate it, so...
  418. !              */
  419. !               if(S_GET_STORAGE_CLASS(symbolP) == C_EFCN) {
  420. !               if(last_functionP == (symbolS*)0)
  421. !                   as_fatal("C_EFCN symbol out of scope");
  422. !               SA_SET_SYM_FSIZE(last_functionP,
  423. !                        (long)(symbolP->sy_value -
  424. !                           last_functionP->sy_value));
  425. !               SA_SET_SYM_ENDNDX(last_functionP, symbol_number);
  426. !               last_functionP = (symbolS*)0;
  427. !               }
  428. !           }
  429. !           } else {
  430. !           /* First descriptor of a structure must point to the next
  431. !              slot outside the structure description. */
  432. !           if(SF_GET_TAG(symbolP))
  433. !               last_tagP = symbolP;
  434. !           else if(S_GET_STORAGE_CLASS(symbolP) == C_EOS)
  435. !               /* +2 take in account the current symbol */
  436. !               SA_SET_SYM_ENDNDX(last_tagP, symbol_number+2);
  437. !           }
  438. !           /* We must put the external symbols appart. The loader
  439. !          does not bomb if we do not. But the references in
  440. !          the endndx field for a .bb symbol are not corrected
  441. !          if an external symbol is removed between .bb and .be.
  442. !          I.e int the following case :
  443. !          [20] .bb endndx = 22
  444. !          [21] foo external
  445. !          [22] .be
  446. !          ld will move the symbol 21 to the end of the list but
  447. !          endndx will still be 22 instead of 21. */
  448. !           {
  449. !           register symbolS* thisP = symbolP;
  450. !           symbolP = thisP->sy_next;
  451. !           /* remove C_EFCN and LOCAL (L...) symbols */
  452. !           if(SF_GET_LOCAL(thisP)) {
  453. !               thisP->sy_next->sy_previous = thisP->sy_previous;
  454. !               thisP->sy_previous->sy_next = thisP->sy_next;
  455. !           } else {
  456. !               if(S_GET_STORAGE_CLASS(thisP) == C_EXT &&
  457. !              !SF_GET_FUNCTION(thisP)) {
  458. !               /* Remove from the list */
  459. !               thisP->sy_next->sy_previous = thisP->sy_previous;
  460. !               thisP->sy_previous->sy_next = thisP->sy_next;
  461. !               /* Move at the end of the list */
  462. !               if (symbol_extern_lastP) {
  463. !                   symbol_extern_lastP->sy_next = thisP;
  464. !                   thisP->sy_previous = symbol_extern_lastP;
  465. !               } else {
  466. !                   symbol_externP = thisP;
  467. !               }
  468. !               thisP->sy_next = (symbolS*)0;
  469. !               symbol_extern_lastP = thisP;
  470. !               } else {
  471. !               if(SF_GET_STRING(thisP)) {
  472. !                   thisP->sy_name_offset = string_byte_count;
  473. !                   string_byte_count += strlen(S_GET_NAME(thisP)) + 1;
  474. !               } else
  475. !                   thisP->sy_name_offset = 0;
  476. !               thisP->sy_number = symbol_number;
  477. !               symbol_number += 1 + S_GET_NUMBER_AUXILIARY(thisP);
  478. !               }
  479. !           }
  480. !           }
  481. !       }
  482.   
  483. !       symbol_lastP->sy_next = symbol_externP;
  484. !       symbolP = symbol_externP;
  485. !       while(symbolP) {
  486. !           if(SF_GET_STRING(symbolP)) {
  487. !           symbolP->sy_name_offset = string_byte_count;
  488. !           string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
  489. !           } else
  490. !           symbolP->sy_name_offset = 0;
  491. !           symbolP->sy_number = symbol_number;
  492. !           symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
  493. !           symbolP = symbolP->sy_next;
  494. !       }
  495. !       }
  496. !       {
  497. !       lineno* lineP;
  498. !       for(lineP = lineno_rootP; lineP; lineP = lineP->next) {
  499. !           if(lineP->line.l_lnno)
  500. !           lineP->line.l_addr.l_paddr +=
  501. !               ((fragS*)lineP->frag)->fr_address;
  502. !           else {
  503. !           /* There is a good chance that the symbol pointed to
  504. !              is not the one that will be emitted and that the 
  505. !              sy_number is not accurate. */
  506. !           char* name;
  507. !           name = (char*)lineP->line.l_addr.l_symndx;
  508. !           if((symbolP = symbol_find_base(name, DO_NOT_STRIP)) ==
  509. !              (symbolS*)0)
  510. !               as_warn("line number lost symbol %s", name);
  511. !           else
  512. !               lineP->line.l_addr.l_symndx = symbolP->sy_number;
  513. !           }
  514. !           text_lineno_number++;
  515. !       }
  516. !       }
  517. ! #elif defined(aout)
  518. !     symbolPP = & symbol_rootP;    /* -> last symbol chain link. */
  519.       while (symbolP  = * symbolPP)
  520.         {
  521. !     name = S_GET_NAME(symbolP);
  522. !     if(flagseen['R'] && S_IS_DATA(symbolP))
  523. !       S_SET_TEXT(symbolP);
  524.       
  525.       symbolP -> sy_value += symbolP -> sy_frag -> fr_address;
  526.           /* JF the \001 bit is to make sure that local labels
  527.              ( 1: - 9: don't make it into the symtable either */
  528.   #ifndef    VMS    /* Under VMS we need to keep local symbols */
  529. !     if (!S_IS_LOCAL(symbolP))
  530.   #endif    /* not VMS */
  531.         {
  532.   #ifndef    VMS
  533. ! /* The + 1 after strlen account for the \0 at the end of each string */
  534. !         symbolP -> sy_number = symbol_number ++;
  535. !         if(!S_IS_STABD(symbolP))
  536.             {            /* Ordinary case. */
  537.           symbolP -> sy_name_offset = string_byte_count;
  538. !         string_byte_count += 
  539. !             strlen (S_GET_NAME(symbolP)) + 1;
  540.             }
  541.           else            /* .Stabd case. */
  542.   #endif    /* not VMS */
  543. ***************
  544. *** 382,397 ****
  545.           symbolPP = & (symbolP -> sy_next);
  546.         }
  547.   #ifndef    VMS
  548. !     else
  549.           * symbolPP = symbolP -> sy_next;
  550.   #endif    /* not VMS */
  551.         }                /* for each symbol */
  552.   
  553. !     syms_siz = sizeof( struct nlist) * symbol_number;
  554. !     md_number_to_chars((char *)&the_exec.a_syms,syms_siz,sizeof(the_exec.a_syms));
  555. !     /* the_exec . a_syms = sizeof( struct nlist) * symbol_number; */
  556.     }
  557.     /*
  558.      * Addresses of frags now reflect addresses we use in the object file.
  559.      * Symbol values are correct.
  560. --- 583,601 ----
  561.           symbolPP = & (symbolP -> sy_next);
  562.         }
  563.   #ifndef    VMS
  564. !     else /* skip the symbol */
  565.           * symbolPP = symbolP -> sy_next;
  566.   #endif    /* not VMS */
  567.         }                /* for each symbol */
  568.   
  569. ! #elif defined(elf)
  570. !       do it yourself !
  571. ! #else
  572. !       you lose
  573. ! #endif
  574. !     H_SET_STRING_SIZE(&headers,string_byte_count);
  575. !     H_SET_SYMBOL_TABLE_SIZE(&headers, symbol_number);
  576.     }
  577.     /*
  578.      * Addresses of frags now reflect addresses we use in the object file.
  579.      * Symbol values are correct.
  580. ***************
  581. *** 553,595 ****
  582.      * Scan every FixS performing fixups. We had to wait until now to do
  583.      * this because md_convert_frag() may have made some fixSs.
  584.      */
  585. !   /* the_exec . a_trsize
  586. !     = sizeof(struct relocation_info) * fixup_segment (text_fix_root, N_TEXT);
  587. !   the_exec . a_drsize
  588. !     = sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA); */
  589. !   tr_siz=sizeof(struct relocation_info) * fixup_segment (text_fix_root, N_TEXT);
  590. !   md_number_to_chars((char *)&the_exec.a_trsize, tr_siz ,sizeof(the_exec.a_trsize));
  591. !   dr_siz=sizeof(struct relocation_info) * fixup_segment (data_fix_root, N_DATA);
  592. !   md_number_to_chars((char *)&the_exec.a_drsize, dr_siz, sizeof(the_exec.a_drsize));
  593. !   md_number_to_chars((char *)&the_exec.a_magic,omagic,sizeof(the_exec.a_magic));
  594. !   md_number_to_chars((char *)&the_exec.a_entry,0,sizeof(the_exec.a_entry));
  595.   
  596.   #ifdef EXEC_MACHINE_TYPE
  597. !   md_number_to_chars((char *)&the_exec.a_machtype, EXEC_MACHINE_TYPE, sizeof(the_exec.a_machtype));
  598.   #endif
  599.   #ifdef EXEC_VERSION
  600. !   md_number_to_chars((char *)&the_exec.a_version,EXEC_VERSION,sizeof(the_exec.a_version));
  601.   #endif
  602. -   
  603. -   /* the_exec . a_entry = 0; */
  604.   
  605. !   size_of_the_object_file =
  606. !     sizeof( the_exec ) +
  607. !       text_siz +
  608. !         data_siz +
  609. !       syms_siz +
  610. !         tr_siz +
  611. !           dr_siz +
  612. !         string_byte_count;
  613. !     
  614. !   next_object_file_charP
  615. !     = the_object_file
  616. !       = xmalloc ( size_of_the_object_file );
  617.   
  618.     output_file_create (out_file_name);
  619.   
  620. !   append (& next_object_file_charP, (char *)(&the_exec), (unsigned long)sizeof(the_exec));
  621.   
  622.     /*
  623.      * Emit code.
  624. --- 757,876 ----
  625.      * Scan every FixS performing fixups. We had to wait until now to do
  626.      * this because md_convert_frag() may have made some fixSs.
  627.      */
  628. !   
  629. !   H_SET_RELOCATION_SIZE(&headers,
  630. !        RELSZ*fixup_segment (text_fix_root, SEG_TEXT),
  631. !        RELSZ*fixup_segment (data_fix_root, SEG_DATA));
  632. !   H_SET_MAGIC_NUMBER(&headers,omagic);
  633. !   H_SET_ENTRY_POINT(&headers,0);
  634.   
  635.   #ifdef EXEC_MACHINE_TYPE
  636. !   H_SET_MACHINE_TYPE(&headers,EXEC_MACHINE_TYPE);
  637.   #endif
  638.   #ifdef EXEC_VERSION
  639. !   H_SET_VERSION(&headers,EXEC_VERSION);
  640.   #endif
  641.   
  642. ! #ifdef coff
  643. !   {
  644. !       register int        text_relocation_number = 0;
  645. !       register int        data_relocation_number = 0;
  646. !       register fixS*    fixP;
  647. !       
  648. !       /* Count the number of relocation entries for text and data */
  649. !       for(fixP = text_fix_root; fixP; fixP = fixP->fx_next)
  650. !       if(fixP->fx_addsy)
  651. !           text_relocation_number++;
  652. !       SA_SET_SCN_NRELOC(dot_text_symbol, text_relocation_number);
  653. !       /* Assign the number of line number entries for the text section */
  654. !       SA_SET_SCN_NLINNO(dot_text_symbol, text_lineno_number);
  655. !       /* Assign the size of the section */
  656. !       SA_SET_SCN_SCNLEN(dot_text_symbol, H_GET_TEXT_SIZE(&headers));
  657. !       
  658. !       for(fixP = data_fix_root; fixP; fixP = fixP->fx_next)
  659. !       if(fixP->fx_addsy)
  660. !           data_relocation_number++;
  661. !       SA_SET_SCN_NRELOC(dot_data_symbol, data_relocation_number);
  662. !       /* Assign the size of the section */
  663. !       SA_SET_SCN_SCNLEN(dot_data_symbol, H_GET_DATA_SIZE(&headers));
  664. !       /* Assign the size of the section */
  665. !       SA_SET_SCN_SCNLEN(dot_bss_symbol, H_GET_BSS_SIZE(&headers));
  666. !   }
  667. !   /* Fill in extra coff fields */
  668. !   /* Initialize general line number information. */
  669. !   H_SET_LINENO_SIZE(&headers, text_lineno_number * LINESZ);
  670. !   /* filehdr */
  671. !   H_SET_FILE_MAGIC_NUMBER(&headers, FILE_HEADER_MAGIC);
  672. !   H_SET_NUMBER_OF_SECTIONS(&headers, 3); /* text+data+bss */
  673. !   H_SET_TIME_STAMP(&headers, (long)time((long*)0));
  674. !   H_SET_SYMBOL_TABLE_POINTER(&headers,
  675. !                  H_GET_SYMBOL_TABLE_FILE_OFFSET(&headers));
  676. !   /* symbol table size allready set */
  677. !   H_SET_SIZEOF_OPTIONAL_HEADER(&headers, AOUTHDRSZ);
  678. !   H_SET_FLAGS(&headers, (text_lineno_number == 0 ? F_LNNO : 0 ) | 
  679. !           BYTE_ORDERING);
  680. !   /* aouthdr */
  681. !   /* magic number allready set */
  682. !   H_SET_VERSION_STAMP(&headers, 0);
  683. !   /* Text, data, bss size; entry point; text_start and data_start
  684. !      are already set */
  685. !   /* Build section headers */
  686. !   
  687. !   c_section_header(&text_section_header,
  688. !            ".text",
  689. !            0,
  690. !            H_GET_TEXT_SIZE(&headers),
  691. !            H_GET_TEXT_FILE_OFFSET(&headers),
  692. !            SA_GET_SCN_NRELOC(dot_text_symbol) ?
  693. !              H_GET_RELOCATION_FILE_OFFSET(&headers) : 0,
  694. !            text_lineno_number ? H_GET_LINENO_FILE_OFFSET(&headers) : 0,
  695. !            SA_GET_SCN_NRELOC(dot_text_symbol),
  696. !            text_lineno_number);
  697. !   c_section_header(&data_section_header,
  698. !            ".data",
  699. !            H_GET_TEXT_SIZE(&headers),
  700. !            H_GET_DATA_SIZE(&headers),
  701. !            H_GET_DATA_SIZE(&headers) ?
  702. !              H_GET_DATA_FILE_OFFSET(&headers) : 0,
  703. !            SA_GET_SCN_NRELOC(dot_data_symbol) ?
  704. !              H_GET_RELOCATION_FILE_OFFSET(&headers) +
  705. !              text_section_header.s_nreloc * RELSZ : 0,
  706. !            0, /* No line number information */
  707. !            SA_GET_SCN_NRELOC(dot_data_symbol),
  708. !            0);  /* No line number information */
  709. !   c_section_header(&bss_section_header,
  710. !            ".bss",
  711. !            H_GET_TEXT_SIZE(&headers) + H_GET_DATA_SIZE(&headers),
  712. !            H_GET_BSS_SIZE(&headers),
  713. !            0, /* No file offset */
  714. !            0, /* No relocation information */
  715. !            0, /* No line number information */
  716. !            0, /* No relocation information */
  717. !            0); /* No line number information */
  718. !   
  719. ! #endif /* coff */
  720. !   
  721. !   object_file_size = H_GET_FILE_SIZE(&headers);
  722. !   next_object_file_charP = the_object_file = xmalloc ( object_file_size );
  723.   
  724.     output_file_create (out_file_name);
  725.   
  726. !   H_OUTPUT(&headers, &next_object_file_charP);
  727. ! #ifdef coff
  728. !   /* Output the section headers */
  729. !   c_section_header_append(&text_section_header, &next_object_file_charP);
  730. !   c_section_header_append(&data_section_header, &next_object_file_charP);
  731. !   c_section_header_append(&bss_section_header, &next_object_file_charP);
  732. ! #endif /* coff */
  733.   
  734.     /*
  735.      * Emit code.
  736. ***************
  737. *** 614,642 ****
  738.      */
  739.     emit_relocations (text_fix_root, (relax_addressT)0);
  740.     emit_relocations (data_fix_root, text_last_frag -> fr_address);
  741.     /*
  742. !    * Emit all symbols left in the symbol chain.
  743. !    * Any symbol still undefined is made N_EXT.
  744.      */
  745. !   for (   symbolP = symbol_rootP;   symbolP;   symbolP = symbolP -> sy_next   )
  746. !     {
  747. !       register char *    temp;
  748. !       temp = symbolP -> sy_nlist . n_un . n_name;
  749. !       /* JF fix the numbers up. Call by value RULES! */
  750. !       md_number_to_chars((char *)&(symbolP -> sy_nlist  . n_un . n_strx ),symbolP -> sy_name_offset,sizeof(symbolP -> sy_nlist  . n_un . n_strx ));
  751. !       md_number_to_chars((char *)&(symbolP->sy_nlist.n_desc),symbolP->sy_nlist.n_desc,sizeof(symbolP -> sy_nlist  . n_desc));
  752. !       md_number_to_chars((char *)&(symbolP->sy_nlist.n_value),symbolP->sy_nlist.n_value,sizeof(symbolP->sy_nlist.n_value));
  753. !       /* symbolP -> sy_nlist  . n_un . n_strx = symbolP -> sy_name_offset; JF replaced by md above */
  754. !       if (symbolP -> sy_type == N_UNDF)
  755. !       symbolP -> sy_type |= N_EXT; /* Any undefined symbols become N_EXT. */
  756. !       append (& next_object_file_charP, (char *)(& symbolP -> sy_nlist),
  757. !           (unsigned long)sizeof(struct nlist));
  758. !       symbolP -> sy_nlist . n_un . n_name = temp;
  759. !     }                /* for each symbol */
  760.   
  761.     /*
  762. -    * next_object_file_charP -> slot for next object byte.
  763.      * Emit strings.
  764.      * Find strings by crawling along symbol table chain.
  765.      */
  766. --- 895,914 ----
  767.      */
  768.     emit_relocations (text_fix_root, (relax_addressT)0);
  769.     emit_relocations (data_fix_root, text_last_frag -> fr_address);
  770. + #ifdef coff
  771.     /*
  772. !    * Emit line number entries.
  773.      */
  774. !   emit_lineno(lineno_rootP, &next_object_file_charP);
  775. ! #endif /* coff */
  776. !   /*
  777. !    * Emit symbols.
  778. !    */
  779. !   emit_symbols (symbol_rootP,&next_object_file_charP);
  780.   
  781.     /*
  782.      * Emit strings.
  783.      * Find strings by crawling along symbol table chain.
  784.      */
  785. ***************
  786. *** 644,661 ****
  787.     md_number_to_chars((char *)&string_byte_count, string_byte_count, sizeof(string_byte_count));
  788.   
  789.     append (& next_object_file_charP, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count));
  790. !   for (   symbolP = symbol_rootP;   symbolP;   symbolP = symbolP -> sy_next   )
  791. !     {
  792. !       if (symbolP -> sy_name)
  793. !     {            /* Ordinary case: not .stabd. */
  794. !       append (& next_object_file_charP, symbolP -> sy_name,
  795. !           (unsigned long)(strlen (symbolP -> sy_name) + 1));
  796. !     }
  797. !     }                /* for each symbol */
  798. !   know( next_object_file_charP == the_object_file + size_of_the_object_file );
  799.   
  800. !   output_file_append (the_object_file, size_of_the_object_file, out_file_name);
  801.   
  802.   #ifdef DONTDEF
  803.     if (flagseen['G'])        /* GDB symbol file to be appended? */
  804. --- 916,934 ----
  805.     md_number_to_chars((char *)&string_byte_count, string_byte_count, sizeof(string_byte_count));
  806.   
  807.     append (& next_object_file_charP, (char *)&string_byte_count, (unsigned long)sizeof(string_byte_count));
  808. !   for(symbolP = symbol_rootP; symbolP; symbolP = symbolP->sy_next) {
  809. ! #ifdef coff
  810. !       if(SF_GET_STRING(symbolP))
  811. ! #else /* coff */
  812. !       if(S_GET_NAME(symbolP))
  813. ! #endif /* coff */
  814. !       append(&next_object_file_charP, S_GET_NAME(symbolP),
  815. !          (unsigned long)(strlen (S_GET_NAME(symbolP)) + 1));
  816. !   }
  817.   
  818. !   know( next_object_file_charP == the_object_file + object_file_size);
  819. !   /* Write the data to the file */
  820. !   output_file_append (the_object_file,object_file_size,out_file_name);
  821.   
  822.   #ifdef DONTDEF
  823.     if (flagseen['G'])        /* GDB symbol file to be appended? */
  824. ***************
  825. *** 692,698 ****
  826.   void
  827.   relax_segment (segment_frag_root, segment_type)
  828.        struct frag *    segment_frag_root;
  829. !      segT        segment_type; /* N_DATA or N_TEXT */
  830.   {
  831.     register struct frag *    fragP;
  832.     register relax_addressT    address;
  833. --- 965,971 ----
  834.   void
  835.   relax_segment (segment_frag_root, segment_type)
  836.        struct frag *    segment_frag_root;
  837. !      segT        segment_type; /* SEG_DATA or SEG_TEXT */
  838.   {
  839.     register struct frag *    fragP;
  840.     register relax_addressT    address;
  841. ***************
  842. *** 730,736 ****
  843.   
  844.       case rs_machine_dependent:
  845.         address += md_estimate_size_before_relax
  846. !         (fragP, seg_N_TYPE [(int) segment_type]);
  847.         break;
  848.   
  849.   #ifndef WORKING_DOT_WORD
  850. --- 1003,1009 ----
  851.   
  852.       case rs_machine_dependent:
  853.         address += md_estimate_size_before_relax
  854. !         (fragP, seg_SEG((int) segment_type));
  855.         break;
  856.   
  857.   #ifndef WORKING_DOT_WORD
  858. ***************
  859. *** 837,845 ****
  860.           target = offset;
  861.           if (symbolP)
  862.             {
  863. !             know(   ((symbolP -> sy_type & N_TYPE) == N_ABS) || ((symbolP -> sy_type & N_TYPE) == N_DATA) || ((symbolP -> sy_type & N_TYPE) == N_TEXT));
  864. !             know( symbolP -> sy_frag );
  865. !             know( (symbolP->sy_type&N_TYPE)!=N_ABS || symbolP->sy_frag==&zero_address_frag );
  866.               target +=
  867.                 symbolP -> sy_value
  868.               + symbolP -> sy_frag -> fr_address;
  869. --- 1110,1121 ----
  870.           target = offset;
  871.           if (symbolP)
  872.             {
  873. !             know(S_IS_ABS(symbolP) ||
  874. !              S_IS_DATA(symbolP) ||
  875. !              S_IS_TEXT(symbolP))
  876. !             know(symbolP -> sy_frag);
  877. !             know(!S_IS_ABS(symbolP) || 
  878. !              symbolP->sy_frag==&zero_address_frag );
  879.               target +=
  880.                 symbolP -> sy_value
  881.               + symbolP -> sy_frag -> fr_address;
  882. ***************
  883. *** 866,875 ****
  884.           target = offset;
  885.           if (symbolP)
  886.             {
  887. !  know(   ((symbolP -> sy_type & N_TYPE) == N_ABS) || ((symbolP -> sy_type &
  888. !  N_TYPE) == N_DATA) || ((symbolP -> sy_type & N_TYPE) == N_TEXT));
  889. !             know( symbolP -> sy_frag );
  890. !             know( (symbolP->sy_type&N_TYPE)!=N_ABS || symbolP->sy_frag==&zero_address_frag );
  891.               target +=
  892.                 symbolP -> sy_value
  893.               + symbolP -> sy_frag -> fr_address;
  894. --- 1142,1153 ----
  895.           target = offset;
  896.           if (symbolP)
  897.             {
  898. !             know(S_IS_ABS(symbolP) ||
  899. !              S_IS_DATA(symbolP) ||
  900. !              S_IS_TEXT(symbolP))
  901. !             know(symbolP -> sy_frag);
  902. !             know(!S_IS_ABS(symbolP) || 
  903. !              symbolP->sy_frag==&zero_address_frag );
  904.               target +=
  905.                 symbolP -> sy_value
  906.               + symbolP -> sy_frag -> fr_address;
  907. ***************
  908. *** 1021,1045 ****
  909.         add_number  = fixP  -> fx_offset;
  910.         pcrel      = fixP  -> fx_pcrel;
  911.         if(add_symbolP)
  912. !     add_symbol_N_TYPE = add_symbolP -> sy_type & N_TYPE;
  913.         if (sub_symbolP)
  914.       {
  915.         if(!add_symbolP)    /* Its just -sym */
  916.           {
  917. !           if(sub_symbolP->sy_type!=N_ABS)
  918. !             as_warn("Negative of non-absolute symbol %s", sub_symbolP->sy_name);
  919. !           add_number-=sub_symbolP->sy_value;
  920.           }
  921. !       else if (   ((sub_symbolP -> sy_type ^ add_symbol_N_TYPE) & N_TYPE) == 0
  922. !           && (   add_symbol_N_TYPE == N_DATA
  923. !           || add_symbol_N_TYPE == N_TEXT
  924. !           || add_symbol_N_TYPE == N_BSS
  925. !           || add_symbol_N_TYPE == N_ABS))
  926.           {
  927.             /* Difference of 2 symbols from same segment. */
  928.             /* Can't make difference of 2 undefineds: 'value' means */
  929.             /* something different for N_UNDF. */
  930. !           add_number += add_symbolP -> sy_value - sub_symbolP -> sy_value;
  931.             add_symbolP = NULL;
  932.             fixP -> fx_addsy = NULL;
  933.           }
  934. --- 1299,1328 ----
  935.         add_number  = fixP  -> fx_offset;
  936.         pcrel      = fixP  -> fx_pcrel;
  937.         if(add_symbolP)
  938. !     add_symbol_N_TYPE = SEG_seg(S_GET_SEGMENT(add_symbolP));
  939.         if (sub_symbolP)
  940.       {
  941.         if(!add_symbolP)    /* Its just -sym */
  942.           {
  943. !           if(SEG_seg(sub_symbolP->sy_type)!=SEG_ABSOLUTE)
  944. !             as_warn("Negative of non-absolute symbol %s", 
  945. !             S_GET_NAME(sub_symbolP));
  946. !           add_number-=S_GET_VALUE(sub_symbolP);
  947.           }
  948. !       /* if sub_symbol is in the same segment that add_symbol
  949. !          and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
  950. !       else if((SEG_seg(S_GET_SEGMENT(sub_symbolP)) == 
  951. !            add_symbol_N_TYPE) &&
  952. !           ((add_symbol_N_TYPE == SEG_DATA) ||
  953. !            (add_symbol_N_TYPE == SEG_TEXT) ||
  954. !            (add_symbol_N_TYPE == SEG_BSS)  ||
  955. !            (add_symbol_N_TYPE == SEG_ABSOLUTE)))
  956.           {
  957.             /* Difference of 2 symbols from same segment. */
  958.             /* Can't make difference of 2 undefineds: 'value' means */
  959.             /* something different for N_UNDF. */
  960. !           add_number += S_GET_VALUE(add_symbolP) - 
  961. !                     S_GET_VALUE(sub_symbolP);
  962.             add_symbolP = NULL;
  963.             fixP -> fx_addsy = NULL;
  964.           }
  965. ***************
  966. *** 1046,1059 ****
  967.         else
  968.           {
  969.             /* Different segments in subtraction. */
  970. !           know( sub_symbolP -> sy_type != (N_ABS | N_EXT))
  971. !         if (sub_symbolP -> sy_type == N_ABS)
  972. !             add_number -= sub_symbolP -> sy_value;
  973.           else
  974.             {
  975. !                as_warn("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
  976. !                     seg_name[(int)N_TYPE_seg[sub_symbolP->sy_type&N_TYPE]],
  977. !                     sub_symbolP -> sy_name, fragP -> fr_address + where);
  978.             }
  979.           }
  980.       }
  981. --- 1329,1342 ----
  982.         else
  983.           {
  984.             /* Different segments in subtraction. */
  985. !           know(!(S_IS_EXTERNAL(sub_symbolP) && S_IS_ABS(sub_symbolP)));
  986. !         if (S_IS_ABS(sub_symbolP))
  987. !             add_number -= S_GET_VALUE(sub_symbolP);
  988.           else
  989.             {
  990. !             as_warn("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
  991. !               segment_name((int)SEG_seg(S_GET_SEGMENT(sub_symbolP))),
  992. !               S_GET_NAME(sub_symbolP), fragP -> fr_address + where);
  993.             }
  994.           }
  995.       }
  996. ***************
  997. *** 1066,1072 ****
  998.              * SEG_UNKNOWN, but it is now in the local segment.
  999.              * So we know how to do the address without relocation.
  1000.              */
  1001. !           add_number += add_symbolP -> sy_value;
  1002.             add_number -= size + where + fragP -> fr_address;
  1003.             pcrel = 0;    /* Lie. Don't want further pcrel processing. */
  1004.             fixP -> fx_addsy = NULL; /* No relocations please. */
  1005. --- 1349,1355 ----
  1006.              * SEG_UNKNOWN, but it is now in the local segment.
  1007.              * So we know how to do the address without relocation.
  1008.              */
  1009. !           add_number += S_GET_VALUE(add_symbolP);
  1010.             add_number -= size + where + fragP -> fr_address;
  1011.             pcrel = 0;    /* Lie. Don't want further pcrel processing. */
  1012.             fixP -> fx_addsy = NULL; /* No relocations please. */
  1013. ***************
  1014. *** 1082,1101 ****
  1015.           {
  1016.             switch (add_symbol_N_TYPE)
  1017.           {
  1018. !         case N_ABS:
  1019. !           add_number += add_symbolP -> sy_value;
  1020.             fixP -> fx_addsy = NULL;
  1021.             add_symbolP = NULL;
  1022.             break;
  1023.             
  1024. !         case N_BSS:
  1025. !         case N_DATA:
  1026. !         case N_TEXT:
  1027.             seg_reloc_count ++;
  1028. !           add_number += add_symbolP -> sy_value;
  1029.             break;
  1030.             
  1031. !         case N_UNDF:
  1032.             seg_reloc_count ++;
  1033.             break;
  1034.             
  1035. --- 1365,1388 ----
  1036.           {
  1037.             switch (add_symbol_N_TYPE)
  1038.           {
  1039. !         case SEG_ABSOLUTE:
  1040. !           add_number += S_GET_VALUE(add_symbolP);
  1041.             fixP -> fx_addsy = NULL;
  1042.             add_symbolP = NULL;
  1043.             break;
  1044.             
  1045. !         case SEG_BSS:
  1046. !         case SEG_DATA:
  1047. !         case SEG_TEXT:
  1048.             seg_reloc_count ++;
  1049. !           add_number += S_GET_VALUE(add_symbolP);
  1050.             break;
  1051.             
  1052. !         case SEG_UNKNOWN:
  1053. ! #ifdef coff
  1054. !           if(S_IS_COMMON(add_symbolP))
  1055. !               add_number += S_GET_VALUE(add_symbolP);
  1056. ! #endif /* coff */
  1057.             seg_reloc_count ++;
  1058.             break;
  1059.             
  1060. ***************
  1061. *** 1125,1131 ****
  1062.       case 0:
  1063.   #ifdef SPARC
  1064.         fixP->fx_addnumber = add_number;
  1065. !       md_number_to_imm(place, add_number, size, fixP, this_segment_type);
  1066.   #else
  1067.         md_number_to_imm (place, add_number, size);
  1068.         /* OVE: the immediates, like disps, have lsb at lowest address */
  1069. --- 1412,1419 ----
  1070.       case 0:
  1071.   #ifdef SPARC
  1072.         fixP->fx_addnumber = add_number;
  1073. !       md_number_to_imm(place, add_number, size, fixP, 
  1074. !                seg_SEG(this_segment_type));
  1075.   #else
  1076.         md_number_to_imm (place, add_number, size);
  1077.         /* OVE: the immediates, like disps, have lsb at lowest address */
  1078. ***************
  1079. *** 1149,1215 ****
  1080.     return (seg_reloc_count);
  1081.   }                /* fixup_segment() */
  1082.   
  1083. - /* The sparc needs its own emit_relocations() */
  1084. - #ifndef SPARC
  1085. - /*
  1086. -  *        emit_relocations()
  1087. -  *
  1088. -  * Crawl along a fixS chain. Emit the segment's relocations.
  1089. -  */
  1090. - static void
  1091. - emit_relocations (fixP, segment_address_in_file)
  1092. -      register fixS *    fixP;    /* Fixup chain for this segment. */
  1093. -      relax_addressT    segment_address_in_file;
  1094. - {
  1095. -   struct relocation_info    ri;
  1096. -   register symbolS *        symbolP;
  1097. -     /* JF this is for paranoia */
  1098. -   bzero((char *)&ri,sizeof(ri));
  1099. -   for ( ;  fixP;  fixP = fixP -> fx_next)
  1100. -     {
  1101. -       if (symbolP = fixP -> fx_addsy)
  1102. -     {
  1103. - #ifndef hpux
  1104. -         /* These two 'cuz of NS32K */
  1105. -       ri . r_bsr        = fixP -> fx_bsr;
  1106. -       ri . r_disp        = fixP -> fx_im_disp;
  1107. - #endif
  1108. -       ri . r_length        = nbytes_r_length [fixP -> fx_size];
  1109. -       ri . r_pcrel        = fixP -> fx_pcrel;
  1110. -       ri . r_address    = fixP -> fx_frag -> fr_address
  1111. -         +   fixP -> fx_where
  1112. -           - segment_address_in_file;
  1113. -       if ((symbolP -> sy_type & N_TYPE) == N_UNDF)
  1114. -         {
  1115. -           ri . r_extern    = 1;
  1116. -           ri . r_symbolnum    = symbolP -> sy_number;
  1117. -         }
  1118. -       else
  1119. -         {
  1120. -           ri . r_extern    = 0;
  1121. -           ri . r_symbolnum    = symbolP -> sy_type & N_TYPE;
  1122. -         }
  1123. -       /* 
  1124. -         The 68k machines assign bit-fields from higher bits to 
  1125. -         lower bits ("left-to-right") within the int.  VAXen assign 
  1126. -         bit-fields from lower bits to higher bits ("right-to-left").
  1127. -         Both handle multi-byte numbers in their usual fashion
  1128. -         (Big-endian and little-endian stuff).
  1129. -         Thus we need a machine dependent routine to make
  1130. -         sure the structure is written out correctly.  FUN!
  1131. -        */
  1132. -       md_ri_to_chars((char *) &ri, ri); 
  1133. -       append (&next_object_file_charP, (char *)& ri, (unsigned long)sizeof(ri));
  1134. -     }
  1135. -     }
  1136. - }
  1137. - #endif
  1138.   
  1139.   int
  1140.   is_dnrange(f1,f2)
  1141. --- 1437,1442 ----
  1142. *** write.h    Tue May 30 20:36:06 1989
  1143. --- /lasvegas/spare/usenet/port/gas-1.36/write.h    Wed Sep 12 09:29:10 1990
  1144. ***************
  1145. *** 72,77 ****
  1146. --- 72,79 ----
  1147.   COMMON fixS *    data_fix_root;    /* Chains fixSs. */
  1148.   COMMON fixS **    seg_fix_rootP;    /* -> one of above. */
  1149.   
  1150. + COMMON char *    next_object_file_charP;
  1151.   bit_fixS *bit_fix_new();
  1152.   /* end: write.h */
  1153.   
  1154. *** xmalloc.c    Wed Mar  1 23:48:34 1989
  1155. --- /lasvegas/spare/usenet/port/gas-1.36/xmalloc.c    Wed Sep 12 09:28:43 1990
  1156. ***************
  1157. *** 43,48 ****
  1158. --- 43,50 ----
  1159.   #include <malloc.h>
  1160.   #endif
  1161.   
  1162. + #define error as_fatal
  1163.   char * xmalloc(n)
  1164.        long n;
  1165.   {
  1166. *** xrealloc.c    Wed Mar  1 23:48:33 1989
  1167. --- /lasvegas/spare/usenet/port/gas-1.36/xrealloc.c    Wed Sep 12 09:28:43 1990
  1168. ***************
  1169. *** 45,50 ****
  1170. --- 45,52 ----
  1171.   #include <malloc.h>
  1172.   #endif
  1173.   
  1174. + #define error as_fatal
  1175.   char   *
  1176.   xrealloc (ptr, n)
  1177.   register char  *ptr;
  1178. --
  1179. Loic Dachary     loic@adesign.uucp or loic@afp.uucp 
  1180. Voice        +33 1 40 35 20 20
  1181.