home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Source Code 1992 March
/
Source_Code_CD-ROM_Walnut_Creek_March_1992.iso
/
usenet
/
altsrcs
/
3
/
3917
< prev
next >
Wrap
Internet Message Format
|
1991-08-28
|
48KB
Xref: wupost comp.unix.xenix.sco:4107 alt.sources:3917
Path: wupost!uunet!mcsun!ukc!stl!robobar!ronald
From: Steve.Bleazard@robobar.Co.Uk
Newsgroups: comp.unix.xenix.sco,alt.sources
Subject: Xenix Patch Kit for GAS 1.38.1/GCC 1.40/GDB 3.5 (part 2/4)
Message-ID: <Xenix/gas-1.38.pch@robobar.co.uk>
Date: 27 Aug 91 14:26:30 GMT
Sender: ronald@robobar.co.uk (Ronald S H Khoo)
Organization: Robobar Ltd., Perivale, Middx., ENGLAND.
Lines: 1781
X-Md4-Signature: 865bdb9bc2aed86a7bcc5fe75eab77d9
Archive-Name: Xenix/gas-1.38.pch
This is part 2 of a 4 part posting.
Part 1 (the README) describes this package
*** gas-1.38/Makefile Thu Oct 18 15:26:42 1990
--- Makefile Fri Jul 12 06:02:10 1991
***************
*** 50,55 ****
--- 50,61 ----
# and un-comment the next two lines.
# G0 = -g -I. -DUSE_SYSTEM_HDR -DEXEC_VERSION=1
# LOADLIBES = -lc /usr/att/lib/libc.a
+ #
+ # To compile gas for a Xenix 386, comment out all the above lines,
+ # and un-comment the next two lines. (If you are using GCC, comment out the
+ # alloca.o part) (Get alloca from the emacs distribution, or use GCC.)
+ G0 = -O -I. -DUSG -DWORKING_DOT_WORD
+ LOADLIBES = alloca.o -lmalloc
# If you just want to compile the vax assembler, type 'make avax'
***************
*** 129,134 ****
--- 135,144 ----
CFLAGS = $(G0) $(G1) $(G2) $(G3) $(G4)
#
+ #
+ # To make the XENIX 386 assembler compile as the default, un-comment the next
+ # line and commment out all the other lines that start with DEFAULT_GAS
+ #DEFAULT_GAS=ax386
# To make the 68020 assembler compile as the default, un-comment the next
# line, and comment out all the other lines that start with DEFAULT_GAS
DEFAULT_GAS=a68
***************
*** 245,250 ****
--- 255,269 ----
a386: $a $x
$(CC) -o a386 $(LDFLAGS) $a $x $(LOADLIBES)
+
+ # XENIX 80386 GAS --------------------------------------------------------------
+ u = xenixomf.o omfwrite.o
+ U = xenixomf.c xenixomf.h msomf.h omfwrite.c
+
+ xenixomf.o: xenixomf.h msomf.h
+
+ ax386: $a $x $u
+ $(CC) -o ax386 $(LDFLAGS) $a $u $x $(LOADLIBES)
# 68020 GAS ------------------------------------------------------------------
y = m68k.o atof-ieee.o write.o read.o
*** gas-1.38/as.c Thu Oct 11 11:26:17 1990
--- as.c Wed Jul 10 09:01:54 1991
***************
*** 84,89 ****
--- 84,90 ----
myname=argv[0];
bzero (flagseen, sizeof(flagseen)); /* aint seen nothing yet */
out_file_name = "a.out"; /* default .o file */
+ module_name = "unknown.s";
symbol_begin(); /* symbols.c */
subsegs_begin(); /* subsegs.c */
read_begin(); /* read.c */
*** gas-1.38/as.h Thu Oct 11 11:26:18 1990
--- as.h Wed Jul 10 09:01:58 1991
***************
*** 286,291 ****
--- 286,292 ----
COMMON int need_pass_2; /* TRUE if we need a second pass. */
+ COMMON char *module_name; /* Name given in the file directive */
#endif /* #ifdef asH */
*** gas-1.38/config.h
--- config.h Wed Jul 10 09:16:07 1991
***************
*** 0 ****
--- 1 ----
+ #define XENIX
*** gas-1.38/msomf.h
--- msomf.h Wed Jul 10 09:02:22 1991
***************
*** 0 ****
--- 1,24 ----
+
+ /* Segment indexes for segdefs */
+
+ #define SDEF_TEXT 1
+ #define SDEF_DATA 2
+ #define SDEF_CONST 3
+ #define SDEF_BSS 4
+ #define SDEF_SYMBOLS 5
+ #define SDEF_TYPES 6
+ #define SDEF_SIZE 4
+ #define SDEF_G_SIZE 6
+
+ #define GDEF_DGROUP 1
+
+ #define I386 1
+ #define FRAME_THREAD 1
+ #define TARGET_THREAD 0
+
+ #define TEXT_FRAME_THREAD 0
+ #define DGROUP_FRAME_THREAD 1
+ #define CONST_TGT_THREAD 0
+ #define DATA_TGT_THREAD 1
+ #define TEXT_TGT_THREAD 2
+ #define BSS_TGT_THREAD 3
*** gas-1.38/omfwrite.c
--- omfwrite.c Wed Jul 10 09:02:24 1991
***************
*** 0 ****
--- 1,672 ----
+ /* write.c - emit .o file - Copyright(C)1986 Free Software Foundation, Inc.
+ Copyright (C) 1986,1987 Free Software Foundation, Inc.
+
+ This file is part of GAS, the GNU Assembler.
+
+ GAS is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+
+ GAS is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GAS; see the file COPYING. If not, write to
+ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+ #include "as.h"
+ #include "md.h"
+ #include "subsegs.h"
+ #include "obstack.h"
+ #include "struc-symbol.h"
+ #include "write.h"
+ #include "symbols.h"
+
+ #include "xenixomf.h"
+ #include "msomf.h"
+
+ #if __STDC__
+ #include <stddef.h>
+ #else
+ #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+ #endif
+
+ void append();
+
+ /*
+ * In: length of relocation (or of address) in chars: 1, 2 or 4.
+ * Out: OMF LOC type.
+ */
+
+ static unsigned char nbytes_r_length [] = {
+ 15, LOC_LOBYTE, LOC_OFFSET, 15, LOC_OFFSET32
+ };
+
+
+ static struct frag * text_frag_root;
+ static struct frag * data_frag_root;
+
+ static struct frag * text_last_frag; /* Last frag in segment. */
+ static struct frag * data_last_frag; /* Last frag in segment. */
+
+ static struct exec the_exec;
+
+ static long int string_byte_count;
+ static long int stab_symbol_count;
+
+ void relax_segment();
+ long int fixup_segment();
+
+ static void threads(type, trgt_thrd, frm_thrd)
+ int type;
+ int *trgt_thrd, *frm_thrd;
+ {
+ switch (type)
+ {
+ case PRIVDATA: *trgt_thrd = DATA_TGT_THREAD;
+ *frm_thrd = DGROUP_FRAME_THREAD;
+ break;
+ case PRIVBSS: *trgt_thrd = BSS_TGT_THREAD;
+ *frm_thrd = DGROUP_FRAME_THREAD;
+ break;
+ case PRIVTEXT: *trgt_thrd = TEXT_TGT_THREAD;
+ *frm_thrd = TEXT_FRAME_THREAD;
+ break;
+ case PUBLICDATA: *trgt_thrd = DATA_TGT_THREAD;
+ *frm_thrd = DGROUP_FRAME_THREAD;
+ break;
+ case PUBLICTEXT: *trgt_thrd = TEXT_TGT_THREAD;
+ *frm_thrd = TEXT_FRAME_THREAD;
+ break;
+ default: *trgt_thrd = CONST_TGT_THREAD;
+ *frm_thrd = DGROUP_FRAME_THREAD;
+ break;
+ }
+ }
+
+ void
+ write_object_file()
+ {
+ register struct frchain * frchainP; /* Track along all frchains. */
+ register fragS * fragP; /* Track along all frags. */
+ register struct frchain * next_frchainP;
+ register fragS * * prev_fragPP;
+ register char * name;
+ register symbolS * symbolP;
+ register symbolS ** symbolPP;
+ /* register fixS * fixP; JF unused */
+ unsigned long
+ text_siz,
+ data_siz,
+ syms_siz,
+ tr_siz,
+ dr_siz;
+ void output_file_create();
+ void output_file_append();
+ void output_file_close();
+ extern long omagic; /* JF magic # to write out. Is different for
+ Suns and Vaxen and other boxes */
+
+ /*
+ * After every sub-segment, we fake an ".align ...". This conforms to BSD4.2
+ * brane-damage. We then fake ".fill 0" because that is the kind of frag
+ * that requires least thought. ".align" frags like to have a following
+ * frag since that makes calculating their intended length trivial.
+ */
+ #define SUB_SEGMENT_ALIGN (2)
+ for ( frchainP=frchain_root; frchainP; frchainP=frchainP->frch_next )
+ {
+ subseg_new (frchainP -> frch_seg, frchainP -> frch_subseg);
+ frag_align (SUB_SEGMENT_ALIGN, 0);
+ /* frag_align will have left a new frag. */
+ /* Use this last frag for an empty ".fill". */
+ /*
+ * For this segment ...
+ * Create a last frag. Do not leave a "being filled in frag".
+ */
+ frag_wane (frag_now);
+ frag_now -> fr_fix = 0;
+ know( frag_now -> fr_next == NULL );
+ /* know( frags . obstack_c_base == frags . obstack_c_next_free ); */
+ /* Above shows we haven't left a half-completed object on obstack. */
+ }
+
+ /*
+ * From now on, we don't care about sub-segments.
+ * Build one frag chain for each segment. Linked thru fr_next.
+ * We know that there is at least 1 text frchain & at least 1 data frchain.
+ */
+ prev_fragPP = &text_frag_root;
+ for ( frchainP=frchain_root; frchainP; frchainP=next_frchainP )
+ {
+ know( frchainP -> frch_root );
+ * prev_fragPP = frchainP -> frch_root;
+ prev_fragPP = & frchainP -> frch_last -> fr_next;
+ if ( ((next_frchainP = frchainP->frch_next) == NULL)
+ || next_frchainP == data0_frchainP)
+ {
+ prev_fragPP = & data_frag_root;
+ if ( next_frchainP )
+ {
+ text_last_frag = frchainP -> frch_last;
+ }
+ else
+ {
+ data_last_frag = frchainP -> frch_last;
+ }
+ }
+ } /* for(each struct frchain) */
+
+ relax_segment (text_frag_root, SEG_TEXT);
+ relax_segment (data_frag_root, SEG_DATA);
+ /*
+ * Now the addresses of frags are correct within the segment.
+ */
+
+ text_siz=text_last_frag->fr_address;
+
+ /*
+ *
+ * Determine a_data [length of data segment].
+ */
+ if (data_frag_root)
+ data_siz=data_last_frag->fr_address;
+ else
+ data_siz = 0;
+
+ bss_address_frag . fr_address = 0;
+
+ /*
+ *
+ * Crawl the symbol chain.
+ *
+ * For each symbol whose value depends on a frag, take the address of
+ * that frag and subsume it into the value of the symbol.
+ * After this, there is just one way to lookup a symbol value.
+ * Values are left in their final state for object file emission.
+ * We adjust the values of 'L' local symbols, even if we do
+ * not intend to emit them to the object file, because their values
+ * are needed for fix-ups.
+ *
+ * Unless we saw a -L flag, remove all symbols that begin with 'L'
+ * from the symbol chain.
+ *
+ * Count the (length of the nlists of the) (remaining) symbols.
+ * Assign a symbol number to each symbol.
+ * Count the number of string-table chars we will emit.
+ *
+ */
+ string_byte_count = sizeof( string_byte_count );
+
+ /* JF deal with forward references first. . . */
+ for(symbolP=symbol_rootP;symbolP;symbolP=symbolP->sy_next) {
+ if(symbolP->sy_forward) {
+ symbolP->sy_value+=symbolP->sy_forward->sy_value+symbolP->sy_forward->sy_frag->fr_address;
+ symbolP->sy_forward=0;
+ }
+ }
+ symbolPP = & symbol_rootP; /* -> last symbol chain link. */
+ {
+ register long int symbol_number;
+
+ symbol_number = 1; stab_symbol_count = 0;
+
+ while (symbolP = * symbolPP)
+ {
+ name = symbolP -> sy_name;
+ symbolP -> sy_value += symbolP -> sy_frag -> fr_address;
+ if ( !name || (symbolP->sy_nlist.n_type&N_STAB)
+ || (name[0]!='\001' && (flagseen ['L'] || name [0] != 'L' )))
+ {
+ if (EXTDEF(symbolP->sy_nlist.n_type))
+ symbolP -> sy_number = symbol_number ++;
+ else
+ symbolP -> sy_number = 0;
+ if (symbolP->sy_nlist.n_type&N_STAB)
+ stab_symbol_count++;
+ if (name && symbolP->sy_nlist.n_type&N_STAB)
+ { /* Ordinary case. */
+ symbolP -> sy_name_offset = string_byte_count;
+ string_byte_count += strlen (symbolP -> sy_name) + 1;
+ }
+ else /* .Stabd case. */
+ symbolP -> sy_name_offset = 0;
+ symbolPP = & (symbolP -> sy_next);
+ }
+ else
+ * symbolPP = symbolP -> sy_next;
+ } /* for each symbol */
+
+ syms_siz = sizeof( struct nlist) * symbol_number;
+ }
+
+ /*
+ * Addresses of frags now reflect addresses we use in the object file.
+ * Symbol values are correct.
+ * Scan the frags, converting any ".org"s and ".align"s to ".fill"s.
+ * Also converting any machine-dependent frags using md_convert_frag();
+ */
+ subseg_change( SEG_TEXT, 0);
+
+ for (fragP = text_frag_root; fragP; fragP = fragP -> fr_next)
+ {
+ switch (fragP -> fr_type)
+ {
+ case rs_align:
+ case rs_org:
+ fragP -> fr_type = rs_fill;
+ know( fragP -> fr_var == 1 );
+ know( fragP -> fr_next );
+ fragP -> fr_offset
+ = fragP -> fr_next -> fr_address
+ - fragP -> fr_address
+ - fragP -> fr_fix;
+ break;
+
+ case rs_fill:
+ break;
+
+ case rs_machine_dependent:
+ md_convert_frag (fragP);
+ /*
+ * After md_convert_frag, we make the frag into a ".space 0".
+ * Md_convert_frag() should set up any fixSs and constants
+ * required.
+ */
+ frag_wane (fragP);
+ break;
+
+ default:
+ BAD_CASE( fragP -> fr_type );
+ break;
+ } /* switch (fr_type) */
+ } /* for each frag. */
+
+
+ subseg_change( SEG_DATA, 0);
+
+ for (fragP = data_frag_root; fragP; fragP = fragP -> fr_next)
+ {
+ switch (fragP -> fr_type)
+ {
+ case rs_align:
+ case rs_org:
+ fragP -> fr_type = rs_fill;
+ know( fragP -> fr_var == 1 );
+ know( fragP -> fr_next );
+ fragP -> fr_offset
+ = fragP -> fr_next -> fr_address
+ - fragP -> fr_address
+ - fragP -> fr_fix;
+ break;
+
+ case rs_fill:
+ break;
+
+ case rs_machine_dependent:
+ md_convert_frag (fragP);
+ /*
+ * After md_convert_frag, we make the frag into a ".space 0".
+ * Md_convert_frag() should set up any fixSs and constants
+ * required.
+ */
+ frag_wane (fragP);
+ break;
+
+ default:
+ BAD_CASE( fragP -> fr_type );
+ break;
+ } /* switch (fr_type) */
+ } /* for each frag. */
+
+ subseg_change( SEG_TEXT, 0);
+
+ fixup_segment (text_fix_root, N_TEXT);
+ fixup_segment (data_fix_root, N_DATA);
+ output_file_create (out_file_name);
+ omf_initialize_a_out(module_name, text_siz, data_siz,
+ (long) local_bss_counter, 0L,
+ flagseen['g'], stab_symbol_count * sizeof(struct nlist),
+ string_byte_count);
+
+ /* Traverse the symbol chain emitting external symbol definitions
+ * for external, public and common symbols.
+ */
+
+ for ( symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next )
+ {
+ if (EXTDEF(symbolP->sy_type))
+ {
+ if (COMMDEF(symbolP->sy_type))
+ {
+ omf_start_comdef();
+ omf_comdef(symbolP->sy_name, TD_CNEAR, symbolP->sy_value, 0L);
+ omf_end_comdef();
+ }
+ else
+ omf_extdef(symbolP->sy_name, 0);
+ }
+ }
+
+ /* Traverse the symbol chain emitting public definitions
+ */
+
+ for ( symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next )
+ {
+ if (PUBLIC(symbolP->sy_type))
+ {
+ unsigned int group = 0, segment = 0;
+
+ if (symbolP->sy_type == PUBLICTEXT)
+ segment = SDEF_TEXT;
+ if (symbolP->sy_type == PUBLICDATA)
+ {
+ group = GDEF_DGROUP; segment = SDEF_DATA;
+ }
+
+ omf_start_pubdef(I386, group, segment, 0);
+ omf_pubdef(I386, symbolP->sy_name, symbolP->sy_value, 0);
+ omf_end_pubdef();
+ }
+ }
+
+
+ /* Setup threads for DGROUP and the segments ready for relocation */
+
+ omf_start_thread(I386);
+ omf_thread(CONST_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_CONST);
+ omf_thread(DATA_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_DATA);
+ omf_thread(TEXT_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_TEXT);
+ omf_thread(BSS_TGT_THREAD, TARGET_THREAD, FRM_SI, SDEF_BSS);
+ omf_thread(TEXT_FRAME_THREAD, FRAME_THREAD, FRM_SI, SDEF_TEXT);
+ omf_thread(DGROUP_FRAME_THREAD, FRAME_THREAD, FRM_GI, GDEF_DGROUP);
+ omf_end_thread();
+
+ /*
+ * Emit code.
+ */
+
+ for (fragP = data_frag_root; fragP; fragP = fragP -> fr_next)
+ {
+ register long int count;
+ register char * fill_literal;
+ register long int fill_size;
+ register fixS * fixP;
+ register symbolS * symbolP;
+ int started_fixup;
+
+ know( fragP -> fr_type == rs_fill );
+
+ if (fragP->fr_fix != 0 || fragP->fr_offset != 0)
+ {
+ omf_start_ledata(I386, SDEF_DATA, fragP->fr_address);
+ if (fragP->fr_fix != 0)
+ omf_ledata(fragP->fr_literal, (int)fragP->fr_fix);
+ fill_literal = fragP->fr_literal + fragP -> fr_fix;
+ fill_size = fragP->fr_var;
+ count = fragP -> fr_offset;
+ if ((fragP->fr_fix + count * fill_size) < 1016)
+ {
+ for ( ; count; count--)
+ omf_ledata(fill_literal, (int)fill_size);
+ }
+ else /* filling will exceed the 1024 byte record size */
+ {
+ /* This code assumes that fill_size <= 8 bytes.
+ * This is infact the case because of
+ * compatability with other assemblers
+ */
+ register int fcount;
+
+ fcount = (1016 - fragP->fr_fix) / fill_size;
+ count -= fcount;
+ for ( ; fcount > 0; fcount--)
+ omf_ledata(fill_literal, (int)fill_size);
+
+ }
+ omf_end_ledata();
+
+ /* Emit the relocations for this frag
+ */
+
+ fixP = data_fix_root; started_fixup = 0;
+ for ( ; fixP; fixP = fixP -> fx_next)
+ {
+ if (fixP->fx_frag == fragP && (symbolP = fixP->fx_addsy))
+ {
+ int trgt_thrd, frm_thrd;
+ int external = EXTDEF(symbolP->sy_type);
+
+ threads(symbolP->sy_type, &trgt_thrd, &frm_thrd);
+ if (fixP->fx_pcrel)
+ frm_thrd = TEXT_FRAME_THREAD;
+
+ if (!started_fixup)
+ {
+ omf_start_fixup(I386);
+ started_fixup++;
+ }
+ omf_fixup(I386, !fixP->fx_pcrel,
+ nbytes_r_length [fixP->fx_size], fixP->fx_where,
+ external ? 0 : 1,
+ external ? FRM_TRGT : frm_thrd,
+ external ? 0 : 1,
+ external ? TGT_EI : trgt_thrd,
+ 1, /* No offset */
+ 0, /* No frame required */
+ EXTDEF(symbolP->sy_type) ? symbolP->sy_number : 0,
+ 0);
+ }
+ }
+ if (started_fixup)
+ omf_end_fixup();
+
+ while (count > 0) /* still sum fill data to emit */
+ {
+ unsigned long address;
+ unsigned int len;
+
+ address = fragP->fr_address + fragP->fr_fix +
+ (fragP->fr_offset - count) * fill_size;
+ omf_start_ledata(I386, SDEF_DATA, address);
+ for ( len = 0; count && (len < 1000); count--, len += fill_size)
+ omf_ledata(fill_literal, (int)fill_size);
+ omf_end_ledata();
+ }
+ }
+ }
+
+ for (fragP = text_frag_root; fragP; fragP = fragP -> fr_next)
+ {
+ register long int count;
+ register char * fill_literal;
+ register long int fill_size;
+ register fixS * fixP;
+ register symbolS * symbolP;
+ int started_fixup;
+
+ know( fragP -> fr_type == rs_fill );
+
+ if (fragP->fr_fix != 0 || fragP->fr_offset != 0)
+ {
+ omf_start_ledata(I386, SDEF_TEXT, fragP->fr_address);
+ if (fragP->fr_fix != 0)
+ omf_ledata(fragP->fr_literal, (int)fragP->fr_fix);
+ fill_literal = fragP->fr_literal + fragP -> fr_fix;
+ fill_size = fragP->fr_var;
+ for (count = fragP -> fr_offset; count; count --)
+ omf_ledata(fill_literal, (int)fill_size);
+ omf_end_ledata();
+
+ /* Emit the relocations for this frag
+ */
+
+ fixP = text_fix_root; started_fixup = 0;
+ for ( ; fixP; fixP = fixP -> fx_next)
+ {
+ if (fixP->fx_frag == fragP && (symbolP = fixP->fx_addsy))
+ {
+ int trgt_thrd, frm_thrd;
+ int external = EXTDEF(symbolP->sy_type);
+
+ threads(symbolP->sy_type, &trgt_thrd, &frm_thrd);
+ if (fixP->fx_pcrel)
+ frm_thrd = TEXT_FRAME_THREAD;
+
+ if (!started_fixup)
+ {
+ omf_start_fixup(I386);
+ started_fixup++;
+ }
+ omf_fixup(I386, !fixP->fx_pcrel,
+ nbytes_r_length [fixP->fx_size], fixP->fx_where,
+ external ? 0 : 1,
+ external ? FRM_TRGT : frm_thrd,
+ external ? 0 : 1,
+ external ? TGT_EI : trgt_thrd,
+ 1, /* No offset */
+ 0, /* No frame required */
+ external ? symbolP->sy_number : 0,
+ 0);
+ }
+ }
+ if (started_fixup)
+ omf_end_fixup();
+ }
+ }
+
+ /* Traverse the symbol chain emitting stabs.
+ */
+
+ #define VAL_OFF offsetof(struct nlist, n_value)
+
+ if (flagseen['g'] && stab_symbol_count)
+ {
+ long count = 0, ncount = 0;
+ symbolS *last_startP;
+ char *temp;
+ symbolS *fsymP;
+ int i;
+ int start_fixup = 0;
+
+ omf_start_ledata(I386, SDEF_SYMBOLS, 0);
+ last_startP = symbol_rootP;
+ for (symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next)
+ {
+ if (symbolP->sy_nlist.n_type & N_STAB)
+ {
+ if ((ncount + 1) * sizeof(struct nlist) >= 1016)
+ {
+ omf_end_ledata();
+
+ /* emit relocations */
+
+ start_fixup = 0;
+ for (i = 0, fsymP=last_startP; i < ncount; fsymP=fsymP->sy_next)
+ {
+ if (fsymP->sy_nlist.n_type & N_STAB)
+ {
+ if (fsymP->sy_type & N_TYPE) /* if relocation required */
+ {
+ int trgt_thrd, frm_thrd;
+ int external = EXTDEF(fsymP->sy_type & N_TYPE);
+
+ threads(fsymP->sy_type & N_TYPE,&trgt_thrd,&frm_thrd);
+ if (!start_fixup)
+ {
+ omf_start_fixup(I386);
+ start_fixup++;
+ }
+ omf_fixup(I386, 1, /* segment relative */
+ LOC_OFFSET32, i * sizeof(struct nlist) + VAL_OFF,
+ external ? 0 : 1,
+ external ? FRM_TRGT : frm_thrd,
+ external ? 0 : 1,
+ external ? TGT_EI : trgt_thrd,
+ 1, /* No offset */
+ 0, /* No frame required */
+ external ? fsymP->sy_number : 0,
+ 0);
+ }
+ i++;
+ }
+ }
+ if (start_fixup)
+ omf_end_fixup();
+
+ /* start new segment */
+
+ ncount = 0; last_startP = symbolP;
+ omf_start_ledata(I386, SDEF_SYMBOLS, count*sizeof(struct nlist));
+ }
+ temp = symbolP->sy_nlist.n_un.n_name;
+ symbolP->sy_nlist.n_un.n_strx = symbolP->sy_name_offset;
+ omf_ledata(&(symbolP->sy_nlist), sizeof(struct nlist));
+ symbolP->sy_nlist.n_un.n_name = temp;
+ ncount++; count++;
+ }
+ }
+ omf_end_ledata();
+ start_fixup = 0;
+ for (i = 0, fsymP = last_startP; i < ncount; fsymP = fsymP->sy_next)
+ {
+ if (fsymP->sy_nlist.n_type & N_STAB)
+ {
+ if (fsymP->sy_type & N_TYPE) /* if relocation required */
+ {
+ int trgt_thrd, frm_thrd;
+ int external = EXTDEF(fsymP->sy_type & N_TYPE);
+
+ threads(fsymP->sy_type & N_TYPE,&trgt_thrd,&frm_thrd);
+ if (!start_fixup)
+ {
+ omf_start_fixup(I386);
+ start_fixup++;
+ }
+ omf_fixup(I386, 1, /* segment relative */
+ LOC_OFFSET32, i * sizeof(struct nlist) + VAL_OFF,
+ external ? 0 : 1,
+ external ? FRM_TRGT : frm_thrd,
+ external ? 0 : 1,
+ external ? TGT_EI : trgt_thrd,
+ 1, /* No offset */
+ 0, /* No frame required */
+ external ? fsymP->sy_number : 0,
+ 0);
+ }
+ i++;
+ }
+ }
+ if (start_fixup)
+ omf_end_fixup();
+
+ count = sizeof(string_byte_count); ncount = count;
+ omf_start_ledata(I386, SDEF_TYPES, 0);
+ omf_ledata(&string_byte_count, sizeof(string_byte_count));
+ for (symbolP = symbol_rootP; symbolP; symbolP = symbolP -> sy_next)
+ {
+ if (symbolP->sy_nlist.n_type & N_STAB && symbolP -> sy_name)
+ {
+ int len = strlen(symbolP -> sy_name) + 1;
+
+ if (ncount + len > 1016)
+ {
+ omf_end_ledata();
+ omf_start_ledata(I386, SDEF_TYPES, count);
+ ncount = 0;
+ }
+ omf_ledata(symbolP->sy_name, len);
+ count += len; ncount += len;
+ }
+ }
+ omf_end_ledata();
+ }
+
+
+ omf_modend(I386);
+ output_file_close (out_file_name);
+
+ } /* write_object_file() */
*** gas-1.38/read.c Tue Oct 30 13:42:03 1990
--- read.c Wed Jul 10 12:53:36 1991
***************
*** 711,717 ****
int length;
/* Some assemblers tolerate immediately following '"' */
! if ( s = demand_copy_string( & length ) ) {
new_logical_line (s, -1);
demand_empty_rest_of_line();
}
--- 711,718 ----
int length;
/* Some assemblers tolerate immediately following '"' */
! if ( s = demand_copy_C_string( & length ) ) {
! module_name = s;
new_logical_line (s, -1);
demand_empty_rest_of_line();
}
***************
*** 1697,1703 ****
void /* JF was static, but can't be if VAX.C is goning to use it */
float_cons(float_type) /* Worker to do .float etc statements. */
/* Clobbers input_line-pointer, checks end-of-line. */
! register float_type; /* 'f':.ffloat ... 'F':.float ... */
{
register char * p;
register char c;
--- 1698,1704 ----
void /* JF was static, but can't be if VAX.C is goning to use it */
float_cons(float_type) /* Worker to do .float etc statements. */
/* Clobbers input_line-pointer, checks end-of-line. */
! register int float_type; /* 'f':.ffloat ... 'F':.float ... */
{
register char * p;
register char c;
*** gas-1.38/subsegs.c Thu Oct 11 11:26:23 1990
--- subsegs.c Wed Jul 10 09:02:02 1991
***************
*** 96,102 ****
--- 96,106 ----
know( SEG_MAXIMUM_ORDINAL == SEG_DIFFERENCE );
know( seg_name [(int) SEG_MAXIMUM_ORDINAL + 1] [0] == 0 );
+ #ifdef M_XENIX
+ obstack_begin( &frags, 1000);
+ #else
obstack_begin( &frags, 5000);
+ #endif /* M_XENIX */
frchain_root = NULL;
frchain_now = NULL; /* Warn new_subseg() that we are booting. */
/* Fake up 1st frag. */
*** gas-1.38/write.c Thu Oct 11 11:26:15 1990
--- write.c Wed Jul 10 09:06:47 1991
***************
*** 38,43 ****
--- 38,46 ----
#include "write.h"
#include "symbols.h"
+ static relax_addressT relax_align();
+
+ #ifndef M_XENIX
#ifdef SPARC
#include "sparc.h"
#endif
***************
*** 93,103 ****
static void relax_segment();
void emit_segment();
- static relax_addressT relax_align();
static long int fixup_segment();
#if !defined(SPARC) && !defined(I860)
static void emit_relocations();
#endif
/*
* fix_new()
*
--- 96,107 ----
static void relax_segment();
void emit_segment();
static long int fixup_segment();
#if !defined(SPARC) && !defined(I860)
static void emit_relocations();
#endif
+
+ #endif /* M_XENIX */
/*
* fix_new()
*
***************
*** 146,151 ****
--- 150,156 ----
* seg_fix_rootP = fixP;
}
+ #ifndef M_XENIX
void
write_object_file()
{
***************
*** 683,688 ****
--- 688,694 ----
VMS_write_object_file(text_siz, data_siz, text_frag_root, data_frag_root);
#endif /* VMS */
} /* write_object_file() */
+ #endif /* M_XENIX */
/*
* relax_segment()
***************
*** 697,703 ****
--- 703,711 ----
* these frag addresses may not be the same as final object-file addresses.
*/
#ifndef VMS
+ #ifndef M_XENIX
static
+ #endif /* not M_XENIX */
#endif /* not VMS */
void
relax_segment (segment_frag_root, segment_type)
***************
*** 1010,1016 ****
/*
* fixup_segment()
*/
! static long int
fixup_segment (fixP, this_segment_type)
register fixS * fixP;
int this_segment_type; /* N_TYPE bits for segment. */
--- 1018,1027 ----
/*
* fixup_segment()
*/
! #ifndef M_XENIX
! static
! #endif /* not M_XENIX */
! long int
fixup_segment (fixP, this_segment_type)
register fixS * fixP;
int this_segment_type; /* N_TYPE bits for segment. */
***************
*** 1137,1142 ****
--- 1148,1156 ----
} /* if there was a + symbol */
if (pcrel)
{
+ #ifdef M_XENIX
+ if (add_symbol_N_TYPE != N_UNDF)
+ #endif
add_number -=
#ifndef NS32K
size +
***************
*** 1184,1189 ****
--- 1198,1204 ----
} /* fixup_segment() */
+ #ifndef M_XENIX
/* The sparc needs its own emit_relocations() */
#if !defined(SPARC) && !defined(I860)
/*
***************
*** 1244,1249 ****
--- 1259,1265 ----
}
#endif
+ #endif /* M_XENIX */
int
is_dnrange(f1,f2)
*** gas-1.38/xenixomf.c
--- xenixomf.c Wed Jul 10 09:02:18 1991
***************
*** 0 ****
--- 1,660 ----
+ #include <string.h>
+ #include <stdio.h>
+ #include "xenixomf.h"
+ #include "msomf.h"
+
+ #ifdef M_XENIX
+ # undef i386
+ #endif
+
+ #define MAXRECORDSIZE (14 * 1024) /* 1k data => 1024 fixups */
+ #define I386 1
+
+ extern char *out_file_name;
+
+ static char chksum = 0;
+ static unsigned char recordbuff[MAXRECORDSIZE];
+ static unsigned char *record_ptr;
+
+ static void copy_bytes_to_record(p, count)
+ unsigned char *p;
+ int count;
+ {
+ while (count--)
+ {
+ *record_ptr++ = *p;
+ chksum += *p++;
+ }
+ }
+
+ static void start_record(type)
+ unsigned char type;
+ {
+ chksum = 0;
+ record_ptr = recordbuff;
+ copy_bytes_to_record(&type, 1);
+ record_ptr += 2; /* leave space for the record size */
+ }
+
+ static void output_record()
+ {
+ int length;
+ unsigned char b;
+
+ length = (record_ptr - recordbuff) + 1; /* 1 for chksum */
+
+ /* patch the record length into the header and put -chksum
+ * at the end of the record.
+ */
+
+ b = (length - 3) & 0xff; /* -3 as record length excludes type + len */
+ chksum += b; recordbuff[1] = b;
+ b = ((length - 3) >> 8) & 0xff;
+ chksum += b; recordbuff[2] = b;
+ *record_ptr = (unsigned char)(-chksum);
+
+ output_file_append (recordbuff, length, out_file_name);
+ }
+
+ static void copy_string_to_record(s)
+ char *s;
+ {
+ unsigned char len;
+
+ len = strlen(s);
+ if (len > OMFNAMELENGTH)
+ {
+ char tname[OMFNAMELENGTH+2];
+
+ strncpy(tname, s, OMFNAMELENGTH);
+ tname[OMFNAMELENGTH] = '\0';
+ fprintf(stderr, "Identifier truncated to %s (%d chars)\n",
+ tname, OMFNAMELENGTH);
+ len = OMFNAMELENGTH;
+ copy_bytes_to_record(&len, 1);
+ copy_bytes_to_record(s, OMFNAMELENGTH);
+ }
+ else
+ {
+ copy_bytes_to_record(&len, 1);
+ if (len > 0)
+ copy_bytes_to_record(s, len);
+ }
+ }
+
+ static void copy_index_to_record(index)
+ unsigned int index;
+ {
+ unsigned char b;
+
+ if (index < 128)
+ {
+ b = (unsigned char)(index & 0xff);
+ copy_bytes_to_record(&b, 1);
+ }
+ else
+ {
+ b = (unsigned char)(((index >> 8) & 0xff) | 0x80);
+ copy_bytes_to_record(&b, 1);
+ b = (unsigned char)(index & 0xff);
+ copy_bytes_to_record(&b, 1);
+ }
+ }
+
+ static void copy_vint_to_record(value, count)
+ long value;
+ int count;
+ {
+ unsigned char b;
+
+ while (count--)
+ {
+ b = (unsigned char)(value & 0xff);
+ copy_bytes_to_record(&b, 1);
+ value >>= 8;
+ }
+ }
+
+ static void copy_word_to_record(value)
+ unsigned int value;
+ {
+ copy_vint_to_record((long)value, 2);
+ }
+
+ static void copy_offset_to_record(i386, value)
+ int i386;
+ long value;
+ {
+ copy_vint_to_record(value, i386 ? 4 : 2);
+ }
+
+ static void copy_comsize_to_record(value)
+ long value;
+ {
+ unsigned char b;
+
+ if (value < 128)
+ copy_vint_to_record((long)value, 1);
+ else if (value < 65536L)
+ {
+ b = 0x81;
+ copy_bytes_to_record(&b, 1);
+ copy_vint_to_record((long)value, 2);
+ }
+ else if (value < 16777216L)
+ {
+ b = 0x84;
+ copy_bytes_to_record(&b, 1);
+ copy_vint_to_record((long)value, 3);
+ }
+ else
+ {
+ b = 0x88;
+ copy_bytes_to_record(&b, 1);
+ copy_vint_to_record((long)value, 4);
+ }
+
+ }
+
+ void omf_theadr(name)
+ unsigned char *name;
+ {
+ start_record(MTHEADR);
+ copy_string_to_record(name);
+ output_record();
+ }
+
+ void omf_coment(p, count, class)
+ unsigned char *p;
+ int count;
+ unsigned char class;
+ {
+ unsigned char attrib;
+
+ start_record(MCOMENT);
+ attrib = 0; /* Purge and List attributes */
+ copy_bytes_to_record(&attrib, 1);
+ copy_bytes_to_record(&class, 1);
+ copy_bytes_to_record(p, count);
+ output_record();
+ }
+
+ void omf_extdef(name, type)
+ unsigned char *name;
+ {
+ start_record(MEXTDEF);
+ copy_string_to_record(name);
+ copy_bytes_to_record(&type, 1);
+ output_record();
+ }
+
+ void omf_start_pubdef(i386, group, segment, frame)
+ int i386;
+ int group, segment, frame;
+ {
+ if (i386)
+ start_record(MPUB386);
+ else
+ start_record(MPUBDEF);
+
+ copy_index_to_record(group);
+ copy_index_to_record(segment);
+ if (group == 0 && segment == 0)
+ copy_word_to_record(frame);
+ }
+
+ void omf_pubdef(i386, name, offset, type)
+ int i386;
+ unsigned char *name;
+ int type;
+ long offset;
+ {
+ copy_string_to_record(name);
+ copy_offset_to_record(i386, offset);
+ copy_index_to_record(type);
+ }
+
+ void omf_end_pubdef()
+ {
+ output_record();
+ }
+
+ void omf_start_lnames()
+ {
+ start_record(MLNAMES);
+ }
+
+ void omf_lnames(name)
+ unsigned char *name;
+ {
+ copy_string_to_record(name);
+ }
+
+ void omf_end_lnames()
+ {
+ output_record();
+ }
+
+ void omf_segdef(i386, acbp, frame, offset, seglen, segname, segclass)
+ int i386;
+ unsigned char acbp;
+ unsigned int frame;
+ unsigned int offset;
+ long seglen;
+ unsigned int segname, segclass;
+ {
+ unsigned int ovlindex = 0;
+ if (i386)
+ start_record(MSEG386);
+ else
+ start_record(MSEGDEF);
+
+ copy_bytes_to_record(&acbp, 1);
+ if ((acbp & SD_ALIGN) == SD_ABS)
+ {
+ copy_word_to_record(frame);
+ copy_word_to_record(offset); /* should be byte - Fix Me */
+ }
+ copy_offset_to_record(i386, seglen);
+ copy_index_to_record(segname);
+ copy_index_to_record(segclass);
+ copy_index_to_record(ovlindex);
+ output_record();
+ }
+
+ void omf_start_grpdef(grpname)
+ unsigned int grpname;
+ {
+ start_record(MGRPDEF);
+ copy_index_to_record(grpname);
+ }
+
+ void omf_grpdef(segindex)
+ unsigned int segindex;
+ {
+ unsigned char b = 0xff;
+
+ copy_bytes_to_record(&b, 1);
+ copy_index_to_record(segindex);
+ }
+
+ void omf_end_grpdef()
+ {
+ output_record();
+ }
+
+ void omf_start_comdef()
+ {
+ start_record(MCOMDEF);
+ }
+
+ void omf_comdef(name, dataseg_type, length, el_size)
+ unsigned char *name;
+ unsigned char dataseg_type;
+ {
+ unsigned char type = 0;
+
+ copy_string_to_record(name);
+ copy_bytes_to_record(&type, 1);
+ copy_bytes_to_record(&dataseg_type, 1);
+
+ copy_comsize_to_record(length);
+ if (dataseg_type == TD_CFAR)
+ {
+ copy_comsize_to_record(el_size);
+ }
+ }
+
+ void omf_end_comdef()
+ {
+ output_record();
+ }
+
+ void omf_start_linnum(i386, segindex)
+ {
+ unsigned char grpindex = 0;
+
+ if (i386)
+ start_record(MLIN386);
+ else
+ start_record(MLINNUM);
+
+ copy_bytes_to_record(&grpindex, 1);
+ copy_index_to_record(segindex);
+ }
+
+ void omf_linnum(i386, line, offset)
+ int i386;
+ unsigned int line;
+ long offset;
+ {
+ copy_word_to_record(line);
+ copy_offset_to_record(i386, offset);
+ }
+
+ void omf_end_linnum()
+ {
+ output_record();
+ }
+
+ void omf_start_thread(i386)
+ {
+ if (i386)
+ start_record(MFIX386);
+ else
+ start_record(MFIXUPP);
+ }
+
+ void omf_thread(thread, framethread, method, index)
+ unsigned char thread;
+ int framethread;
+ unsigned char method;
+ unsigned int index;
+ {
+ unsigned char thread_data;
+
+ thread_data = thread | (method << TRD_MTHDSHFT);
+ if (framethread)
+ thread_data |= TRD_FRAME;
+ copy_bytes_to_record(&thread_data, 1);
+
+ if (framethread)
+ {
+ switch (method)
+ {
+ case FRM_SI:
+ case FRM_GI:
+ case FRM_EI:
+ case FRM_ABS:
+ copy_index_to_record(index);
+ break;
+ case FRM_LOC:
+ case FRM_TRGT:
+ break;
+ }
+ }
+ else
+ copy_index_to_record(index);
+ }
+
+ void omf_end_thread()
+ {
+ output_record();
+ }
+
+ void omf_start_fixup(i386)
+ {
+ if (i386)
+ start_record(MFIX386);
+ else
+ start_record(MFIXUPP);
+ }
+
+ static void generate_fixdat(i386, f_thrd, frame, t_thrd, trgt, t_sec,
+ frame_index, target_index, offset)
+ int i386;
+ int f_thrd;
+ unsigned int frame;
+ int t_thrd;
+ unsigned int trgt;
+ int t_sec;
+ unsigned int frame_index, target_index;
+ long offset;
+ {
+ unsigned char fixdat, b;
+
+ fixdat = (f_thrd ? FIXDAT_FTHRD : 0) | (frame << FIXDAT_FRSHFT);
+ fixdat |= (t_thrd ? FIXDAT_TTHRD : 0) | trgt | (t_sec ? FIXDAT_TSCND:0);
+ copy_bytes_to_record(&fixdat, 1);
+
+ if (!f_thrd)
+ {
+ switch (frame)
+ {
+ case FRM_SI:
+ case FRM_GI:
+ case FRM_EI:
+ case FRM_ABS:
+ copy_index_to_record(frame_index);
+ break;
+ case FRM_LOC:
+ case FRM_TRGT:
+ break;
+ }
+ }
+
+ if (!t_thrd)
+ copy_index_to_record(target_index);
+
+ if (!t_sec)
+ copy_offset_to_record(i386, offset);
+ }
+
+ void omf_fixup(i386, segrel, loc, data_off, f_thrd, frame, t_thrd, trgt, t_sec,
+ frame_index, target_index, offset)
+ int i386, segrel;
+ unsigned char loc;
+ unsigned int data_off;
+ int f_thrd;
+ unsigned int frame;
+ int t_thrd;
+ unsigned int trgt;
+ int t_sec;
+ unsigned int frame_index, target_index;
+ long offset;
+ {
+ unsigned int locat = 0x8000;
+ unsigned char fixdat, b;
+
+ locat |= (segrel ? FIX_SEG : 0) | (loc << FIX_LOCSHFT) |
+ (data_off & FIX_DATAOFF);
+ b = (locat >> 8) & 0xff; copy_bytes_to_record(&b, 1);
+ b = locat & 0xff; copy_bytes_to_record(&b, 1);
+ generate_fixdat(i386, f_thrd, frame, t_thrd, trgt, t_sec, frame_index,
+ target_index, offset);
+ }
+
+ void omf_end_fixup()
+ {
+ output_record();
+ }
+
+ void omf_start_ledata(i386, segindex, start_offset)
+ int i386;
+ unsigned int segindex;
+ long start_offset;
+ {
+ if (i386)
+ start_record(MLED386);
+ else
+ start_record(MLEDATA);
+
+ copy_index_to_record(segindex);
+ copy_offset_to_record(i386, start_offset);
+ }
+
+ void omf_ledata(data, count)
+ unsigned char *data;
+ int count;
+ {
+ copy_bytes_to_record(data, count);
+
+ }
+
+ void omf_end_ledata()
+ {
+ output_record();
+ }
+
+ void omf_main_modend(i386, f_thrd, frame, t_thrd, trgt, t_sec, frame_index,
+ target_index, offset)
+ int i386;
+ int f_thrd;
+ unsigned int frame;
+ int t_thrd;
+ unsigned int trgt;
+ int t_sec;
+ unsigned int frame_index, target_index;
+ long offset;
+ {
+ unsigned char mtype = 0xc1;
+
+ if (i386)
+ start_record(M386END);
+ else
+ start_record(MMODEND);
+
+ copy_bytes_to_record(&mtype, 1);
+
+ generate_fixdat(i386, f_thrd, frame, t_thrd, trgt, t_sec, frame_index,
+ target_index, offset);
+ output_record();
+ }
+
+ void omf_modend(i386)
+ int i386;
+ {
+ unsigned char mtype = 0;
+
+ if (i386)
+ start_record(M386END);
+ else
+ start_record(MMODEND);
+
+ copy_bytes_to_record(&mtype, 1);
+ output_record();
+ }
+
+ /** Definitions required to produce a standard Microsoft .o file
+ */
+
+ /** LNAMES, SEGDEF, GRPDEF and COMENT stuff
+ *
+ * NB the following defines must reflect the position of the string in
+ * the lnames_tab table.
+ */
+
+ #define L_BLANK 1
+ #define L_DGROUP 2
+ #define L_UTEXT 3
+ #define L_CODE 4
+ #define L_UDATA 5
+ #define L_DATA 6
+ #define L_CONST 7
+ #define L_UBSS 8
+ #define L_BSS 9
+ #define L_TYPES 10
+ #define L_DEBTYP 11
+ #define L_SYMBOLS 12
+ #define L_DEBSYM 13
+ #define L_TSIZE 9
+ #define L_G_TSIZE 13
+
+ char *lnames_tab[] = {
+ "",
+ "",
+ "DGROUP",
+ "_TEXT",
+ "CODE",
+ "_DATA",
+ "DATA",
+ "CONST",
+ "_BSS",
+ "BSS",
+ "$$TYPES",
+ "DEBTYP",
+ "$$SYMBOLS",
+ "DEBSYM"
+ };
+
+ struct segtable {
+ unsigned char attrib;
+ long length;
+ unsigned nameindex;
+ unsigned classindex;
+ };
+
+ /* SEGDEF's */
+
+ static struct segtable segt[] = {
+ {0, NULL, 0, 0},
+ {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_UTEXT, L_CODE},
+ {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_UDATA, L_DATA},
+ {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_CONST, L_CONST},
+ {SD_DWORD|SD_PUBLIC|SD_PGRES, 0, L_UBSS, L_BSS},
+ {SD_BYTE|SD_PGRES, 0, L_SYMBOLS, L_DEBSYM},
+ {SD_BYTE|SD_PGRES, 0, L_TYPES, L_DEBTYP}
+ };
+
+ /* GRPDEF */
+
+ #define GRPTABSIZ 3
+
+ unsigned int group_tab[GRPTABSIZ] = {3, 4, 2};
+
+ /* COMENTs */
+
+ struct comment {
+ unsigned char class;
+ unsigned char count;
+ unsigned char *data;
+ };
+
+ #define NUMFIXEDCOMMENTS 4
+
+ static unsigned char gas_comment[] = "gas-1.38.1a";
+ static unsigned char lib_comment[] = "SLIBCE";
+ static unsigned char model_comment[] = "3s";
+ static unsigned char msext_comment[] = {1, 0x43, 0x56};
+
+ struct comment fix_cmnt[NUMFIXEDCOMMENTS] = {
+ {0, 8, gas_comment},
+ {0x9f, 6, lib_comment},
+ {0x9d, 2, model_comment},
+ {0xa1, 3, msext_comment}
+ };
+
+ void omf_initialize_a_out(name, text_size, data_size, bss_size, const_size,
+ gdb, syms_size, str_size)
+ unsigned char *name;
+ long text_size, data_size, bss_size, const_size;
+ int gdb;
+ long syms_size, str_size;
+ {
+ int i;
+
+ omf_theadr(name);
+
+ /* static comments */
+
+ for (i = 0; i < NUMFIXEDCOMMENTS; i++)
+ omf_coment(fix_cmnt[i].data, fix_cmnt[i].count, fix_cmnt[i].class);
+
+ /* LNAMES */
+
+ omf_start_lnames();
+ for (i = 1; i <= (gdb ? L_G_TSIZE : L_TSIZE); i++)
+ omf_lnames(lnames_tab[i]);
+ omf_end_lnames();
+
+ /* SEGDEFS */
+
+ segt[SDEF_TEXT].length = text_size;
+ segt[SDEF_DATA].length = data_size;
+ segt[SDEF_BSS].length = bss_size;
+ segt[SDEF_CONST].length = const_size;
+ if (gdb)
+ {
+ segt[SDEF_SYMBOLS].length = syms_size;
+ segt[SDEF_TYPES].length = str_size;
+ }
+ for (i = 1; i <= (gdb ? SDEF_G_SIZE : SDEF_SIZE); i++)
+ omf_segdef(I386, segt[i].attrib, 0, 0L, segt[i].length,
+ segt[i].nameindex, segt[i].classindex);
+ /* DGROUP */
+
+ omf_start_grpdef(L_DGROUP);
+ for (i = 0; i < GRPTABSIZ; i++)
+ omf_grpdef(group_tab[i]);
+ omf_end_grpdef();
+ }
*** gas-1.38/xenixomf.h
--- xenixomf.h Wed Jul 10 09:02:21 1991
***************
*** 0 ****
--- 1,140 ----
+
+ /* Defines to map a.out definitions to OMF style definitions
+ */
+ #define PUBLICDATA (N_DATA|N_EXT)
+ #define PUBLICTEXT (N_TEXT|N_EXT)
+ #define PUBLICABS (N_ABS|N_EXT)
+ #define COMMDEF(x) ((x) == (N_UNDF|N_EXT))
+ #define PRIVDATA (N_DATA)
+ #define PRIVTEXT (N_TEXT)
+ #define PRIVBSS (N_BSS)
+ #define EXTERNAL (N_UNDF)
+ #define PUBLIC(x) ((x)==PUBLICDATA || (x)==PUBLICTEXT || (x)==PUBLICABS)
+ #define EXTDEF(x) ((x)==EXTERNAL || COMMDEF(x))
+ #define PRIVATE(x) ((x)==PRIVDATA || (x)==PRIVTEXT || (x)==PRIVBSS)
+
+
+ #define MTHEADR 0x80 /* module header */
+ #define MCOMENT 0x88 /* comment */
+ #define MMODEND 0x8a /* module end */
+ #define M386END 0x8b /* 32 bit module end */
+ #define MEXTDEF 0x8c /* external definition */
+ #define MTYPDEF 0x8e /* type definition */
+ #define MPUBDEF 0x90 /* public definition */
+ #define MPUB386 0x91 /* 32 bit public definition */
+ #define MLINNUM 0x94 /* source line number */
+ #define MLIN386 0x95 /* 32 bit source line number */
+ #define MLNAMES 0x96 /* name list */
+ #define MSEGDEF 0x98 /* segment definition */
+ #define MSEG386 0x99 /* 32 bit segment definition */
+ #define MGRPDEF 0x9a /* group definition */
+ #define MFIXUPP 0x9c /* fix up previous data image */
+ #define MFIX386 0x9d /* fix up previous 32 bit data image */
+ #define MLEDATA 0xa0 /* logical data image */
+ #define MLED386 0xa1 /* 32 bit logical data image */
+ #define MCOMDEF 0xb0 /* communal names definition */
+
+ /* The maximum length of an identifier.
+ */
+
+ #define OMFNAMELENGTH 127
+
+ /* alignment required
+ */
+
+ #define SD_ABS 0x00 /* absolute */
+ #define SD_BYTE 0x20 /* byte */
+ #define SD_WORD 0x40 /* word */
+ #define SD_PARA 0x60 /* paragraph */
+ #define SD_PAGE 0x80 /* page */
+ #define SD_DWORD 0xa0 /* double word */
+ #define SD_LTL 0xc0 /* load-time locatable */
+ #define SD_ALIGN 0xe0 /* alignment mask */
+ #define SD_ASHIFT 5 /* alignment shift */
+
+ /* segment combine classes */
+
+ #define SD_PRIV 0x00 /* private, can't be combined */
+ #define SD_HCOMM 0x04 /* common, place in high mem */
+ #define SD_PUBLIC 0x08 /* public, sequential */
+ #define SD_BAD 0x0c /* undefined */
+ #define SD_C4 0x10 /* not used */
+ #define SD_STACK 0x14 /* stack segment */
+ #define SD_COMM 0x18 /* common segment */
+ #define SD_RCOMM 0x1c /* not used, reverse common segment */
+ #define SD_COMBO 0x1c /* combine mask */
+ #define SD_CSHIFT 2 /* combine shift */
+ #define SD_PGRES 0x01 /* page resident */
+ #define SD_64K 0x02 /* segment size is exactly 64k */
+
+ /* BSSDEF record definitions
+ */
+
+ #define TD_CNEAR 0x62 /* near .comm variable */
+ #define TD_CFAR 0x61 /* far .comm variable */
+
+ /* COMENT record definitions
+ */
+
+ #define CMT_PURGE 0x80 /* comment can be purged */
+ #define CMT_LIST 0x40 /* don't list when listing comments */
+
+ /* FIXUP record definitions
+ */
+
+ #define FIX_FIXUP 0x80 /* fixup is a fixup (else thread def) */
+ #define TRD_FRAME 0x40 /* thread def for a frame (else tgt) */
+ #define TRD_MTHDSHFT 2 /* frame / target method shift */
+ #define TRD_MTHDMSK 0x1c /* frame / target method mask */
+ #define TRD_THRED 0x03 /* thread number mask */
+
+ /* Target method defines. 0 - 3 are primary, they include an offset, while
+ * 4 - 7 or secondary, the offset 0 and not specified.
+ */
+
+ #define TGT_SI 0 /* target is Segment Index(N) + M */
+ #define TGT_GI 1 /* target is Group Index(N) + M */
+ #define TGT_EI 2 /* target is External Index(N) + M */
+ #define TGT_ABS 3 /* target is absolute frame N + N */
+ #define TGT_SI_0 4 /* target is Segment Index(N) + 0 */
+ #define TGT_GI_0 5 /* target is Group Index(N) + 0 */
+ #define TGT_EI_0 6 /* target is External Index(N) + 0 */
+ #define TGT_ABS_0 7 /* target is Absolute Segmnent N + 0 */
+
+ /* Frame fixup method
+ */
+
+ #define FRM_SI 0 /* Frame is Segment index(N) */
+ #define FRM_GI 1 /* Frame is Group index(N) */
+ #define FRM_EI 2 /* Frame is External index(N) */
+ #define FRM_ABS 3 /* Frame is Absolute frame(N) */
+ #define FRM_LOC 4 /* Frame is LSEG of LOCATION */
+ #define FRM_TRGT 5 /* Frame is the frame of the target */
+
+ /* FIXUP fixdat field definitions
+ */
+
+ #define FIX_SEG 0x4000 /* Fixup is seg relative (else self) */
+ #define FIX_24BIT 0x2000 /* Fixup has 24b tgt disp (NOT USED) */
+ #define FIX_LOCMSK 0x3c00 /* Fixup location type mask */
+ #define FIX_LOCSHFT 10 /* Fixup location type shift */
+ #define FIX_DATAOFF 0x3ff /* location in prev data rec of fixup */
+ #define FIXDAT_FTHRD 0x80 /* Fixup frame by thread else direct */
+ #define FIXDAT_FRAME 0x70 /* Frame thread or method mask */
+ #define FIXDAT_FRSHFT 4 /* Frame thread or method shift */
+ #define FIXDAT_TTHRD 0x08 /* Fixup target by thread else direct */
+ #define FIXDAT_TSCND 0x04 /* Primary or secondary target method */
+ #define FIXDAT_TRGT 0x03 /* Target thread or method mask */
+
+ /* Location type definitions
+ */
+
+ #define LOC_LOBYTE 0 /* low 8 bits */
+ #define LOC_OFFSET 1 /* 16 bit offset */
+ #define LOC_BASE 2 /* 16 bit frame number */
+ #define LOC_POINTER 3 /* 32 bit pointer */
+ #define LOC_HIBTE 4 /* second 8 bits */
+ #define LOC_OFFSETL 5 /* 16 bit offset (liner resolved) */
+ #define LOC_OFFSET32 9 /* 32 bit offset */
+ #define LOC_POINTER48 11 /* 48 bit pointer */
+ #define LOC_OFFSETL32 13 /* 32 bit offset (liner resolved) */
--
Steve.Bleazard@RoboBar.Co.Uk | Phone: +44 81 991 1142 x153
Snr Software Engineer, Robobar Ltd. | Fax: +44 81 998 8343 (G3)
22 Wadsworth Road, Perivale. |
Middx., UB6 7JD ENGLAND. | ...!ukc!robobar!steve