home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume23 / xenix-gnu / part03 / gas-1.38.pch
Encoding:
Text File  |  1991-09-27  |  46.2 KB  |  1,773 lines

  1. *** gas-1.38/Makefile    Thu Oct 18 15:26:42 1990
  2. --- Makefile    Fri Jul 12 06:02:10 1991
  3. ***************
  4. *** 50,55 ****
  5. --- 50,61 ----
  6.   # and un-comment the next two lines.
  7.   # G0 = -g -I. -DUSE_SYSTEM_HDR -DEXEC_VERSION=1
  8.   # LOADLIBES = -lc /usr/att/lib/libc.a
  9. + #
  10. + # To compile gas for a Xenix 386, comment out all the above lines,
  11. + # and un-comment the next two lines.  (If you are using GCC, comment out the
  12. + # alloca.o part) (Get alloca from the emacs distribution, or use GCC.)
  13. + G0 = -O -I. -DUSG -DWORKING_DOT_WORD
  14. + LOADLIBES = alloca.o -lmalloc
  15.   
  16.   # If you just want to compile the vax assembler, type 'make avax'
  17.   
  18. ***************
  19. *** 129,134 ****
  20. --- 135,144 ----
  21.   CFLAGS = $(G0) $(G1) $(G2) $(G3) $(G4)
  22.   
  23.   #
  24. + #
  25. + # To make the XENIX 386 assembler compile as the default, un-comment the next
  26. + # line and commment out all the other lines that start with DEFAULT_GAS
  27. + #DEFAULT_GAS=ax386
  28.   # To make the 68020 assembler compile as the default, un-comment the next
  29.   # line, and comment out all the other lines that start with DEFAULT_GAS
  30.   DEFAULT_GAS=a68
  31. ***************
  32. *** 245,250 ****
  33. --- 255,269 ----
  34.   
  35.   a386: $a $x
  36.       $(CC) -o a386 $(LDFLAGS) $a $x $(LOADLIBES)
  37. + # XENIX 80386 GAS --------------------------------------------------------------
  38. + u = xenixomf.o omfwrite.o
  39. + U = xenixomf.c xenixomf.h msomf.h omfwrite.c
  40. + xenixomf.o:    xenixomf.h msomf.h
  41. + ax386: $a $x $u
  42. +     $(CC) -o ax386 $(LDFLAGS) $a $u $x $(LOADLIBES)
  43.   
  44.   # 68020 GAS ------------------------------------------------------------------
  45.   y = m68k.o  atof-ieee.o write.o read.o
  46. *** gas-1.38/as.c    Thu Oct 11 11:26:17 1990
  47. --- as.c    Wed Jul 10 09:01:54 1991
  48. ***************
  49. *** 84,89 ****
  50. --- 84,90 ----
  51.       myname=argv[0];
  52.       bzero (flagseen, sizeof(flagseen)); /* aint seen nothing yet */
  53.       out_file_name    = "a.out";    /* default .o file */
  54. +     module_name = "unknown.s";
  55.       symbol_begin();        /* symbols.c */
  56.       subsegs_begin();        /* subsegs.c */
  57.       read_begin();            /* read.c */
  58. *** gas-1.38/as.h    Thu Oct 11 11:26:18 1990
  59. --- as.h    Wed Jul 10 09:01:58 1991
  60. ***************
  61. *** 286,291 ****
  62. --- 286,292 ----
  63.   
  64.   COMMON int    need_pass_2;    /* TRUE if we need a second pass. */
  65.   
  66. + COMMON char *module_name;    /* Name given in the file directive */
  67.   
  68.   #endif                /* #ifdef asH */
  69.   
  70. *** gas-1.38/config.h
  71. --- config.h    Wed Jul 10 09:16:07 1991
  72. ***************
  73. *** 0 ****
  74. --- 1 ----
  75. + #define XENIX
  76. *** gas-1.38/msomf.h
  77. --- msomf.h    Wed Jul 10 09:02:22 1991
  78. ***************
  79. *** 0 ****
  80. --- 1,24 ----
  81. + /* Segment indexes for segdefs */
  82. + #define SDEF_TEXT    1
  83. + #define SDEF_DATA    2
  84. + #define SDEF_CONST    3
  85. + #define SDEF_BSS    4
  86. + #define SDEF_SYMBOLS    5
  87. + #define SDEF_TYPES    6
  88. + #define SDEF_SIZE    4
  89. + #define SDEF_G_SIZE    6
  90. + #define GDEF_DGROUP    1
  91. + #define I386        1
  92. + #define FRAME_THREAD    1
  93. + #define TARGET_THREAD    0
  94. + #define TEXT_FRAME_THREAD    0
  95. + #define DGROUP_FRAME_THREAD    1
  96. + #define CONST_TGT_THREAD    0
  97. + #define DATA_TGT_THREAD        1
  98. + #define TEXT_TGT_THREAD        2
  99. + #define BSS_TGT_THREAD        3
  100. *** gas-1.38/omfwrite.c
  101. --- omfwrite.c    Wed Jul 10 09:02:24 1991
  102. ***************
  103. *** 0 ****
  104. --- 1,672 ----
  105. + /* write.c - emit .o file - Copyright(C)1986 Free Software Foundation, Inc.
  106. +    Copyright (C) 1986,1987 Free Software Foundation, Inc.
  107. + This file is part of GAS, the GNU Assembler.
  108. + GAS is free software; you can redistribute it and/or modify
  109. + it under the terms of the GNU General Public License as published by
  110. + the Free Software Foundation; either version 1, or (at your option)
  111. + any later version.
  112. + GAS is distributed in the hope that it will be useful,
  113. + but WITHOUT ANY WARRANTY; without even the implied warranty of
  114. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  115. + GNU General Public License for more details.
  116. + You should have received a copy of the GNU General Public License
  117. + along with GAS; see the file COPYING.  If not, write to
  118. + the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  119. + #include "as.h"
  120. + #include "md.h"
  121. + #include "subsegs.h"
  122. + #include "obstack.h"
  123. + #include "struc-symbol.h"
  124. + #include "write.h"
  125. + #include "symbols.h"
  126. + #include "xenixomf.h"
  127. + #include "msomf.h"
  128. + #if __STDC__
  129. + #include <stddef.h>
  130. + #else
  131. + #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
  132. + #endif
  133. + void    append();
  134. + /*
  135. +  * In: length of relocation (or of address) in chars: 1, 2 or 4.
  136. +  * Out: OMF LOC type.
  137. +  */
  138. + static unsigned char nbytes_r_length [] = {
  139. +   15, LOC_LOBYTE, LOC_OFFSET, 15, LOC_OFFSET32
  140. +   };
  141. + static struct frag *    text_frag_root;
  142. + static struct frag *    data_frag_root;
  143. + static struct frag *    text_last_frag;    /* Last frag in segment. */
  144. + static struct frag *    data_last_frag;    /* Last frag in segment. */
  145. + static struct exec    the_exec;
  146. + static long int string_byte_count;
  147. + static long int stab_symbol_count;
  148. + void    relax_segment();
  149. + long int    fixup_segment();
  150. + static void threads(type, trgt_thrd, frm_thrd)
  151. + int type;
  152. + int *trgt_thrd, *frm_thrd;
  153. + {
  154. +       switch (type)
  155. +       {
  156. +         case PRIVDATA:    *trgt_thrd = DATA_TGT_THREAD;
  157. +                 *frm_thrd = DGROUP_FRAME_THREAD;
  158. +                 break;
  159. +         case PRIVBSS:    *trgt_thrd = BSS_TGT_THREAD;
  160. +                 *frm_thrd = DGROUP_FRAME_THREAD;
  161. +                 break;
  162. +         case PRIVTEXT:    *trgt_thrd = TEXT_TGT_THREAD;
  163. +                 *frm_thrd = TEXT_FRAME_THREAD;
  164. +                 break;
  165. +         case PUBLICDATA:    *trgt_thrd = DATA_TGT_THREAD;
  166. +                 *frm_thrd = DGROUP_FRAME_THREAD;
  167. +                 break;
  168. +         case PUBLICTEXT:    *trgt_thrd = TEXT_TGT_THREAD;
  169. +                 *frm_thrd = TEXT_FRAME_THREAD;
  170. +                 break;
  171. +         default:        *trgt_thrd = CONST_TGT_THREAD;
  172. +                 *frm_thrd = DGROUP_FRAME_THREAD;
  173. +                 break;
  174. +       }
  175. + }
  176. + void
  177. + write_object_file()
  178. + {
  179. +   register struct frchain *    frchainP; /* Track along all frchains. */
  180. +   register fragS *        fragP;    /* Track along all frags. */
  181. +   register struct frchain *    next_frchainP;
  182. +   register fragS * *        prev_fragPP;
  183. +   register char *        name;
  184. +   register symbolS *        symbolP;
  185. +   register symbolS **        symbolPP;
  186. +   /* register fixS *        fixP; JF unused */
  187. +   unsigned long
  188. +       text_siz,
  189. +     data_siz,
  190. +     syms_siz,
  191. +     tr_siz,
  192. +     dr_siz;
  193. +   void output_file_create();
  194. +   void output_file_append();
  195. +   void output_file_close();
  196. +   extern long omagic;        /* JF magic # to write out.  Is different for
  197. +                    Suns and Vaxen and other boxes */
  198. +   /*
  199. +    * After every sub-segment, we fake an ".align ...". This conforms to BSD4.2
  200. +    * brane-damage. We then fake ".fill 0" because that is the kind of frag
  201. +    * that requires least thought. ".align" frags like to have a following
  202. +    * frag since that makes calculating their intended length trivial.
  203. +    */
  204. + #define SUB_SEGMENT_ALIGN (2)
  205. +   for ( frchainP=frchain_root; frchainP; frchainP=frchainP->frch_next )
  206. +     {
  207. +       subseg_new (frchainP -> frch_seg, frchainP -> frch_subseg);
  208. +       frag_align (SUB_SEGMENT_ALIGN, 0);
  209. +                 /* frag_align will have left a new frag. */
  210. +                 /* Use this last frag for an empty ".fill". */
  211. +       /*
  212. +        * For this segment ...
  213. +        * Create a last frag. Do not leave a "being filled in frag".
  214. +        */
  215. +       frag_wane (frag_now);
  216. +       frag_now -> fr_fix    = 0;
  217. +       know( frag_now -> fr_next == NULL );
  218. +       /* know( frags . obstack_c_base == frags . obstack_c_next_free ); */
  219. +       /* Above shows we haven't left a half-completed object on obstack. */
  220. +     }
  221. +   /*
  222. +    * From now on, we don't care about sub-segments.
  223. +    * Build one frag chain for each segment. Linked thru fr_next.
  224. +    * We know that there is at least 1 text frchain & at least 1 data frchain.
  225. +    */
  226. +   prev_fragPP = &text_frag_root;
  227. +   for ( frchainP=frchain_root; frchainP; frchainP=next_frchainP )
  228. +     {
  229. +       know( frchainP -> frch_root );
  230. +       * prev_fragPP = frchainP -> frch_root;
  231. +       prev_fragPP = & frchainP -> frch_last -> fr_next;
  232. +       if (   ((next_frchainP = frchainP->frch_next) == NULL)
  233. +       || next_frchainP == data0_frchainP)
  234. +     {
  235. +       prev_fragPP = & data_frag_root;
  236. +       if ( next_frchainP )
  237. +         {
  238. +           text_last_frag = frchainP -> frch_last;
  239. +         }
  240. +       else
  241. +         {
  242. +           data_last_frag = frchainP -> frch_last;
  243. +         }
  244. +     }
  245. +     }                /* for(each struct frchain) */
  246. +   relax_segment (text_frag_root, SEG_TEXT);
  247. +   relax_segment (data_frag_root, SEG_DATA);
  248. +   /*
  249. +    * Now the addresses of frags are correct within the segment.
  250. +    */
  251. +   text_siz=text_last_frag->fr_address;
  252. +   /*
  253. +    *
  254. +    * Determine a_data [length of data segment].
  255. +    */
  256. +   if (data_frag_root)
  257. +       data_siz=data_last_frag->fr_address;
  258. +   else
  259. +       data_siz = 0;
  260. +   bss_address_frag . fr_address = 0;
  261. +           
  262. +   /*
  263. +    *
  264. +    * Crawl the symbol chain.
  265. +    *
  266. +    * For each symbol whose value depends on a frag, take the address of
  267. +    * that frag and subsume it into the value of the symbol.
  268. +    * After this, there is just one way to lookup a symbol value.
  269. +    * Values are left in their final state for object file emission.
  270. +    * We adjust the values of 'L' local symbols, even if we do
  271. +    * not intend to emit them to the object file, because their values
  272. +    * are needed for fix-ups.
  273. +    *
  274. +    * Unless we saw a -L flag, remove all symbols that begin with 'L'
  275. +    * from the symbol chain.
  276. +    *
  277. +    * Count the (length of the nlists of the) (remaining) symbols.
  278. +    * Assign a symbol number to each symbol.
  279. +    * Count the number of string-table chars we will emit.
  280. +    *
  281. +    */
  282. +   string_byte_count = sizeof( string_byte_count );
  283. +   /* JF deal with forward references first. . . */
  284. +   for(symbolP=symbol_rootP;symbolP;symbolP=symbolP->sy_next) {
  285. +       if(symbolP->sy_forward) {
  286. +         symbolP->sy_value+=symbolP->sy_forward->sy_value+symbolP->sy_forward->sy_frag->fr_address;
  287. +         symbolP->sy_forward=0;
  288. +     }
  289. +   }
  290. +   symbolPP = & symbol_rootP;    /* -> last symbol chain link. */
  291. +   {
  292. +     register long int        symbol_number;
  293. +     symbol_number = 1;  stab_symbol_count = 0;
  294. +     while (symbolP  = * symbolPP)
  295. +       {
  296. +     name = symbolP -> sy_name;
  297. +     symbolP -> sy_value += symbolP -> sy_frag -> fr_address;
  298. +     if ( !name || (symbolP->sy_nlist.n_type&N_STAB)
  299. +         || (name[0]!='\001' && (flagseen ['L'] || name [0] != 'L' )))
  300. +       {
  301. +         if (EXTDEF(symbolP->sy_nlist.n_type))
  302. +             symbolP -> sy_number = symbol_number ++;
  303. +         else
  304. +             symbolP -> sy_number = 0;
  305. +         if (symbolP->sy_nlist.n_type&N_STAB)
  306. +         stab_symbol_count++;
  307. +         if (name && symbolP->sy_nlist.n_type&N_STAB)
  308. +           {            /* Ordinary case. */
  309. +         symbolP -> sy_name_offset = string_byte_count;
  310. +         string_byte_count += strlen (symbolP  -> sy_name) + 1;
  311. +           }
  312. +         else            /* .Stabd case. */
  313. +         symbolP -> sy_name_offset = 0;
  314. +         symbolPP = & (symbolP -> sy_next);
  315. +       }
  316. +     else
  317. +         * symbolPP = symbolP -> sy_next;
  318. +       }                /* for each symbol */
  319. +     syms_siz = sizeof( struct nlist) * symbol_number;
  320. +   }
  321. +   /*
  322. +    * Addresses of frags now reflect addresses we use in the object file.
  323. +    * Symbol values are correct.
  324. +    * Scan the frags, converting any ".org"s and ".align"s to ".fill"s.
  325. +    * Also converting any machine-dependent frags using md_convert_frag();
  326. +    */
  327. +   subseg_change( SEG_TEXT, 0);
  328. +   for (fragP = text_frag_root;  fragP;  fragP = fragP -> fr_next)
  329. +     {
  330. +       switch (fragP -> fr_type)
  331. +     {
  332. +     case rs_align:
  333. +     case rs_org:
  334. +       fragP -> fr_type = rs_fill;
  335. +       know( fragP -> fr_var == 1 );
  336. +       know( fragP -> fr_next );
  337. +       fragP -> fr_offset
  338. +         =     fragP -> fr_next -> fr_address
  339. +           -   fragP -> fr_address
  340. +         - fragP -> fr_fix;
  341. +       break;
  342. +     case rs_fill:
  343. +       break;
  344. +     case rs_machine_dependent:
  345. +       md_convert_frag (fragP);
  346. +       /*
  347. +        * After md_convert_frag, we make the frag into a ".space 0".
  348. +        * Md_convert_frag() should set up any fixSs and constants
  349. +        * required.
  350. +        */
  351. +       frag_wane (fragP);
  352. +       break;
  353. +     default:
  354. +       BAD_CASE( fragP -> fr_type );
  355. +       break;
  356. +     }            /* switch (fr_type) */
  357. +     }                /* for each frag. */
  358. +   subseg_change( SEG_DATA, 0);
  359. +   for (fragP = data_frag_root;  fragP;  fragP = fragP -> fr_next)
  360. +     {
  361. +       switch (fragP -> fr_type)
  362. +     {
  363. +     case rs_align:
  364. +     case rs_org:
  365. +       fragP -> fr_type = rs_fill;
  366. +       know( fragP -> fr_var == 1 );
  367. +       know( fragP -> fr_next );
  368. +       fragP -> fr_offset
  369. +         =     fragP -> fr_next -> fr_address
  370. +           -   fragP -> fr_address
  371. +         - fragP -> fr_fix;
  372. +       break;
  373. +     case rs_fill:
  374. +       break;
  375. +     case rs_machine_dependent:
  376. +       md_convert_frag (fragP);
  377. +       /*
  378. +        * After md_convert_frag, we make the frag into a ".space 0".
  379. +        * Md_convert_frag() should set up any fixSs and constants
  380. +        * required.
  381. +        */
  382. +       frag_wane (fragP);
  383. +       break;
  384. +     default:
  385. +       BAD_CASE( fragP -> fr_type );
  386. +       break;
  387. +     }            /* switch (fr_type) */
  388. +     }                /* for each frag. */
  389. +   subseg_change( SEG_TEXT, 0);
  390. +   fixup_segment (text_fix_root, N_TEXT);
  391. +   fixup_segment (data_fix_root, N_DATA);
  392. +   output_file_create (out_file_name);
  393. +   omf_initialize_a_out(module_name, text_siz, data_siz,
  394. +                (long) local_bss_counter, 0L,
  395. +                flagseen['g'], stab_symbol_count * sizeof(struct nlist),
  396. +                string_byte_count);
  397. + /*  Traverse the symbol chain emitting external symbol definitions
  398. +  *  for external, public and common symbols.
  399. +  */
  400. +   for (   symbolP = symbol_rootP;   symbolP;   symbolP = symbolP -> sy_next   )
  401. +   {
  402. +       if (EXTDEF(symbolP->sy_type))
  403. +       {
  404. +           if (COMMDEF(symbolP->sy_type))
  405. +           {
  406. +               omf_start_comdef();
  407. +               omf_comdef(symbolP->sy_name, TD_CNEAR, symbolP->sy_value, 0L);
  408. +               omf_end_comdef();
  409. +           }
  410. +           else
  411. +               omf_extdef(symbolP->sy_name, 0);
  412. +       }
  413. +   }
  414. + /*  Traverse the symbol chain emitting public definitions
  415. +  */
  416. +   for (   symbolP = symbol_rootP;   symbolP;   symbolP = symbolP -> sy_next   )
  417. +   {
  418. +     if (PUBLIC(symbolP->sy_type))
  419. +     {
  420. +         unsigned int group = 0, segment = 0;
  421. +         if (symbolP->sy_type == PUBLICTEXT)
  422. +             segment = SDEF_TEXT;
  423. +         if (symbolP->sy_type == PUBLICDATA)
  424. +         {
  425. +             group = GDEF_DGROUP;  segment = SDEF_DATA;
  426. +         }
  427. +         
  428. +         omf_start_pubdef(I386, group, segment, 0);
  429. +         omf_pubdef(I386, symbolP->sy_name, symbolP->sy_value, 0);
  430. +         omf_end_pubdef();
  431. +     }
  432. +   }
  433. +   
  434. +   /* Setup threads for DGROUP and the segments ready for relocation */
  435. +   omf_start_thread(I386);
  436. +   omf_thread(CONST_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_CONST);
  437. +   omf_thread(DATA_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_DATA);
  438. +   omf_thread(TEXT_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_TEXT);
  439. +   omf_thread(BSS_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_BSS);
  440. +   omf_thread(TEXT_FRAME_THREAD, FRAME_THREAD, FRM_SI, SDEF_TEXT);
  441. +   omf_thread(DGROUP_FRAME_THREAD, FRAME_THREAD, FRM_GI, GDEF_DGROUP);
  442. +   omf_end_thread();
  443. +   
  444. +   /*
  445. +    * Emit code.
  446. +    */
  447. +   for (fragP = data_frag_root;  fragP;  fragP = fragP -> fr_next)
  448. +   {
  449. +       register long int count;
  450. +       register char * fill_literal;
  451. +       register long int fill_size;
  452. +       register fixS * fixP;
  453. +       register symbolS * symbolP;
  454. +       int started_fixup;
  455. +       know( fragP -> fr_type == rs_fill );
  456. +       if (fragP->fr_fix != 0 || fragP->fr_offset != 0)
  457. +       {
  458. +           omf_start_ledata(I386, SDEF_DATA, fragP->fr_address);
  459. +           if (fragP->fr_fix != 0)
  460. +               omf_ledata(fragP->fr_literal, (int)fragP->fr_fix);
  461. +           fill_literal = fragP->fr_literal + fragP -> fr_fix;
  462. +           fill_size = fragP->fr_var;
  463. +           count = fragP -> fr_offset;
  464. +       if ((fragP->fr_fix + count * fill_size) < 1016)
  465. +       {
  466. +               for ( ; count; count--)
  467. +                   omf_ledata(fill_literal, (int)fill_size);
  468. +       }
  469. +       else  /* filling will exceed the 1024 byte record size */
  470. +       {
  471. +           /* This code assumes that fill_size <= 8 bytes.
  472. +            * This is infact the case because of
  473. +            * compatability with other assemblers 
  474. +            */
  475. +           register int fcount;
  476. +           fcount = (1016 - fragP->fr_fix) / fill_size;
  477. +           count -= fcount;
  478. +           for ( ; fcount > 0; fcount--)
  479. +                   omf_ledata(fill_literal, (int)fill_size);
  480. +           
  481. +       }
  482. +           omf_end_ledata();
  483. +           /* Emit the relocations for this frag
  484. +            */
  485. +           fixP = data_fix_root;  started_fixup = 0;
  486. +           for ( ;  fixP;  fixP = fixP -> fx_next)
  487. +           {
  488. +               if (fixP->fx_frag == fragP && (symbolP = fixP->fx_addsy))
  489. +               {
  490. +           int trgt_thrd, frm_thrd;
  491. +           int external = EXTDEF(symbolP->sy_type);
  492. +           threads(symbolP->sy_type, &trgt_thrd, &frm_thrd);
  493. +           if (fixP->fx_pcrel)
  494. +             frm_thrd = TEXT_FRAME_THREAD;
  495. +                   if (!started_fixup)
  496. +                   {
  497. +                       omf_start_fixup(I386);
  498. +                       started_fixup++;
  499. +                   }
  500. +                   omf_fixup(I386, !fixP->fx_pcrel,
  501. +                 nbytes_r_length [fixP->fx_size], fixP->fx_where,
  502. +                 external ? 0 : 1,
  503. +                 external ? FRM_TRGT : frm_thrd,
  504. +                 external ? 0 : 1,
  505. +                 external ? TGT_EI : trgt_thrd,
  506. +                 1, /* No offset */
  507. +             0, /* No frame required */
  508. +                 EXTDEF(symbolP->sy_type) ? symbolP->sy_number : 0,
  509. +             0);
  510. +           }
  511. +           }
  512. +           if (started_fixup)
  513. +               omf_end_fixup();
  514. +       
  515. +       while (count > 0)    /* still sum fill data to emit */
  516. +       {
  517. +           unsigned long address;
  518. +           unsigned int len;
  519. +               address = fragP->fr_address + fragP->fr_fix +
  520. +               (fragP->fr_offset - count) * fill_size;
  521. +               omf_start_ledata(I386, SDEF_DATA, address);
  522. +               for ( len = 0; count && (len < 1000); count--, len += fill_size)
  523. +                   omf_ledata(fill_literal, (int)fill_size);
  524. +               omf_end_ledata();
  525. +       }
  526. +       }
  527. +   }
  528. +   for (fragP = text_frag_root;  fragP;  fragP = fragP -> fr_next)
  529. +   {
  530. +       register long int count;
  531. +       register char * fill_literal;
  532. +       register long int fill_size;
  533. +       register fixS * fixP;
  534. +       register symbolS * symbolP;
  535. +       int started_fixup;
  536. +       know( fragP -> fr_type == rs_fill );
  537. +       if (fragP->fr_fix != 0 || fragP->fr_offset != 0)
  538. +       {
  539. +           omf_start_ledata(I386, SDEF_TEXT, fragP->fr_address);
  540. +           if (fragP->fr_fix != 0)
  541. +               omf_ledata(fragP->fr_literal, (int)fragP->fr_fix);
  542. +           fill_literal = fragP->fr_literal + fragP -> fr_fix;
  543. +           fill_size = fragP->fr_var;
  544. +           for (count = fragP -> fr_offset;  count;  count --)
  545. +               omf_ledata(fill_literal, (int)fill_size);
  546. +           omf_end_ledata();
  547. +           /* Emit the relocations for this frag
  548. +            */
  549. +           fixP = text_fix_root;  started_fixup = 0;
  550. +           for ( ;  fixP;  fixP = fixP -> fx_next)
  551. +           {
  552. +               if (fixP->fx_frag == fragP && (symbolP = fixP->fx_addsy))
  553. +               {
  554. +           int trgt_thrd, frm_thrd;
  555. +           int external = EXTDEF(symbolP->sy_type);
  556. +           threads(symbolP->sy_type, &trgt_thrd, &frm_thrd);
  557. +           if (fixP->fx_pcrel)
  558. +             frm_thrd = TEXT_FRAME_THREAD;
  559. +                   if (!started_fixup)
  560. +                   {
  561. +                       omf_start_fixup(I386);
  562. +                       started_fixup++;
  563. +                   }
  564. +                   omf_fixup(I386, !fixP->fx_pcrel,
  565. +                 nbytes_r_length [fixP->fx_size], fixP->fx_where,
  566. +                 external ? 0 : 1,
  567. +                 external ? FRM_TRGT : frm_thrd,
  568. +                 external ? 0 : 1,
  569. +                 external ? TGT_EI : trgt_thrd,
  570. +                 1, /* No offset */
  571. +             0, /* No frame required */
  572. +                 external ? symbolP->sy_number : 0,
  573. +             0);
  574. +           }
  575. +           }
  576. +           if (started_fixup)
  577. +               omf_end_fixup();
  578. +       }
  579. +   }
  580. + /*  Traverse the symbol chain emitting stabs.
  581. +  */
  582. + #define VAL_OFF offsetof(struct nlist, n_value)
  583. +   if (flagseen['g'] && stab_symbol_count)
  584. +   {   
  585. +       long count = 0, ncount = 0;
  586. +       symbolS *last_startP;
  587. +       char *temp;
  588. +       symbolS *fsymP;
  589. +       int i;
  590. +       int start_fixup = 0;
  591. +       omf_start_ledata(I386, SDEF_SYMBOLS, 0);
  592. +       last_startP = symbol_rootP;
  593. +       for (symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next)
  594. +       {
  595. +      if (symbolP->sy_nlist.n_type & N_STAB)
  596. +      {
  597. +             if ((ncount + 1) * sizeof(struct nlist) >= 1016)
  598. +             {
  599. +                omf_end_ledata();
  600. +                /* emit relocations */
  601. +                start_fixup = 0;
  602. +            for (i = 0, fsymP=last_startP; i < ncount; fsymP=fsymP->sy_next)
  603. +            {
  604. +               if (fsymP->sy_nlist.n_type & N_STAB)
  605. +           {
  606. +                      if (fsymP->sy_type & N_TYPE) /* if relocation required */
  607. +              {
  608. +                int trgt_thrd, frm_thrd;
  609. +                int external = EXTDEF(fsymP->sy_type & N_TYPE);
  610. +                threads(fsymP->sy_type & N_TYPE,&trgt_thrd,&frm_thrd);
  611. +                if (!start_fixup)
  612. +                {
  613. +                            omf_start_fixup(I386);
  614. +                start_fixup++;
  615. +                }
  616. +                omf_fixup(I386, 1, /* segment relative */
  617. +                   LOC_OFFSET32, i * sizeof(struct nlist) + VAL_OFF,
  618. +                   external ? 0 : 1,
  619. +                   external ? FRM_TRGT : frm_thrd,
  620. +                   external ? 0 : 1,
  621. +                   external ? TGT_EI : trgt_thrd,
  622. +                   1, /* No offset */
  623. +               0, /* No frame required */
  624. +                   external ? fsymP->sy_number : 0,
  625. +               0);
  626. +              }
  627. +              i++;
  628. +           }
  629. +            }
  630. +            if (start_fixup)
  631. +                   omf_end_fixup();
  632. +                /* start new segment */
  633. +                ncount = 0;  last_startP = symbolP;
  634. +                omf_start_ledata(I386, SDEF_SYMBOLS, count*sizeof(struct nlist));
  635. +             }
  636. +             temp = symbolP->sy_nlist.n_un.n_name;
  637. +             symbolP->sy_nlist.n_un.n_strx = symbolP->sy_name_offset;
  638. +             omf_ledata(&(symbolP->sy_nlist), sizeof(struct nlist));
  639. +             symbolP->sy_nlist.n_un.n_name = temp;
  640. +            ncount++;  count++;
  641. +      }
  642. +       }
  643. +       omf_end_ledata();
  644. +       start_fixup = 0;
  645. +       for (i = 0, fsymP = last_startP; i < ncount; fsymP = fsymP->sy_next)
  646. +       {
  647. +          if (fsymP->sy_nlist.n_type & N_STAB)
  648. +      {
  649. +             if (fsymP->sy_type & N_TYPE) /* if relocation required */
  650. +         {
  651. +           int trgt_thrd, frm_thrd;
  652. +           int external = EXTDEF(fsymP->sy_type & N_TYPE);
  653. +           threads(fsymP->sy_type & N_TYPE,&trgt_thrd,&frm_thrd);
  654. +           if (!start_fixup)
  655. +               {
  656. +                  omf_start_fixup(I386);
  657. +                  start_fixup++;
  658. +               }
  659. +           omf_fixup(I386, 1, /* segment relative */
  660. +              LOC_OFFSET32, i * sizeof(struct nlist) + VAL_OFF,
  661. +              external ? 0 : 1,
  662. +              external ? FRM_TRGT : frm_thrd,
  663. +              external ? 0 : 1,
  664. +              external ? TGT_EI : trgt_thrd,
  665. +              1, /* No offset */
  666. +                   0, /* No frame required */
  667. +              external ? fsymP->sy_number : 0,
  668. +           0);
  669. +         }
  670. +         i++;
  671. +      }
  672. +       }
  673. +       if (start_fixup)
  674. +          omf_end_fixup();
  675. +       count = sizeof(string_byte_count);  ncount = count;
  676. +       omf_start_ledata(I386, SDEF_TYPES, 0);
  677. +       omf_ledata(&string_byte_count, sizeof(string_byte_count));
  678. +       for (symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next)
  679. +       {
  680. +          if (symbolP->sy_nlist.n_type & N_STAB && symbolP -> sy_name)
  681. +      {
  682. +         int len = strlen(symbolP -> sy_name) + 1;
  683. +         if (ncount + len > 1016)
  684. +         {
  685. +            omf_end_ledata();
  686. +                omf_start_ledata(I386, SDEF_TYPES, count);
  687. +            ncount = 0;
  688. +         }
  689. +             omf_ledata(symbolP->sy_name, len);
  690. +         count += len;  ncount += len;
  691. +      }
  692. +       }
  693. +       omf_end_ledata();
  694. +   }
  695. +   
  696. +   omf_modend(I386);
  697. +   output_file_close (out_file_name);
  698. + }                /* write_object_file() */
  699. *** gas-1.38/read.c    Tue Oct 30 13:42:03 1990
  700. --- read.c    Wed Jul 10 12:53:36 1991
  701. ***************
  702. *** 711,717 ****
  703.       int    length;
  704.   
  705.       /* Some assemblers tolerate immediately following '"' */
  706. !     if ( s = demand_copy_string( & length ) ) {
  707.           new_logical_line (s, -1);
  708.           demand_empty_rest_of_line();
  709.       }
  710. --- 711,718 ----
  711.       int    length;
  712.   
  713.       /* Some assemblers tolerate immediately following '"' */
  714. !     if ( s = demand_copy_C_string( & length ) ) {
  715. !         module_name = s;
  716.           new_logical_line (s, -1);
  717.           demand_empty_rest_of_line();
  718.       }
  719. ***************
  720. *** 1697,1703 ****
  721.   void    /* JF was static, but can't be if VAX.C is goning to use it */
  722.   float_cons(float_type)        /* Worker to do .float etc statements. */
  723.                   /* Clobbers input_line-pointer, checks end-of-line. */
  724. !      register float_type;    /* 'f':.ffloat ... 'F':.float ... */
  725.   {
  726.     register char *    p;
  727.     register char        c;
  728. --- 1698,1704 ----
  729.   void    /* JF was static, but can't be if VAX.C is goning to use it */
  730.   float_cons(float_type)        /* Worker to do .float etc statements. */
  731.                   /* Clobbers input_line-pointer, checks end-of-line. */
  732. !      register int float_type;    /* 'f':.ffloat ... 'F':.float ... */
  733.   {
  734.     register char *    p;
  735.     register char        c;
  736. *** gas-1.38/subsegs.c    Thu Oct 11 11:26:23 1990
  737. --- subsegs.c    Wed Jul 10 09:02:02 1991
  738. ***************
  739. *** 96,102 ****
  740. --- 96,106 ----
  741.     know( SEG_MAXIMUM_ORDINAL == SEG_DIFFERENCE );
  742.     know( seg_name [(int) SEG_MAXIMUM_ORDINAL + 1] [0] == 0 );
  743.   
  744. + #ifdef M_XENIX
  745. +   obstack_begin( &frags, 1000);
  746. + #else
  747.     obstack_begin( &frags, 5000);
  748. + #endif /* M_XENIX */
  749.     frchain_root = NULL;
  750.     frchain_now  = NULL;        /* Warn new_subseg() that we are booting. */
  751.                   /* Fake up 1st frag. */
  752. *** gas-1.38/write.c    Thu Oct 11 11:26:15 1990
  753. --- write.c    Wed Jul 10 09:06:47 1991
  754. ***************
  755. *** 38,43 ****
  756. --- 38,46 ----
  757.   #include "write.h"
  758.   #include "symbols.h"
  759.   
  760. + static relax_addressT    relax_align();
  761. + #ifndef M_XENIX
  762.   #ifdef SPARC
  763.   #include "sparc.h"
  764.   #endif
  765. ***************
  766. *** 93,103 ****
  767.   
  768.   static void    relax_segment();
  769.   void        emit_segment();
  770. - static relax_addressT    relax_align();
  771.   static long int    fixup_segment();
  772.   #if !defined(SPARC) && !defined(I860)
  773.   static void        emit_relocations();
  774.   #endif
  775.    /*
  776.    *            fix_new()
  777.    *
  778. --- 96,107 ----
  779.   
  780.   static void    relax_segment();
  781.   void        emit_segment();
  782.   static long int    fixup_segment();
  783.   #if !defined(SPARC) && !defined(I860)
  784.   static void        emit_relocations();
  785.   #endif
  786. + #endif /* M_XENIX */
  787.    /*
  788.    *            fix_new()
  789.    *
  790. ***************
  791. *** 146,151 ****
  792. --- 150,156 ----
  793.     * seg_fix_rootP = fixP;
  794.   }
  795.   
  796. + #ifndef M_XENIX
  797.   void
  798.   write_object_file()
  799.   {
  800. ***************
  801. *** 683,688 ****
  802. --- 688,694 ----
  803.     VMS_write_object_file(text_siz, data_siz, text_frag_root, data_frag_root);
  804.   #endif    /* VMS */
  805.   }                /* write_object_file() */
  806. + #endif /* M_XENIX */
  807.   
  808.   /*
  809.    *            relax_segment()
  810. ***************
  811. *** 697,703 ****
  812. --- 703,711 ----
  813.    * these frag addresses may not be the same as final object-file addresses.
  814.    */
  815.   #ifndef    VMS
  816. + #ifndef M_XENIX
  817.   static
  818. + #endif    /* not M_XENIX */
  819.   #endif    /* not VMS */
  820.   void
  821.   relax_segment (segment_frag_root, segment_type)
  822. ***************
  823. *** 1010,1016 ****
  824.   /*
  825.    *            fixup_segment()
  826.    */
  827. ! static long int
  828.   fixup_segment (fixP, this_segment_type)
  829.        register fixS *    fixP;
  830.        int        this_segment_type; /* N_TYPE bits for segment. */
  831. --- 1018,1027 ----
  832.   /*
  833.    *            fixup_segment()
  834.    */
  835. ! #ifndef M_XENIX 
  836. ! static
  837. ! #endif /* not M_XENIX */
  838. ! long int
  839.   fixup_segment (fixP, this_segment_type)
  840.        register fixS *    fixP;
  841.        int        this_segment_type; /* N_TYPE bits for segment. */
  842. ***************
  843. *** 1137,1142 ****
  844. --- 1148,1156 ----
  845.       }            /* if there was a + symbol */
  846.         if (pcrel)
  847.       {
  848. + #ifdef M_XENIX
  849. +       if (add_symbol_N_TYPE != N_UNDF)
  850. + #endif
  851.         add_number -=
  852.   #ifndef NS32K
  853.             size + 
  854. ***************
  855. *** 1184,1189 ****
  856. --- 1198,1204 ----
  857.   }                /* fixup_segment() */
  858.   
  859.   
  860. + #ifndef M_XENIX
  861.   /* The sparc needs its own emit_relocations() */
  862.   #if !defined(SPARC) && !defined(I860)
  863.   /*
  864. ***************
  865. *** 1244,1249 ****
  866. --- 1259,1265 ----
  867.   
  868.   }
  869.   #endif
  870. + #endif /* M_XENIX */
  871.   
  872.   int
  873.   is_dnrange(f1,f2)
  874. *** gas-1.38/xenixomf.c
  875. --- xenixomf.c    Wed Jul 10 09:02:18 1991
  876. ***************
  877. *** 0 ****
  878. --- 1,660 ----
  879. + #include <string.h>
  880. + #include <stdio.h>
  881. + #include "xenixomf.h"
  882. + #include "msomf.h"
  883. + #ifdef M_XENIX
  884. + #  undef i386
  885. + #endif
  886. + #define MAXRECORDSIZE    (14 * 1024)    /* 1k data => 1024 fixups */
  887. + #define I386    1
  888. + extern char *out_file_name;
  889. + static char chksum = 0;
  890. + static unsigned char recordbuff[MAXRECORDSIZE];
  891. + static unsigned char *record_ptr;
  892. + static void copy_bytes_to_record(p, count)
  893. + unsigned char *p;
  894. + int count;
  895. + {
  896. +     while (count--)
  897. +     {
  898. +         *record_ptr++ = *p;
  899. +         chksum += *p++;
  900. +     }
  901. + }
  902. + static void start_record(type)
  903. + unsigned char type;
  904. + {
  905. +     chksum = 0;
  906. +     record_ptr = recordbuff;
  907. +     copy_bytes_to_record(&type, 1);
  908. +     record_ptr += 2;    /* leave space for the record size */
  909. + }
  910. + static void output_record()
  911. + {
  912. +     int length;
  913. +     unsigned char b;
  914. +     length = (record_ptr - recordbuff) + 1; /* 1 for chksum */
  915. +     /* patch the record length into the header and put -chksum
  916. +      * at the end of the record.
  917. +      */
  918. +     b = (length - 3) & 0xff;  /* -3 as record length excludes type + len */
  919. +     chksum += b;  recordbuff[1] = b;
  920. +     b = ((length - 3) >> 8) & 0xff;
  921. +     chksum += b;  recordbuff[2] = b;
  922. +     *record_ptr = (unsigned char)(-chksum);
  923. +     output_file_append (recordbuff, length, out_file_name);
  924. + }
  925. + static void copy_string_to_record(s)
  926. + char *s;
  927. + {
  928. +     unsigned char len;
  929. +     len = strlen(s);
  930. +     if (len > OMFNAMELENGTH)
  931. +     {
  932. +         char tname[OMFNAMELENGTH+2];
  933. +         strncpy(tname, s, OMFNAMELENGTH);
  934. +         tname[OMFNAMELENGTH] = '\0';
  935. +         fprintf(stderr, "Identifier truncated to %s (%d chars)\n",
  936. +                 tname, OMFNAMELENGTH);
  937. +         len = OMFNAMELENGTH;
  938. +         copy_bytes_to_record(&len, 1);
  939. +         copy_bytes_to_record(s, OMFNAMELENGTH);
  940. +     }
  941. +     else
  942. +     {
  943. +         copy_bytes_to_record(&len, 1);
  944. +         if (len > 0)
  945. +             copy_bytes_to_record(s, len);
  946. +     }
  947. + }
  948. + static void copy_index_to_record(index)
  949. + unsigned int index;
  950. + {
  951. +     unsigned char b;
  952. +     if (index < 128)
  953. +     {
  954. +         b = (unsigned char)(index & 0xff);
  955. +         copy_bytes_to_record(&b, 1);
  956. +     }
  957. +     else
  958. +     {
  959. +         b = (unsigned char)(((index >> 8) & 0xff) | 0x80);
  960. +         copy_bytes_to_record(&b, 1);
  961. +         b = (unsigned char)(index & 0xff);
  962. +         copy_bytes_to_record(&b, 1);
  963. +     }
  964. + }
  965. + static void copy_vint_to_record(value, count)
  966. + long value;
  967. + int count;
  968. + {
  969. +     unsigned char b;
  970. +     while (count--)
  971. +     {
  972. +         b = (unsigned char)(value & 0xff);
  973. +         copy_bytes_to_record(&b, 1);
  974. +         value >>= 8;
  975. +     }
  976. + }
  977. + static void copy_word_to_record(value)
  978. + unsigned int value;
  979. + {
  980. +     copy_vint_to_record((long)value, 2);
  981. + }
  982. + static void copy_offset_to_record(i386, value)
  983. + int i386;
  984. + long value;
  985. + {
  986. +     copy_vint_to_record(value, i386 ? 4 : 2);
  987. + }
  988. + static void copy_comsize_to_record(value)
  989. + long value;
  990. + {
  991. +     unsigned char b;
  992. +     if (value < 128)
  993. +         copy_vint_to_record((long)value, 1);
  994. +     else if (value < 65536L)
  995. +     {
  996. +         b = 0x81;
  997. +         copy_bytes_to_record(&b, 1);
  998. +         copy_vint_to_record((long)value, 2);
  999. +     }
  1000. +     else if (value < 16777216L)
  1001. +     {
  1002. +         b = 0x84;
  1003. +         copy_bytes_to_record(&b, 1);
  1004. +         copy_vint_to_record((long)value, 3);
  1005. +     }
  1006. +     else
  1007. +     {
  1008. +         b = 0x88;
  1009. +         copy_bytes_to_record(&b, 1);
  1010. +         copy_vint_to_record((long)value, 4);
  1011. +     }
  1012. + }
  1013. + void omf_theadr(name)
  1014. + unsigned char *name;
  1015. + {
  1016. +     start_record(MTHEADR);
  1017. +     copy_string_to_record(name);
  1018. +     output_record();
  1019. + }
  1020. + void omf_coment(p, count, class)
  1021. + unsigned char *p;
  1022. + int count;
  1023. + unsigned char class;
  1024. + {
  1025. +     unsigned char attrib;
  1026. +     start_record(MCOMENT);
  1027. +     attrib = 0;        /* Purge and List attributes */
  1028. +     copy_bytes_to_record(&attrib, 1);
  1029. +     copy_bytes_to_record(&class, 1);
  1030. +     copy_bytes_to_record(p, count);
  1031. +     output_record();
  1032. + }
  1033. + void omf_extdef(name, type)
  1034. + unsigned char *name;
  1035. + {
  1036. +     start_record(MEXTDEF);
  1037. +     copy_string_to_record(name);
  1038. +     copy_bytes_to_record(&type, 1);
  1039. +     output_record();
  1040. + }
  1041. + void omf_start_pubdef(i386, group, segment, frame)
  1042. + int i386;
  1043. + int group, segment, frame;
  1044. + {
  1045. +     if (i386)
  1046. +         start_record(MPUB386);
  1047. +     else
  1048. +         start_record(MPUBDEF);
  1049. +     copy_index_to_record(group);
  1050. +     copy_index_to_record(segment);
  1051. +     if (group == 0 && segment == 0)
  1052. +         copy_word_to_record(frame);
  1053. + }
  1054. + void omf_pubdef(i386, name, offset, type)
  1055. + int i386;
  1056. + unsigned char *name;
  1057. + int type;
  1058. + long offset;
  1059. + {
  1060. +     copy_string_to_record(name);
  1061. +     copy_offset_to_record(i386, offset);
  1062. +     copy_index_to_record(type);
  1063. + }
  1064. + void omf_end_pubdef()
  1065. + {
  1066. +     output_record();
  1067. + }
  1068. + void omf_start_lnames()
  1069. + {
  1070. +     start_record(MLNAMES);
  1071. + }
  1072. + void omf_lnames(name)
  1073. + unsigned char *name;
  1074. + {
  1075. +     copy_string_to_record(name);
  1076. + }
  1077. + void omf_end_lnames()
  1078. + {
  1079. +     output_record();
  1080. + }
  1081. + void omf_segdef(i386, acbp, frame, offset, seglen, segname, segclass)
  1082. + int i386;
  1083. + unsigned char acbp;
  1084. + unsigned int frame;
  1085. + unsigned int offset;
  1086. + long seglen;
  1087. + unsigned int segname, segclass;
  1088. + {
  1089. +     unsigned int ovlindex = 0;
  1090. +     if (i386)
  1091. +         start_record(MSEG386);
  1092. +     else
  1093. +         start_record(MSEGDEF);
  1094. +     copy_bytes_to_record(&acbp, 1);
  1095. +     if ((acbp & SD_ALIGN) == SD_ABS)
  1096. +     {
  1097. +         copy_word_to_record(frame);
  1098. +         copy_word_to_record(offset);  /* should be byte - Fix Me */
  1099. +     }
  1100. +     copy_offset_to_record(i386, seglen);
  1101. +     copy_index_to_record(segname);
  1102. +     copy_index_to_record(segclass);
  1103. +     copy_index_to_record(ovlindex);
  1104. +     output_record();
  1105. + }
  1106. + void omf_start_grpdef(grpname)
  1107. + unsigned int grpname;
  1108. + {
  1109. +     start_record(MGRPDEF);
  1110. +     copy_index_to_record(grpname);
  1111. + }
  1112. + void omf_grpdef(segindex)
  1113. + unsigned int segindex;
  1114. + {
  1115. +     unsigned char b = 0xff;
  1116. +     copy_bytes_to_record(&b, 1);
  1117. +     copy_index_to_record(segindex);
  1118. + }
  1119. + void omf_end_grpdef()
  1120. + {
  1121. +     output_record();
  1122. + }
  1123. + void omf_start_comdef()
  1124. + {
  1125. +     start_record(MCOMDEF);
  1126. + }
  1127. + void omf_comdef(name, dataseg_type, length, el_size)
  1128. + unsigned char *name;
  1129. + unsigned char dataseg_type;
  1130. + {
  1131. +     unsigned char type = 0;
  1132. +     copy_string_to_record(name);
  1133. +     copy_bytes_to_record(&type, 1);
  1134. +     copy_bytes_to_record(&dataseg_type, 1);
  1135. +     copy_comsize_to_record(length);
  1136. +     if (dataseg_type == TD_CFAR)
  1137. +     {
  1138. +         copy_comsize_to_record(el_size);
  1139. +     }
  1140. + }
  1141. + void omf_end_comdef()
  1142. + {
  1143. +     output_record();
  1144. + }
  1145. + void omf_start_linnum(i386, segindex)
  1146. + {
  1147. +     unsigned char grpindex = 0;
  1148. +     if (i386)
  1149. +         start_record(MLIN386);
  1150. +     else
  1151. +         start_record(MLINNUM);
  1152. +     copy_bytes_to_record(&grpindex, 1);
  1153. +     copy_index_to_record(segindex);
  1154. + }
  1155. + void omf_linnum(i386, line, offset)
  1156. + int i386;
  1157. + unsigned int line;
  1158. + long offset;
  1159. + {
  1160. +     copy_word_to_record(line);
  1161. +     copy_offset_to_record(i386, offset);
  1162. + }
  1163. + void omf_end_linnum()
  1164. + {
  1165. +     output_record();
  1166. + }
  1167. + void omf_start_thread(i386)
  1168. + {
  1169. +     if (i386)
  1170. +         start_record(MFIX386);
  1171. +     else
  1172. +         start_record(MFIXUPP);
  1173. + }
  1174. + void omf_thread(thread, framethread, method, index)
  1175. + unsigned char thread;
  1176. + int framethread;
  1177. + unsigned char method;
  1178. + unsigned int index;
  1179. + {
  1180. +     unsigned char thread_data;
  1181. +     thread_data = thread | (method << TRD_MTHDSHFT);
  1182. +     if (framethread)
  1183. +         thread_data |= TRD_FRAME;
  1184. +     copy_bytes_to_record(&thread_data, 1);
  1185. +     if (framethread)
  1186. +     {
  1187. +         switch (method)
  1188. +         {
  1189. +         case FRM_SI:
  1190. +         case FRM_GI:
  1191. +         case FRM_EI:
  1192. +         case FRM_ABS:
  1193. +             copy_index_to_record(index);
  1194. +             break;
  1195. +         case FRM_LOC:
  1196. +         case FRM_TRGT:
  1197. +             break;
  1198. +         }
  1199. +     }
  1200. +     else
  1201. +         copy_index_to_record(index);
  1202. + }
  1203. + void omf_end_thread()
  1204. + {
  1205. +     output_record();
  1206. + }
  1207. + void omf_start_fixup(i386)
  1208. + {
  1209. +     if (i386)
  1210. +         start_record(MFIX386);
  1211. +     else
  1212. +         start_record(MFIXUPP);
  1213. + }
  1214. + static void generate_fixdat(i386, f_thrd, frame, t_thrd, trgt, t_sec,
  1215. +                        frame_index, target_index, offset)
  1216. + int i386;
  1217. + int f_thrd;
  1218. + unsigned int frame;
  1219. + int t_thrd;
  1220. + unsigned int trgt;
  1221. + int t_sec;
  1222. + unsigned int frame_index, target_index;
  1223. + long offset;
  1224. + {
  1225. +     unsigned char fixdat, b;
  1226. +     fixdat = (f_thrd ? FIXDAT_FTHRD : 0) | (frame << FIXDAT_FRSHFT);
  1227. +     fixdat |= (t_thrd ? FIXDAT_TTHRD : 0) | trgt | (t_sec ? FIXDAT_TSCND:0);
  1228. +     copy_bytes_to_record(&fixdat, 1);
  1229. +     if (!f_thrd)
  1230. +     {
  1231. +         switch (frame)
  1232. +         {
  1233. +         case FRM_SI:
  1234. +         case FRM_GI:
  1235. +         case FRM_EI:
  1236. +         case FRM_ABS:
  1237. +             copy_index_to_record(frame_index);
  1238. +             break;
  1239. +         case FRM_LOC:
  1240. +         case FRM_TRGT:
  1241. +             break;
  1242. +         }
  1243. +     }
  1244. +     if (!t_thrd)
  1245. +         copy_index_to_record(target_index);
  1246. +     
  1247. +     if (!t_sec)
  1248. +         copy_offset_to_record(i386, offset);
  1249. + }
  1250. + void omf_fixup(i386, segrel, loc, data_off, f_thrd, frame, t_thrd, trgt, t_sec,
  1251. +            frame_index, target_index, offset)
  1252. + int i386, segrel;
  1253. + unsigned char loc;
  1254. + unsigned int data_off;
  1255. + int f_thrd;
  1256. + unsigned int frame;
  1257. + int t_thrd;
  1258. + unsigned int trgt;
  1259. + int t_sec;
  1260. + unsigned int frame_index, target_index;
  1261. + long offset;
  1262. + {
  1263. +     unsigned int locat = 0x8000;
  1264. +     unsigned char fixdat, b;
  1265. +     locat |= (segrel ? FIX_SEG : 0) | (loc << FIX_LOCSHFT) |
  1266. +          (data_off & FIX_DATAOFF);
  1267. +     b = (locat >> 8) & 0xff;  copy_bytes_to_record(&b, 1);
  1268. +     b = locat & 0xff;  copy_bytes_to_record(&b, 1);
  1269. +     generate_fixdat(i386, f_thrd, frame, t_thrd, trgt, t_sec, frame_index,
  1270. +             target_index, offset);
  1271. + }
  1272. + void omf_end_fixup()
  1273. + {
  1274. +     output_record();
  1275. + }
  1276. + void omf_start_ledata(i386, segindex, start_offset)
  1277. + int i386;
  1278. + unsigned int segindex;
  1279. + long start_offset;
  1280. + {
  1281. +     if (i386)
  1282. +         start_record(MLED386);
  1283. +     else
  1284. +         start_record(MLEDATA);
  1285. +     copy_index_to_record(segindex);
  1286. +     copy_offset_to_record(i386, start_offset);
  1287. + }
  1288. + void omf_ledata(data, count)
  1289. + unsigned char *data;
  1290. + int count;
  1291. + {
  1292. +     copy_bytes_to_record(data, count);
  1293. +     
  1294. + }
  1295. + void omf_end_ledata()
  1296. + {
  1297. +     output_record();
  1298. + }
  1299. + void omf_main_modend(i386, f_thrd, frame, t_thrd, trgt, t_sec, frame_index,
  1300. +              target_index, offset)
  1301. + int i386;
  1302. + int f_thrd;
  1303. + unsigned int frame;
  1304. + int t_thrd;
  1305. + unsigned int trgt;
  1306. + int t_sec;
  1307. + unsigned int frame_index, target_index;
  1308. + long offset;
  1309. + {
  1310. +     unsigned char mtype = 0xc1;
  1311. +     if (i386)
  1312. +         start_record(M386END);
  1313. +     else
  1314. +         start_record(MMODEND);
  1315. +     copy_bytes_to_record(&mtype, 1);
  1316. +     generate_fixdat(i386, f_thrd, frame, t_thrd, trgt, t_sec, frame_index,
  1317. +             target_index, offset);
  1318. +     output_record();
  1319. + }
  1320. + void omf_modend(i386)
  1321. + int i386;
  1322. + {
  1323. +     unsigned char mtype = 0;
  1324. +     if (i386)
  1325. +         start_record(M386END);
  1326. +     else
  1327. +         start_record(MMODEND);
  1328. +     copy_bytes_to_record(&mtype, 1);
  1329. +     output_record();
  1330. + }
  1331. + /** Definitions required to produce a standard Microsoft .o file
  1332. +  */
  1333. + /** LNAMES, SEGDEF, GRPDEF and COMENT stuff
  1334. +  *
  1335. +  *  NB the following defines must reflect the position of the string in
  1336. +  *  the lnames_tab table.
  1337. +  */
  1338. + #define    L_BLANK        1
  1339. + #define    L_DGROUP    2
  1340. + #define L_UTEXT        3
  1341. + #define L_CODE        4
  1342. + #define L_UDATA        5
  1343. + #define L_DATA        6
  1344. + #define L_CONST        7
  1345. + #define L_UBSS        8
  1346. + #define L_BSS        9
  1347. + #define L_TYPES        10
  1348. + #define L_DEBTYP    11
  1349. + #define L_SYMBOLS    12
  1350. + #define L_DEBSYM    13
  1351. + #define L_TSIZE        9
  1352. + #define L_G_TSIZE    13
  1353. + char *lnames_tab[] = {
  1354. +     "",
  1355. +     "",
  1356. +     "DGROUP",
  1357. +     "_TEXT",
  1358. +     "CODE",
  1359. +     "_DATA",
  1360. +     "DATA",
  1361. +     "CONST",
  1362. +     "_BSS",
  1363. +     "BSS",
  1364. +     "$$TYPES",
  1365. +     "DEBTYP",
  1366. +     "$$SYMBOLS",
  1367. +     "DEBSYM"
  1368. + };
  1369. + struct segtable {
  1370. +     unsigned char attrib;
  1371. +     long length;
  1372. +     unsigned nameindex;
  1373. +     unsigned classindex;
  1374. + };
  1375. + /* SEGDEF's */
  1376. + static struct segtable segt[] = {
  1377. +     {0, NULL, 0, 0},
  1378. +     {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_UTEXT, L_CODE},
  1379. +     {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_UDATA, L_DATA},
  1380. +     {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_CONST, L_CONST},
  1381. +     {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_UBSS, L_BSS},
  1382. +     {SD_BYTE|SD_PGRES, 0, L_SYMBOLS, L_DEBSYM},
  1383. +     {SD_BYTE|SD_PGRES, 0, L_TYPES, L_DEBTYP}
  1384. + };
  1385. + /* GRPDEF */
  1386. + #define GRPTABSIZ 3
  1387. + unsigned int group_tab[GRPTABSIZ] = {3, 4, 2};
  1388. + /* COMENTs */
  1389. + struct comment {
  1390. +     unsigned char class;
  1391. +     unsigned char count;
  1392. +     unsigned char *data;
  1393. + };
  1394. + #define NUMFIXEDCOMMENTS 4
  1395. + static unsigned char gas_comment[] = "gas-1.38.1a";
  1396. + static unsigned char lib_comment[] = "SLIBCE";
  1397. + static unsigned char model_comment[] = "3s";
  1398. + static unsigned char msext_comment[] = {1, 0x43, 0x56};
  1399. + struct comment fix_cmnt[NUMFIXEDCOMMENTS] = {
  1400. +     {0, 8, gas_comment},
  1401. +     {0x9f, 6, lib_comment},
  1402. +     {0x9d, 2, model_comment},
  1403. +     {0xa1, 3, msext_comment}
  1404. + };
  1405. + void omf_initialize_a_out(name, text_size, data_size, bss_size, const_size,
  1406. +               gdb, syms_size, str_size)
  1407. + unsigned char *name;
  1408. + long text_size, data_size, bss_size, const_size;
  1409. + int gdb;
  1410. + long syms_size, str_size;
  1411. + {
  1412. +     int i;
  1413. +     omf_theadr(name);
  1414. +     /* static comments */
  1415. +     for (i = 0; i < NUMFIXEDCOMMENTS; i++)
  1416. +       omf_coment(fix_cmnt[i].data, fix_cmnt[i].count, fix_cmnt[i].class);
  1417. +     /* LNAMES */
  1418. +     omf_start_lnames();
  1419. +     for (i = 1; i <= (gdb ? L_G_TSIZE : L_TSIZE); i++)
  1420. +         omf_lnames(lnames_tab[i]);
  1421. +     omf_end_lnames();
  1422. +     /* SEGDEFS */
  1423. +     segt[SDEF_TEXT].length = text_size;
  1424. +     segt[SDEF_DATA].length = data_size;
  1425. +     segt[SDEF_BSS].length = bss_size;
  1426. +     segt[SDEF_CONST].length = const_size;
  1427. +     if (gdb)
  1428. +     {
  1429. +         segt[SDEF_SYMBOLS].length = syms_size;
  1430. +         segt[SDEF_TYPES].length = str_size;
  1431. +     }
  1432. +     for (i = 1; i <= (gdb ? SDEF_G_SIZE : SDEF_SIZE); i++)
  1433. +         omf_segdef(I386, segt[i].attrib, 0, 0L, segt[i].length,
  1434. +                segt[i].nameindex, segt[i].classindex);
  1435. +     /* DGROUP */
  1436. +     omf_start_grpdef(L_DGROUP);
  1437. +     for (i = 0; i < GRPTABSIZ; i++)
  1438. +         omf_grpdef(group_tab[i]);
  1439. +     omf_end_grpdef();
  1440. + }
  1441. *** gas-1.38/xenixomf.h
  1442. --- xenixomf.h    Wed Jul 10 09:02:21 1991
  1443. ***************
  1444. *** 0 ****
  1445. --- 1,140 ----
  1446. + /* Defines to map a.out definitions to OMF style definitions
  1447. +  */
  1448. + #define    PUBLICDATA    (N_DATA|N_EXT)
  1449. + #define    PUBLICTEXT    (N_TEXT|N_EXT)
  1450. + #define    PUBLICABS    (N_ABS|N_EXT)
  1451. + #define COMMDEF(x)    ((x) == (N_UNDF|N_EXT))
  1452. + #define PRIVDATA    (N_DATA)
  1453. + #define PRIVTEXT    (N_TEXT)
  1454. + #define PRIVBSS        (N_BSS)
  1455. + #define EXTERNAL    (N_UNDF)
  1456. + #define PUBLIC(x)    ((x)==PUBLICDATA || (x)==PUBLICTEXT || (x)==PUBLICABS)
  1457. + #define EXTDEF(x)    ((x)==EXTERNAL || COMMDEF(x))
  1458. + #define PRIVATE(x)    ((x)==PRIVDATA || (x)==PRIVTEXT || (x)==PRIVBSS)
  1459. + #define MTHEADR        0x80    /* module header */
  1460. + #define MCOMENT        0x88    /* comment */
  1461. + #define MMODEND        0x8a    /* module end */
  1462. + #define M386END        0x8b    /* 32 bit module end */
  1463. + #define MEXTDEF        0x8c    /* external definition */
  1464. + #define MTYPDEF        0x8e    /* type definition */
  1465. + #define MPUBDEF        0x90    /* public definition */
  1466. + #define MPUB386        0x91    /* 32 bit public definition */
  1467. + #define MLINNUM        0x94    /* source line number */
  1468. + #define MLIN386        0x95    /* 32 bit source line number */
  1469. + #define MLNAMES        0x96    /* name list */
  1470. + #define MSEGDEF        0x98    /* segment definition */
  1471. + #define MSEG386        0x99    /* 32 bit segment definition */
  1472. + #define MGRPDEF        0x9a    /* group definition */
  1473. + #define MFIXUPP        0x9c    /* fix up previous data image */
  1474. + #define MFIX386        0x9d    /* fix up previous 32 bit data image */
  1475. + #define MLEDATA        0xa0    /* logical data image */
  1476. + #define MLED386        0xa1    /* 32 bit logical data image */
  1477. + #define    MCOMDEF        0xb0    /* communal names definition */
  1478. + /* The maximum length of an identifier.
  1479. +  */
  1480. + #define OMFNAMELENGTH    127
  1481. + /* alignment required
  1482. +  */
  1483. + #define SD_ABS        0x00        /* absolute */
  1484. + #define SD_BYTE        0x20        /* byte */
  1485. + #define SD_WORD        0x40        /* word */
  1486. + #define SD_PARA        0x60        /* paragraph */
  1487. + #define SD_PAGE        0x80        /* page */
  1488. + #define SD_DWORD    0xa0        /* double word */
  1489. + #define SD_LTL        0xc0        /* load-time locatable */
  1490. + #define SD_ALIGN    0xe0        /* alignment mask */
  1491. + #define SD_ASHIFT    5        /* alignment shift */
  1492. + /* segment combine classes */
  1493. + #define SD_PRIV        0x00        /* private, can't be combined */
  1494. + #define SD_HCOMM    0x04        /* common, place in high mem */
  1495. + #define SD_PUBLIC    0x08        /* public, sequential */
  1496. + #define SD_BAD        0x0c        /* undefined */
  1497. + #define SD_C4        0x10        /* not used */
  1498. + #define SD_STACK    0x14        /* stack segment */
  1499. + #define SD_COMM        0x18        /* common segment */
  1500. + #define SD_RCOMM    0x1c        /* not used, reverse common segment */
  1501. + #define SD_COMBO    0x1c        /* combine mask */
  1502. + #define SD_CSHIFT    2        /* combine shift */
  1503. + #define SD_PGRES    0x01        /* page resident */
  1504. + #define SD_64K        0x02        /* segment size is exactly 64k */
  1505. + /* BSSDEF record definitions
  1506. +  */
  1507. + #define    TD_CNEAR    0x62        /* near .comm variable */
  1508. + #define    TD_CFAR        0x61        /* far .comm variable */
  1509. + /* COMENT record definitions
  1510. +  */
  1511. + #define     CMT_PURGE    0x80        /* comment can be purged */
  1512. + #define  CMT_LIST    0x40        /* don't list when listing comments */
  1513. + /* FIXUP record definitions
  1514. +  */
  1515. + #define  FIX_FIXUP    0x80        /* fixup is a fixup (else thread def) */
  1516. + #define  TRD_FRAME    0x40        /* thread def for a frame (else tgt) */
  1517. + #define  TRD_MTHDSHFT    2        /* frame / target method shift */
  1518. + #define  TRD_MTHDMSK    0x1c        /* frame / target method mask */
  1519. + #define  TRD_THRED    0x03        /* thread number mask */
  1520. + /* Target method defines.  0 - 3 are primary, they include an offset, while 
  1521. +  * 4 - 7 or secondary, the offset 0 and not specified.
  1522. +  */
  1523. + #define  TGT_SI        0        /* target is Segment Index(N) + M */
  1524. + #define  TGT_GI        1        /* target is Group Index(N) + M */
  1525. + #define  TGT_EI        2        /* target is External Index(N) + M */
  1526. + #define  TGT_ABS    3        /* target is absolute frame N + N */
  1527. + #define  TGT_SI_0    4        /* target is Segment Index(N) + 0 */
  1528. + #define  TGT_GI_0    5        /* target is Group Index(N) + 0 */
  1529. + #define  TGT_EI_0    6        /* target is External Index(N) + 0 */
  1530. + #define  TGT_ABS_0    7        /* target is Absolute Segmnent N + 0 */
  1531. + /* Frame fixup method
  1532. +  */
  1533. + #define  FRM_SI        0        /* Frame is Segment index(N) */
  1534. + #define  FRM_GI        1        /* Frame is Group index(N) */
  1535. + #define  FRM_EI        2        /* Frame is External index(N) */
  1536. + #define  FRM_ABS    3        /* Frame is Absolute frame(N) */
  1537. + #define  FRM_LOC    4        /* Frame is LSEG of LOCATION */
  1538. + #define  FRM_TRGT    5        /* Frame is the frame of the target */
  1539. + /* FIXUP fixdat field definitions
  1540. +  */
  1541. + #define  FIX_SEG    0x4000        /* Fixup is seg relative (else self) */
  1542. + #define  FIX_24BIT    0x2000        /* Fixup has 24b tgt disp (NOT USED) */
  1543. + #define  FIX_LOCMSK    0x3c00        /* Fixup location type mask */
  1544. + #define  FIX_LOCSHFT    10        /* Fixup location type shift */
  1545. + #define  FIX_DATAOFF    0x3ff        /* location in prev data rec of fixup */
  1546. + #define  FIXDAT_FTHRD    0x80        /* Fixup frame by thread else direct */
  1547. + #define  FIXDAT_FRAME    0x70        /* Frame thread or method mask */
  1548. + #define  FIXDAT_FRSHFT    4        /* Frame thread or method shift */
  1549. + #define  FIXDAT_TTHRD    0x08        /* Fixup target by thread else direct */
  1550. + #define  FIXDAT_TSCND    0x04        /* Primary or secondary target method */
  1551. + #define  FIXDAT_TRGT    0x03        /* Target thread or method mask */
  1552. + /* Location type definitions
  1553. +  */
  1554. + #define  LOC_LOBYTE    0        /* low 8 bits */
  1555. + #define  LOC_OFFSET    1        /* 16 bit offset */
  1556. + #define  LOC_BASE    2        /* 16 bit frame number */
  1557. + #define  LOC_POINTER    3        /* 32 bit pointer */
  1558. + #define  LOC_HIBTE    4        /* second 8 bits */
  1559. + #define  LOC_OFFSETL    5        /* 16 bit offset (liner resolved) */
  1560. + #define  LOC_OFFSET32    9        /* 32 bit offset */
  1561. + #define  LOC_POINTER48    11        /* 48 bit pointer */
  1562. + #define  LOC_OFFSETL32    13        /* 32 bit offset (liner resolved) */
  1563.  
  1564.