/* coff object file format with bfd
- Copyright (C) 1989, 1990, 1991, 1992 Free Software Foundation, Inc.
-
- This file is part of GAS.
-
- 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 2, 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. */
+ Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc.
+
+This file is part of GAS.
+
+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 2, 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. */
/*
-
- How does this releate to the rest of GAS ?
-
- Well, all the other files in gas are more or less a black box. It
- takes care of opening files, parsing command lines, stripping blanks
- etc etc. This module gets a chance to register what it wants to do by
- saying that it is interested in various pseduo ops. The other big
- change is write_object_file. This runs through all the data
- structures that gas builds, and outputs the file in the format of our
- choice.
-
- Hacked for BFDness by steve chamberlain
-
- This object module now supports the Hitachi H8/300 and the AMD 29k
-
- sac@cygnus.com
- */
+
+ How does this releate to the rest of GAS ?
+
+ Well, all the other files in gas are more or less a black box. It
+ takes care of opening files, parsing command lines, stripping blanks
+ etc etc. This module gets a chance to register what it wants to do by
+ saying that it is interested in various pseduo ops. The other big
+ change is write_object_file. This runs through all the data
+ structures that gas builds, and outputs the file in the format of our
+ choice.
+
+ Hacked for BFDness by steve chamberlain
+
+ This object module now supports the Hitachi H8/300 and the AMD 29k
+
+ sac@cygnus.com
+*/
#include "as.h"
#include "obstack.h"
/* This vector is used to turn an internal segment into a section #
suitable for insertion into a coff symbol table
- */
+ */
const short seg_N_TYPE[] = { /* in: segT out: N_TYPE bits */
C_ABS_SECTION,
int function_lineoff = -1; /* Offset in line#s where the last function
started (the odd entry for line #0) */
-int our_lineno_number = 0; /* we use this to build pointers from .bf's
- into the linetable. It should match
- exactly the values that are later
- assigned in text_lineno_number by
- write.c. */
-int text_lineno_number = 0;
+int had_lineno = 0;
+int had_reloc = 0;
+static symbolS*last_line_symbol;
/* Add 4 to the real value to get the index and compensate the
negatives. This vector is used by S_GET_SEGMENT to turn a coff
section number into a segment number
- */
+*/
static symbolS *previous_file_symbol = NULL;
void c_symbol_merge();
static int line_base;
bfd *abfd));
static void EXFUN(fixup_segment,(fixS * fixP,
- segT this_segment_type));
+ segT this_segment_type));
static void EXFUN(fill_section,(bfd *abfd ,
struct internal_filehdr *f, unsigned
static int
- EXFUN(c_line_new,(
- symbolS *symbol,
- long paddr,
- unsigned short line_number,
- fragS* frag));
+EXFUN(c_line_new,(
+ symbolS *symbol,
+ long paddr,
+ unsigned short line_number,
+ fragS* frag));
static void EXFUN(w_symbols,
/* Section stuff
-
+
We allow more than just the standard 3 sections, infact, we allow
10 sections, (though the usual three have to be there).
-
+
This structure performs the mappings for us:
-
- */
+
+*/
/* OBS stuff
- static struct internal_scnhdr bss_section_header;
- struct internal_scnhdr data_section_header;
- struct internal_scnhdr text_section_header;
-
- const segT N_TYPE_seg [32] =
- {
-
- };
-
- */
+static struct internal_scnhdr bss_section_header;
+struct internal_scnhdr data_section_header;
+struct internal_scnhdr text_section_header;
+
+const segT N_TYPE_seg [32] =
+{
+
+};
+
+*/
#define N_SEG 32
typedef struct
{
- segT seg_t;
- int i;
+ segT seg_t;
+int i;
} seg_info_type;
seg_info_type seg_info_off_by_4[N_SEG] =
{
- {SEG_PTV, },
- {SEG_NTV, },
- {SEG_DEBUG, },
- {SEG_ABSOLUTE, },
- {SEG_UNKNOWN, },
- {SEG_E0},
- {SEG_E1},
- {SEG_E2},
- {SEG_E3},
- {SEG_E4},
- {SEG_E5},
- {SEG_E6},
- {SEG_E7},
- {SEG_E8},
- {SEG_E9},
- {15},
- {16},
- {17},
- {18},
- {19},
- {20},
- {0},
- {0},
- {0},
- {SEG_REGISTER},0,0,0,0};
+{SEG_PTV, },
+{SEG_NTV, },
+{SEG_DEBUG, },
+{SEG_ABSOLUTE, },
+{SEG_UNKNOWN, },
+{SEG_E0},
+{SEG_E1},
+{SEG_E2},
+{SEG_E3},
+{SEG_E4},
+{SEG_E5},
+{SEG_E6},
+{SEG_E7},
+{SEG_E8},
+{SEG_E9},
+{15},
+{16},
+{17},
+{18},
+{19},
+{20},
+{0},
+{0},
+{0},
+{SEG_REGISTER},0,0,0,0};
#define SEG_INFO_FROM_SECTION_NUMBER(x) (seg_info_off_by_4[(x)+4])
#define SEG_INFO_FROM_SEG_NUMBER(x) (seg_info_off_by_4[(x)])
-relax_addressT
- DEFUN(relax_align,(address, alignment),
- register relax_addressT address AND
- register long alignment )
+ relax_addressT
+DEFUN(relax_align,(address, alignment),
+register relax_addressT address AND
+register long alignment )
{
- relax_addressT mask;
- relax_addressT new_address;
-
- mask = ~ ( (~0) << alignment );
- new_address = (address + mask) & (~ mask);
- return (new_address - address);
+ relax_addressT mask;
+ relax_addressT new_address;
+
+ mask = ~ ( (~0) << alignment );
+ new_address = (address + mask) & (~ mask);
+ return (new_address - address);
} /* relax_align() */
segT
- DEFUN(s_get_segment,(x) ,
- symbolS* x)
+DEFUN(s_get_segment,(x) ,
+symbolS* x)
{
- return SEG_INFO_FROM_SECTION_NUMBER(x->sy_symbol.ost_entry.n_scnum).seg_t;
+ return SEG_INFO_FROM_SECTION_NUMBER(x->sy_symbol.ost_entry.n_scnum).seg_t;
}
/* calculate the size of the frag chain and fill in the section header
to contain all of it, also fill in the addr of the sections */
static unsigned int DEFUN(size_section,(abfd, idx),
- bfd *abfd AND
- unsigned int idx)
+ bfd *abfd AND
+ unsigned int idx)
{
-
- unsigned int size = 0;
- fragS *frag = segment_info[idx].frchainP->frch_root;
- while (frag) {
- if (frag->fr_address != size) {
- printf("Out of step\n");
- size = frag->fr_address;
- }
- size += frag->fr_fix;
- switch (frag->fr_type) {
- case rs_fill:
- case rs_org:
- size += frag->fr_offset * frag->fr_var;
- break;
- case rs_align:
- size += relax_align(size, frag->fr_offset);
- }
- frag = frag->fr_next;
+
+ unsigned int size = 0;
+ fragS *frag = segment_info[idx].frchainP->frch_root;
+ while (frag) {
+ if (frag->fr_address != size) {
+ printf("Out of step\n");
+ size = frag->fr_address;
}
- segment_info[idx].scnhdr.s_size = size;
- return size;
+ size += frag->fr_fix;
+ switch (frag->fr_type) {
+ case rs_fill:
+ case rs_org:
+ size += frag->fr_offset * frag->fr_var;
+ break;
+ case rs_align:
+ size += relax_align(size, frag->fr_offset);
+ }
+ frag = frag->fr_next;
+ }
+ segment_info[idx].scnhdr.s_size = size;
+ return size;
}
static unsigned int DEFUN(count_entries_in_chain,(idx),
unsigned int idx)
{
- unsigned int nrelocs;
- fixS *fixup_ptr;
-
- /* Count the relocations */
- fixup_ptr = segment_info[idx].fix_root;
- nrelocs = 0;
- while (fixup_ptr != (fixS *)NULL)
- {
- if (TC_COUNT_RELOC(fixup_ptr))
- {
-
+ unsigned int nrelocs;
+ fixS *fixup_ptr;
+
+ /* Count the relocations */
+ fixup_ptr = segment_info[idx].fix_root;
+ nrelocs = 0;
+ while (fixup_ptr != (fixS *)NULL)
+ {
+ if (TC_COUNT_RELOC(fixup_ptr))
+ {
+
#ifdef TC_A29K
-
- if (fixup_ptr->fx_r_type == RELOC_CONSTH)
- nrelocs+=2;
- else
- nrelocs++;
+
+ if (fixup_ptr->fx_r_type == RELOC_CONSTH)
+ nrelocs+=2;
+ else
+ nrelocs++;
#else
- nrelocs++;
+ nrelocs++;
#endif
- }
-
- fixup_ptr = fixup_ptr->fx_next;
- }
- return nrelocs;
+ }
+
+ fixup_ptr = fixup_ptr->fx_next;
+ }
+ return nrelocs;
}
/* output all the relocations for a section */
bfd *abfd AND
unsigned long *file_cursor)
{
- unsigned int nrelocs;
- unsigned int idx;
-
- for (idx = SEG_E0; idx < SEG_E9; idx++)
- {
- if (segment_info[idx].scnhdr.s_name[0])
- {
-
- struct external_reloc *ext_ptr;
- struct external_reloc *external_reloc_vec;
- unsigned int external_reloc_size;
- unsigned int count = 0;
- unsigned int base = segment_info[idx].scnhdr.s_paddr;
- fixS * fix_ptr = segment_info[idx].fix_root;
- nrelocs = count_entries_in_chain(idx);
- external_reloc_size = nrelocs * RELSZ;
- external_reloc_vec =
- (struct external_reloc*)malloc(external_reloc_size);
-
-
-
- ext_ptr = external_reloc_vec;
-
- /* Fill in the internal coff style reloc struct from the
- internal fix list */
- while (fix_ptr)
- {
- symbolS *symbol_ptr;
- struct internal_reloc intr;
-
- /* Only output some of the relocations */
- if (TC_COUNT_RELOC(fix_ptr))
- {
+ unsigned int nrelocs;
+ unsigned int idx;
+
+ for (idx = SEG_E0; idx < SEG_E9; idx++)
+ {
+ if (segment_info[idx].scnhdr.s_name[0])
+ {
+
+ struct external_reloc *ext_ptr;
+ struct external_reloc *external_reloc_vec;
+ unsigned int external_reloc_size;
+ unsigned int count = 0;
+ unsigned int base = segment_info[idx].scnhdr.s_paddr;
+ fixS * fix_ptr = segment_info[idx].fix_root;
+ nrelocs = count_entries_in_chain(idx);
+
+ if (nrelocs)
+ had_reloc = 1;
+
+ external_reloc_size = nrelocs * RELSZ;
+ external_reloc_vec =
+ (struct external_reloc*)malloc(external_reloc_size);
+
+
+
+ ext_ptr = external_reloc_vec;
+
+ /* Fill in the internal coff style reloc struct from the
+ internal fix list */
+ while (fix_ptr)
+ {
+ symbolS *symbol_ptr;
+ struct internal_reloc intr;
+
+ /* Only output some of the relocations */
+ if (TC_COUNT_RELOC(fix_ptr))
+ {
#ifdef TC_RELOC_MANGLE
- TC_RELOC_MANGLE(fix_ptr, &intr, base);
-
+ TC_RELOC_MANGLE(fix_ptr, &intr, base);
+
#else
- symbolS *dot;
- symbol_ptr = fix_ptr->fx_addsy;
-
- intr.r_type = TC_COFF_FIX2RTYPE(fix_ptr);
- intr.r_vaddr =
- base + fix_ptr->fx_frag->fr_address + fix_ptr->fx_where ;
-
- intr.r_offset = fix_ptr->fx_offset;
-
- intr.r_offset = 0;
-
- /* Turn the segment of the symbol into an offset
- */
- if (symbol_ptr)
- {
- dot = segment_info[S_GET_SEGMENT(symbol_ptr)].dot;
- if (dot)
- {
- intr.r_symndx = dot->sy_number;
- }
- else
- {
- intr.r_symndx = symbol_ptr->sy_number;
- }
-
- }
- else
- {
- intr.r_symndx = -1;
-
-
- }
+ symbolS *dot;
+ symbol_ptr = fix_ptr->fx_addsy;
+
+ intr.r_type = TC_COFF_FIX2RTYPE(fix_ptr);
+ intr.r_vaddr =
+ base + fix_ptr->fx_frag->fr_address + fix_ptr->fx_where ;
+
+ intr.r_offset = fix_ptr->fx_offset;
+
+ intr.r_offset = 0;
+
+ /* Turn the segment of the symbol into an offset
+ */
+ if (symbol_ptr)
+ {
+ dot = segment_info[S_GET_SEGMENT(symbol_ptr)].dot;
+ if (dot)
+ {
+ intr.r_symndx = dot->sy_number;
+ }
+ else
+ {
+ intr.r_symndx = symbol_ptr->sy_number;
+ }
+
+ }
+ else
+ {
+ intr.r_symndx = -1;
+
+
+ }
#endif
-
- (void)bfd_coff_swap_reloc_out(abfd, &intr, ext_ptr);
- ext_ptr++;
-
+
+ (void)bfd_coff_swap_reloc_out(abfd, &intr, ext_ptr);
+ ext_ptr++;
+
#if defined(TC_A29K)
- /* The 29k has a special kludge for the high 16 bit reloc.
- Two relocations are emmited, R_IHIHALF, and
- R_IHCONST. The second one doesn't contain a symbol,
- but uses the value for offset */
-
- if (intr.r_type == R_IHIHALF)
- {
- /* now emit the second bit */
- intr.r_type = R_IHCONST;
- intr.r_symndx = fix_ptr->fx_addnumber;
- (void)bfd_coff_swap_reloc_out(abfd,&intr,ext_ptr);
- ext_ptr++;
- }
+ /* The 29k has a special kludge for the high 16 bit reloc.
+ Two relocations are emmited, R_IHIHALF, and
+ R_IHCONST. The second one doesn't contain a symbol,
+ but uses the value for offset */
+
+ if (intr.r_type == R_IHIHALF)
+ {
+ /* now emit the second bit */
+ intr.r_type = R_IHCONST;
+ intr.r_symndx = fix_ptr->fx_addnumber;
+ (void)bfd_coff_swap_reloc_out(abfd,&intr,ext_ptr);
+ ext_ptr++;
+ }
#endif
- }
-
- fix_ptr = fix_ptr->fx_next;
- }
-
- /* Write out the reloc table */
- segment_info[idx].scnhdr.s_relptr = *file_cursor;
- segment_info[idx].scnhdr.s_nreloc = nrelocs;
- bfd_write((PTR)external_reloc_vec, 1, external_reloc_size, abfd);
- *file_cursor += external_reloc_size;
- free( external_reloc_vec);
- }
- }
+ }
+
+ fix_ptr = fix_ptr->fx_next;
+ }
+
+ /* Write out the reloc table */
+ segment_info[idx].scnhdr.s_relptr = *file_cursor;
+ segment_info[idx].scnhdr.s_nreloc = nrelocs;
+ bfd_write((PTR)external_reloc_vec, 1, external_reloc_size, abfd);
+ *file_cursor += external_reloc_size;
+ free( external_reloc_vec);
+ }
+ }
}
/* run through a frag chain and write out the data to go with it, fill
in the scnhdrs with the info on the file postions
- */
+*/
static void DEFUN(fill_section,(abfd, filehdr, file_cursor),
bfd *abfd AND
struct internal_filehdr *filehdr AND
unsigned long *file_cursor)
{
-
- unsigned int i;
- unsigned int paddr = 0;
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- unsigned int offset = 0;
-
- struct internal_scnhdr *s = &( segment_info[i].scnhdr);
-
- if (s->s_name[0])
- {
- fragS *frag = segment_info[i].frchainP->frch_root;
- char *buffer = malloc(s->s_size);
- s->s_scnptr = *file_cursor;
- s->s_paddr = paddr;
- s->s_vaddr = paddr;
-
- s->s_flags = STYP_REG;
- if (strcmp(s->s_name,".text")==0)
- s->s_flags |= STYP_TEXT;
- else if (strcmp(s->s_name,".data")==0)
- s->s_flags |= STYP_DATA;
- else if (strcmp(s->s_name,".bss")==0)
- s->s_flags |= STYP_BSS | STYP_NOLOAD;
-
- while (frag) {
- unsigned int fill_size;
- switch (frag->fr_type) {
-
- case rs_fill:
- case rs_align:
- case rs_org:
- if(frag->fr_fix)
- {
- memcpy(buffer + frag->fr_address,
- frag->fr_literal,
- frag->fr_fix);
- offset += frag->fr_fix;
- }
-
- fill_size = frag->fr_var;
- if (fill_size)
- {
- unsigned int count ;
- unsigned int off = frag->fr_fix;
- for (count = frag->fr_offset; count; count--)
- {
- memcpy(buffer + frag->fr_address + off,
- frag->fr_literal + frag->fr_fix,
- fill_size);
- off += fill_size;
- offset += fill_size;
-
- }
-
- }
- break;
- default:
- abort();
- }
- frag = frag->fr_next;
- }
-
-
- bfd_write(buffer, s->s_size,1,abfd);
- free(buffer);
-
- *file_cursor += s->s_size;
- paddr += s->s_size;
- }
+
+ unsigned int i;
+ unsigned int paddr = 0;
+
+ for (i = SEG_E0; i < SEG_UNKNOWN; i++)
+ {
+ unsigned int offset = 0;
+
+ struct internal_scnhdr *s = &( segment_info[i].scnhdr);
+
+ if (s->s_name[0])
+ {
+ fragS *frag = segment_info[i].frchainP->frch_root;
+ char *buffer = malloc(s->s_size);
+ if (s->s_size != 0)
+ {
+ s->s_scnptr = *file_cursor;
+ s->s_paddr = paddr;
+ s->s_vaddr = paddr;
+
+ }
+ else
+ {
+ s->s_scnptr = 0;
+ s->s_paddr = 0;
+ s->s_vaddr = 0;
+
+ }
+
+
+ s->s_flags = STYP_REG;
+ if (strcmp(s->s_name,".text")==0)
+ s->s_flags |= STYP_TEXT;
+ else if (strcmp(s->s_name,".data")==0)
+ s->s_flags |= STYP_DATA;
+ else if (strcmp(s->s_name,".bss")==0)
+ s->s_flags |= STYP_BSS | STYP_NOLOAD;
+
+ while (frag) {
+ unsigned int fill_size;
+ switch (frag->fr_type) {
+
+ case rs_fill:
+ case rs_align:
+ case rs_org:
+ if(frag->fr_fix)
+ {
+ memcpy(buffer + frag->fr_address,
+ frag->fr_literal,
+ frag->fr_fix);
+ offset += frag->fr_fix;
+ }
+
+ fill_size = frag->fr_var;
+ if (fill_size)
+ {
+ unsigned int count ;
+ unsigned int off = frag->fr_fix;
+ for (count = frag->fr_offset; count; count--)
+ {
+ memcpy(buffer + frag->fr_address + off,
+ frag->fr_literal + frag->fr_fix,
+ fill_size);
+ off += fill_size;
+ offset += fill_size;
+
+ }
+
+ }
+ break;
+ default:
+ abort();
+ }
+ frag = frag->fr_next;
}
-
+
+
+ bfd_write(buffer, s->s_size,1,abfd);
+ free(buffer);
+
+ *file_cursor += s->s_size;
+ paddr += s->s_size;
+ }
+ }
+
}
static void
- DEFUN(coff_header_append,(abfd, filehdr, aouthdr),
- bfd *abfd AND
- struct internal_filehdr *filehdr AND
- struct internal_aouthdr *aouthdr)
+DEFUN(coff_header_append,(abfd, filehdr, aouthdr),
+ bfd *abfd AND
+ struct internal_filehdr *filehdr AND
+ struct internal_aouthdr *aouthdr)
{
- unsigned int i;
- char buffer[1000];
- char buffero[1000];
-
- bfd_seek(abfd, 0, 0);
+ unsigned int i;
+ char buffer[1000];
+ char buffero[1000];
+
+ bfd_seek(abfd, 0, 0);
#if 0
- filehdr.f_opthdr = bfd_coff_swap_aouthdr_out(abfd, aouthdr,
- buffero);
+ filehdr.f_opthdr = bfd_coff_swap_aouthdr_out(abfd, aouthdr,
+ buffero);
#else
- filehdr->f_opthdr = 0;
+ filehdr->f_opthdr = 0;
#endif
- i = bfd_coff_swap_filehdr_out(abfd, filehdr, buffer);
-
- bfd_write(buffer, i ,1, abfd);
- bfd_write(buffero, filehdr->f_opthdr, 1, abfd);
-
- for (i = SEG_E0; i < SEG_E9; i++)
- {
- if (segment_info[i].scnhdr.s_name[0])
- {
- unsigned int size =
- bfd_coff_swap_scnhdr_out(abfd,
- &(segment_info[i].scnhdr),
- buffer);
- bfd_write(buffer, size, 1, abfd);
- }
- }
+ i = bfd_coff_swap_filehdr_out(abfd, filehdr, buffer);
+
+ bfd_write(buffer, i ,1, abfd);
+ bfd_write(buffero, filehdr->f_opthdr, 1, abfd);
+
+ for (i = SEG_E0; i < SEG_E9; i++)
+ {
+ if (segment_info[i].scnhdr.s_name[0])
+ {
+ unsigned int size =
+ bfd_coff_swap_scnhdr_out(abfd,
+ &(segment_info[i].scnhdr),
+ buffer);
+ bfd_write(buffer, size, 1, abfd);
+ }
+ }
}
char *
- DEFUN(symbol_to_chars,(abfd, where, symbolP),
- bfd*abfd AND
- char *where AND
- symbolS *symbolP)
+DEFUN(symbol_to_chars,(abfd, where, symbolP),
+ bfd*abfd AND
+ char *where AND
+ symbolS *symbolP)
{
- unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux;
- unsigned int i;
-
- /* Turn any symbols with register attributes into abs symbols */
- if (S_GET_SEGMENT(symbolP) == SEG_REGISTER)
- {
- S_SET_SEGMENT(symbolP, SEG_ABSOLUTE);
- }
- /* At the same time, relocate all symbols to their output value */
-
- S_SET_VALUE(symbolP,
- segment_info[S_GET_SEGMENT(symbolP)].scnhdr.s_paddr
- + S_GET_VALUE(symbolP));
-
- where += bfd_coff_swap_sym_out(abfd, &symbolP->sy_symbol.ost_entry,
+ unsigned int numaux = symbolP->sy_symbol.ost_entry.n_numaux;
+ unsigned int i;
+
+ /* Turn any symbols with register attributes into abs symbols */
+ if (S_GET_SEGMENT(symbolP) == SEG_REGISTER)
+ {
+ S_SET_SEGMENT(symbolP, SEG_ABSOLUTE);
+ }
+ /* At the same time, relocate all symbols to their output value */
+
+ S_SET_VALUE(symbolP,
+ segment_info[S_GET_SEGMENT(symbolP)].scnhdr.s_paddr
+ + S_GET_VALUE(symbolP));
+
+ where += bfd_coff_swap_sym_out(abfd, &symbolP->sy_symbol.ost_entry,
+ where);
+
+ for (i = 0; i < numaux; i++)
+ {
+ where += bfd_coff_swap_aux_out(abfd,
+ &symbolP->sy_symbol.ost_auxent[i],
+ S_GET_DATA_TYPE(symbolP),
+ S_GET_STORAGE_CLASS(symbolP),
where);
-
- for (i = 0; i < numaux; i++)
- {
- where += bfd_coff_swap_aux_out(abfd,
- &symbolP->sy_symbol.ost_auxent[i],
- S_GET_DATA_TYPE(symbolP),
- S_GET_STORAGE_CLASS(symbolP),
- where);
- }
- return where;
-
+ }
+ return where;
+
}
symbolS *symbolP;
{
char underscore = 0; /* Symbol has leading _ */
-
+
/* Effective symbol */
/* Store the pointer in the offset. */
S_SET_ZEROES(symbolP, 0L);
/* Additional information */
symbolP->sy_symbol.ost_flags = 0;
/* Auxiliary entries */
- memset((char*) &symbolP->sy_symbol.ost_auxent[0], '\0', AUXESZ);
-
+ bzero((char*)&symbolP->sy_symbol.ost_auxent[0], AUXESZ);
+
#ifdef STRIP_UNDERSCORE
/* Remove leading underscore at the beginning of the symbol.
* This is to be compatible with the standard librairies.
S_SET_NAME(symbolP, S_GET_NAME(symbolP) + 1);
} /* strip underscore */
#endif /* STRIP_UNDERSCORE */
-
+
if (S_IS_STRING(symbolP))
SF_SET_STRING(symbolP);
if (!underscore && S_IS_LOCAL(symbolP))
SF_SET_LOCAL(symbolP);
-
+
return;
} /* obj_symbol_new_hook() */
-/* stack stuff */
+ /* stack stuff */
stack* stack_init(chunk_size, element_size)
unsigned long chunk_size;
unsigned long element_size;
{
stack* st;
-
+
if ((st = (stack*)malloc(sizeof(stack))) == (stack*)0)
return (stack*)0;
if ((st->data = malloc(chunk_size)) == (char*)0) {
void stack_delete(st)
stack* st;
{
- free(st->data);
- free(st);
+ free(st->data);
+ free(st);
}
char *stack_push(st, element)
char* stack_pop(st)
stack* st;
{
- if ((st->pointer -= st->element_size) < 0) {
- st->pointer = 0;
- return (char*)0;
- }
-
- return st->data + st->pointer;
+ if ((st->pointer -= st->element_size) < 0) {
+ st->pointer = 0;
+ return (char*)0;
+ }
+
+ return st->data + st->pointer;
}
char* stack_top(st)
stack* st;
{
- return st->data + st->pointer - st->element_size;
+ return st->data + st->pointer - st->element_size;
}
static void obj_coff_ln()
{
- int l;
-
- if (def_symbol_in_progress != NULL) {
- as_warn(".ln pseudo-op inside .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* wrong context */
-
- c_line_new(0,
- obstack_next_free(&frags) - frag_now->fr_literal,
- l = get_absolute_expression(),
- frag_now);
+ int l;
+
+ if (def_symbol_in_progress != NULL) {
+ as_warn(".ln pseudo-op inside .def/.endef: ignored.");
+ demand_empty_rest_of_line();
+ return;
+ } /* wrong context */
+
+ c_line_new(0,
+ obstack_next_free(&frags) - frag_now->fr_literal,
+ l = get_absolute_expression(),
+ frag_now);
#ifndef NO_LISTING
- {
- extern int listing;
-
- if (listing)
- {
- listing_source_line(l + line_base - 1);
- }
-
- }
+{
+ extern int listing;
+
+ if (listing)
+ {
+ listing_source_line(l + line_base - 1);
+ }
+
+}
#endif
- demand_empty_rest_of_line();
- return;
+ demand_empty_rest_of_line();
+ return;
} /* obj_coff_line() */
/*
#define SKIP_SEMI_COLON() while (*input_line_pointer++ != ';')
#define SKIP_WHITESPACES() while (*input_line_pointer == ' ' || \
- *input_line_pointer == '\t') \
- input_line_pointer++;
+ *input_line_pointer == '\t') \
+ input_line_pointer++;
static void
- DEFUN(obj_coff_def,(what),
- int what)
+DEFUN(obj_coff_def,(what),
+ int what)
{
- char name_end; /* Char after the end of name */
- char *symbol_name; /* Name of the debug symbol */
- char *symbol_name_copy; /* Temporary copy of the name */
- unsigned int symbol_name_length;
- /*$char* directiveP;$ */ /* Name of the pseudo opcode */
- /*$char directive[MAX_DIRECTIVE];$ */ /* Backup of the directive */
- /*$char end = 0;$ */ /* If 1, stop parsing */
-
- if (def_symbol_in_progress != NULL) {
- as_warn(".def pseudo-op used inside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
+ char name_end; /* Char after the end of name */
+ char *symbol_name; /* Name of the debug symbol */
+ char *symbol_name_copy; /* Temporary copy of the name */
+ unsigned int symbol_name_length;
+ /*$char* directiveP;$ */ /* Name of the pseudo opcode */
+ /*$char directive[MAX_DIRECTIVE];$ */ /* Backup of the directive */
+ /*$char end = 0;$ */ /* If 1, stop parsing */
+
+ if (def_symbol_in_progress != NULL) {
+ as_warn(".def pseudo-op used inside of .def/.endef: ignored.");
+ demand_empty_rest_of_line();
+ return;
} /* if not inside .def/.endef */
-
- SKIP_WHITESPACES();
-
- def_symbol_in_progress = (symbolS *) obstack_alloc(¬es, sizeof(*def_symbol_in_progress));
- memset(def_symbol_in_progress, '\0', sizeof(*def_symbol_in_progress));
-
- symbol_name = input_line_pointer;
- name_end = get_symbol_end();
- symbol_name_length = strlen(symbol_name);
- symbol_name_copy = xmalloc(symbol_name_length + 1);
- strcpy(symbol_name_copy, symbol_name);
-
- /* Initialize the new symbol */
+
+ SKIP_WHITESPACES();
+
+ def_symbol_in_progress = (symbolS *) obstack_alloc(¬es, sizeof(*def_symbol_in_progress));
+ bzero(def_symbol_in_progress, sizeof(*def_symbol_in_progress));
+
+ symbol_name = input_line_pointer;
+ name_end = get_symbol_end();
+ symbol_name_length = strlen(symbol_name);
+ symbol_name_copy = xmalloc(symbol_name_length + 1);
+ strcpy(symbol_name_copy, symbol_name);
+
+ /* Initialize the new symbol */
#ifdef STRIP_UNDERSCORE
- S_SET_NAME(def_symbol_in_progress, (*symbol_name_copy == '_'
- ? symbol_name_copy + 1
- : symbol_name_copy));
+ S_SET_NAME(def_symbol_in_progress, (*symbol_name_copy == '_'
+ ? symbol_name_copy + 1
+ : symbol_name_copy));
#else /* STRIP_UNDERSCORE */
- S_SET_NAME(def_symbol_in_progress, symbol_name_copy);
+ S_SET_NAME(def_symbol_in_progress, symbol_name_copy);
#endif /* STRIP_UNDERSCORE */
- /* free(symbol_name_copy); */
- def_symbol_in_progress->sy_name_offset = ~0;
- def_symbol_in_progress->sy_number = ~0;
- def_symbol_in_progress->sy_frag = &zero_address_frag;
-
- if (S_IS_STRING(def_symbol_in_progress)) {
- SF_SET_STRING(def_symbol_in_progress);
+ /* free(symbol_name_copy); */
+ def_symbol_in_progress->sy_name_offset = ~0;
+ def_symbol_in_progress->sy_number = ~0;
+ def_symbol_in_progress->sy_frag = &zero_address_frag;
+
+ if (S_IS_STRING(def_symbol_in_progress)) {
+ SF_SET_STRING(def_symbol_in_progress);
} /* "long" name */
-
- *input_line_pointer = name_end;
-
- demand_empty_rest_of_line();
- return;
+
+ *input_line_pointer = name_end;
+
+ demand_empty_rest_of_line();
+ return;
} /* obj_coff_def() */
unsigned int dim_index;
static void
- DEFUN_VOID(obj_coff_endef)
+DEFUN_VOID(obj_coff_endef)
{
- symbolS *symbolP = 0;
- /* DIM BUG FIX sac@cygnus.com */
- dim_index =0;
- if (def_symbol_in_progress == NULL) {
- as_warn(".endef pseudo-op used outside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
+ symbolS *symbolP = 0;
+ /* DIM BUG FIX sac@cygnus.com */
+ dim_index =0;
+ if (def_symbol_in_progress == NULL) {
+ as_warn(".endef pseudo-op used outside of .def/.endef: ignored.");
+ demand_empty_rest_of_line();
+ return;
} /* if not inside .def/.endef */
-
- /* Set the section number according to storage class. */
- switch (S_GET_STORAGE_CLASS(def_symbol_in_progress)) {
- case C_STRTAG:
- case C_ENTAG:
- case C_UNTAG:
- SF_SET_TAG(def_symbol_in_progress);
- /* intentional fallthrough */
- case C_FILE:
- case C_TPDEF:
- SF_SET_DEBUG(def_symbol_in_progress);
- S_SET_SEGMENT(def_symbol_in_progress, SEG_DEBUG);
- break;
-
- case C_EFCN:
- SF_SET_LOCAL(def_symbol_in_progress); /* Do not emit this symbol. */
- /* intentional fallthrough */
- case C_BLOCK:
- SF_SET_PROCESS(def_symbol_in_progress); /* Will need processing before writing */
- /* intentional fallthrough */
- case C_FCN:
- S_SET_SEGMENT(def_symbol_in_progress, SEG_E0);
-
- if (def_symbol_in_progress->sy_symbol.ost_entry.n_name[1] == 'b') { /* .bf */
- if (function_lineoff < 0) {
- fprintf(stderr, "`.bf' symbol without preceding function\n");
+
+ /* Set the section number according to storage class. */
+ switch (S_GET_STORAGE_CLASS(def_symbol_in_progress)) {
+ case C_STRTAG:
+ case C_ENTAG:
+ case C_UNTAG:
+ SF_SET_TAG(def_symbol_in_progress);
+ /* intentional fallthrough */
+ case C_FILE:
+ case C_TPDEF:
+ SF_SET_DEBUG(def_symbol_in_progress);
+ S_SET_SEGMENT(def_symbol_in_progress, SEG_DEBUG);
+ break;
+
+ case C_EFCN:
+ SF_SET_LOCAL(def_symbol_in_progress); /* Do not emit this symbol. */
+ /* intentional fallthrough */
+ case C_BLOCK:
+ SF_SET_PROCESS(def_symbol_in_progress); /* Will need processing before writing */
+ /* intentional fallthrough */
+ case C_FCN:
+ S_SET_SEGMENT(def_symbol_in_progress, SEG_E0);
+
+ if (def_symbol_in_progress->sy_symbol.ost_entry._n._n_nptr[1][1] == 'b') { /* .bf */
+ if (function_lineoff < 0) {
+ fprintf(stderr, "`.bf' symbol without preceding function\n");
} /* missing function symbol */
- SA_GET_SYM_LNNOPTR(def_symbol_in_progress) = function_lineoff;
- SF_SET_PROCESS(def_symbol_in_progress); /* Will need relocating */
- function_lineoff = -1;
+ SA_GET_SYM_LNNOPTR(last_line_symbol) = function_lineoff;
+
+ SF_SET_PROCESS(last_line_symbol);
+ function_lineoff = -1;
}
- break;
-
+ break;
+
#ifdef C_AUTOARG
- case C_AUTOARG:
+ case C_AUTOARG:
#endif /* C_AUTOARG */
- case C_AUTO:
- case C_REG:
- case C_MOS:
- case C_MOE:
- case C_MOU:
- case C_ARG:
- case C_REGPARM:
- case C_FIELD:
- case C_EOS:
- SF_SET_DEBUG(def_symbol_in_progress);
- S_SET_SEGMENT(def_symbol_in_progress, SEG_ABSOLUTE);
- break;
-
- case C_EXT:
- case C_STAT:
- case C_LABEL:
- /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
- break;
-
- case C_USTATIC:
- case C_EXTDEF:
- case C_ULABEL:
- as_warn("unexpected storage class %d", S_GET_STORAGE_CLASS(def_symbol_in_progress));
- break;
+ case C_AUTO:
+ case C_REG:
+ case C_MOS:
+ case C_MOE:
+ case C_MOU:
+ case C_ARG:
+ case C_REGPARM:
+ case C_FIELD:
+ case C_EOS:
+ SF_SET_DEBUG(def_symbol_in_progress);
+ S_SET_SEGMENT(def_symbol_in_progress, SEG_ABSOLUTE);
+ break;
+
+ case C_EXT:
+ case C_STAT:
+ case C_LABEL:
+ /* Valid but set somewhere else (s_comm, s_lcomm, colon) */
+ break;
+
+ case C_USTATIC:
+ case C_EXTDEF:
+ case C_ULABEL:
+ as_warn("unexpected storage class %d", S_GET_STORAGE_CLASS(def_symbol_in_progress));
+ break;
} /* switch on storage class */
-
- /* Now that we have built a debug symbol, try to
- find if we should merge with an existing symbol
- or not. If a symbol is C_EFCN or SEG_ABSOLUTE or
- untagged SEG_DEBUG it never merges. */
-
- /* Two cases for functions. Either debug followed
- by definition or definition followed by debug.
- For definition first, we will merge the debug
- symbol into the definition. For debug first, the
- lineno entry MUST point to the definition
- function or else it will point off into space
- when crawl_symbols() merges the debug
- symbol into the real symbol. Therefor, let's
- presume the debug symbol is a real function
- reference. */
-
- /* FIXME-SOON If for some reason the definition
- label/symbol is never seen, this will probably
- leave an undefined symbol at link time. */
-
- if (S_GET_STORAGE_CLASS(def_symbol_in_progress) == C_EFCN
- || (S_GET_SEGMENT(def_symbol_in_progress) == SEG_DEBUG
- && !SF_GET_TAG(def_symbol_in_progress))
- || S_GET_SEGMENT(def_symbol_in_progress) == SEG_ABSOLUTE
- || (symbolP = symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP)) == NULL) {
-
- symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
-
+
+ /* Now that we have built a debug symbol, try to
+ find if we should merge with an existing symbol
+ or not. If a symbol is C_EFCN or SEG_ABSOLUTE or
+ untagged SEG_DEBUG it never merges. */
+
+ /* Two cases for functions. Either debug followed
+ by definition or definition followed by debug.
+ For definition first, we will merge the debug
+ symbol into the definition. For debug first, the
+ lineno entry MUST point to the definition
+ function or else it will point off into space
+ when crawl_symbols() merges the debug
+ symbol into the real symbol. Therefor, let's
+ presume the debug symbol is a real function
+ reference. */
+
+ /* FIXME-SOON If for some reason the definition
+ label/symbol is never seen, this will probably
+ leave an undefined symbol at link time. */
+
+ if (S_GET_STORAGE_CLASS(def_symbol_in_progress) == C_EFCN
+ || (S_GET_SEGMENT(def_symbol_in_progress) == SEG_DEBUG
+ && !SF_GET_TAG(def_symbol_in_progress))
+ || S_GET_SEGMENT(def_symbol_in_progress) == SEG_ABSOLUTE
+ || (symbolP = symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP)) == NULL) {
+
+ symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
+
} else {
/* This symbol already exists, merge the
newly created symbol into the old one.
guess that it save a *lot* of space if
the assembly file defines a lot of
symbols. [loic] */
-
+
/* The debug entry (def_symbol_in_progress)
is merged into the previous definition. */
-
+
c_symbol_merge(def_symbol_in_progress, symbolP);
/* FIXME-SOON Should *def_symbol_in_progress be free'd? xoxorich. */
def_symbol_in_progress = symbolP;
-
+
if (SF_GET_FUNCTION(def_symbol_in_progress)
|| SF_GET_TAG(def_symbol_in_progress)) {
/* For functions, and tags, the symbol *must* be where the debug symbol
if (def_symbol_in_progress != symbol_lastP) {
symbol_remove(def_symbol_in_progress, &symbol_rootP, &symbol_lastP);
symbol_append(def_symbol_in_progress, symbol_lastP, &symbol_rootP, &symbol_lastP);
- } /* if not already in place */
- } /* if function */
- } /* normal or mergable */
-
- if (SF_GET_TAG(def_symbol_in_progress)
- && symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP) == NULL) {
- tag_insert(S_GET_NAME(def_symbol_in_progress), def_symbol_in_progress);
+ } /* if not already in place */
+ } /* if function */
+ } /* normal or mergable */
+
+ if (SF_GET_TAG(def_symbol_in_progress)
+ && symbol_find_base(S_GET_NAME(def_symbol_in_progress), DO_NOT_STRIP) == NULL) {
+ tag_insert(S_GET_NAME(def_symbol_in_progress), def_symbol_in_progress);
} /* If symbol is a {structure,union} tag, associate symbol to its name. */
-
- if (SF_GET_FUNCTION(def_symbol_in_progress)) {
- know(sizeof(def_symbol_in_progress) <= sizeof(long));
- function_lineoff
- = c_line_new(def_symbol_in_progress,0, 0, &zero_address_frag);
-
-
-
- SF_SET_PROCESS(def_symbol_in_progress);
-
- if (symbolP == NULL) {
- /* That is, if this is the first
- time we've seen the function... */
- symbol_table_insert(def_symbol_in_progress);
+
+ if (SF_GET_FUNCTION(def_symbol_in_progress)) {
+ know(sizeof(def_symbol_in_progress) <= sizeof(long));
+ function_lineoff
+ = c_line_new(def_symbol_in_progress,0, 0, &zero_address_frag);
+
+
+
+ SF_SET_PROCESS(def_symbol_in_progress);
+
+ if (symbolP == NULL) {
+ /* That is, if this is the first
+ time we've seen the function... */
+ symbol_table_insert(def_symbol_in_progress);
} /* definition follows debug */
} /* Create the line number entry pointing to the function being defined */
-
- def_symbol_in_progress = NULL;
- demand_empty_rest_of_line();
- return;
+
+ def_symbol_in_progress = NULL;
+ demand_empty_rest_of_line();
+ return;
} /* obj_coff_endef() */
static void
- DEFUN_VOID(obj_coff_dim)
+DEFUN_VOID(obj_coff_dim)
{
- register int dim_index;
-
- if (def_symbol_in_progress == NULL)
- {
- as_warn(".dim pseudo-op used outside of .def/.endef: ignored.");
- demand_empty_rest_of_line();
- return;
- } /* if not inside .def/.endef */
-
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
-
- for (dim_index = 0; dim_index < DIMNUM; dim_index++)
- {
- SKIP_WHITESPACES();
- SA_SET_SYM_DIMEN(def_symbol_in_progress, dim_index, get_absolute_expression());
-
- switch (*input_line_pointer)
- {
-
- case ',':
- input_line_pointer++;
- break;
-
- default:
- as_warn("badly formed .dim directive ignored");
- /* intentional fallthrough */
- case '\n':
- case ';':
- dim_index = DIMNUM;
- break;
- } /* switch on following character */
- } /* for each dimension */
-
+ register int dim_index;
+
+ if (def_symbol_in_progress == NULL)
+ {
+ as_warn(".dim pseudo-op used outside of .def/.endef: ignored.");
demand_empty_rest_of_line();
return;
+ } /* if not inside .def/.endef */
+
+ S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
+
+ for (dim_index = 0; dim_index < DIMNUM; dim_index++)
+ {
+ SKIP_WHITESPACES();
+ SA_SET_SYM_DIMEN(def_symbol_in_progress, dim_index, get_absolute_expression());
+
+ switch (*input_line_pointer)
+ {
+
+ case ',':
+ input_line_pointer++;
+ break;
+
+ default:
+ as_warn("badly formed .dim directive ignored");
+ /* intentional fallthrough */
+ case '\n':
+ case ';':
+ dim_index = DIMNUM;
+ break;
+ } /* switch on following character */
+ } /* for each dimension */
+
+ demand_empty_rest_of_line();
+ return;
} /* obj_coff_dim() */
static void obj_coff_line()
{
- int this_base;
-
- if (def_symbol_in_progress == NULL) {
- obj_coff_ln();
- return;
- } /* if it looks like a stabs style line */
-
- this_base = get_absolute_expression();
- if (this_base > line_base)
- {
- line_base = this_base;
- }
-
-
+ int this_base;
+
+ if (def_symbol_in_progress == NULL) {
+ obj_coff_ln();
+ return;
+ } /* if it looks like a stabs style line */
+
+ this_base = get_absolute_expression();
+ if (this_base > line_base)
+ {
+ line_base = this_base;
+ }
+
+
#ifndef NO_LISTING
- {
- extern int listing;
- if (listing && 0) {
- listing_source_line(line_base);
- }
- }
+{
+ extern int listing;
+ if (listing && 0) {
+ listing_source_line(line_base);
+ }
+}
#endif
- S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
- SA_SET_SYM_LNNO(def_symbol_in_progress, line_base);
-
- demand_empty_rest_of_line();
- return;
+ S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
+ SA_SET_SYM_LNNO(def_symbol_in_progress, line_base);
+
+ demand_empty_rest_of_line();
+ return;
} /* obj_coff_line() */
static void obj_coff_size() {
demand_empty_rest_of_line();
return;
} /* if not inside .def/.endef */
-
+
S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
SA_SET_SYM_SIZE(def_symbol_in_progress, get_absolute_expression());
demand_empty_rest_of_line();
demand_empty_rest_of_line();
return;
} /* if not inside .def/.endef */
-
+
S_SET_STORAGE_CLASS(def_symbol_in_progress, get_absolute_expression());
demand_empty_rest_of_line();
return;
static void obj_coff_tag() {
char *symbol_name;
char name_end;
-
+
if (def_symbol_in_progress == NULL) {
as_warn(".tag pseudo-op used outside of .def/.endef ignored.");
demand_empty_rest_of_line();
return;
} /* if not inside .def/.endef */
-
+
S_SET_NUMBER_AUXILIARY(def_symbol_in_progress, 1);
symbol_name = input_line_pointer;
name_end = get_symbol_end();
-
+
/* Assume that the symbol referred to by .tag is always defined. */
/* This was a bad assumption. I've added find_or_make. xoxorich. */
SA_SET_SYM_TAGNDX(def_symbol_in_progress, (long) tag_find_or_make(symbol_name));
if (SA_GET_SYM_TAGNDX(def_symbol_in_progress) == 0L) {
as_warn("tag not found for .tag %s", symbol_name);
} /* not defined */
-
+
SF_SET_TAGGED(def_symbol_in_progress);
*input_line_pointer = name_end;
-
+
demand_empty_rest_of_line();
return;
} /* obj_coff_tag() */
demand_empty_rest_of_line();
return;
} /* if not inside .def/.endef */
-
+
S_SET_DATA_TYPE(def_symbol_in_progress, get_absolute_expression());
-
+
if (ISFCN(S_GET_DATA_TYPE(def_symbol_in_progress)) &&
S_GET_STORAGE_CLASS(def_symbol_in_progress) != C_TPDEF) {
SF_SET_FUNCTION(def_symbol_in_progress);
} /* is a function */
-
+
demand_empty_rest_of_line();
return;
} /* obj_coff_type() */
demand_empty_rest_of_line();
return;
} /* if not inside .def/.endef */
-
+
if (is_name_beginner(*input_line_pointer)) {
char *symbol_name = input_line_pointer;
char name_end = get_symbol_end();
-
+
if (!strcmp(symbol_name, ".")) {
def_symbol_in_progress->sy_frag = frag_now;
S_SET_VALUE(def_symbol_in_progress, obstack_next_free(&frags) - frag_now->fr_literal);
/* If the .val is != from the .def (e.g. statics) */
} else if (strcmp(S_GET_NAME(def_symbol_in_progress), symbol_name)) {
def_symbol_in_progress->sy_forward = symbol_find_or_make(symbol_name);
-
+
/* If the segment is undefined when the forward
reference is solved, then copy the segment id
from the forward symbol. */
} else {
S_SET_VALUE(def_symbol_in_progress, get_absolute_expression());
} /* if symbol based */
-
+
demand_empty_rest_of_line();
return;
} /* obj_coff_val() */
*/
static void tag_init() {
- tag_hash = hash_new();
- return ;
+ tag_hash = hash_new();
+ return ;
} /* tag_init() */
static void tag_insert(name, symbolP)
symbolS *symbolP;
{
register char * error_string;
-
+
if (*(error_string = hash_jam(tag_hash, name, (char *)symbolP))) {
as_fatal("Inserting \"%s\" into structure table failed: %s",
name, error_string);
char *name;
{
symbolS *symbolP;
-
+
if ((symbolP = tag_find(name)) == NULL) {
symbolP = symbol_new(name,
SEG_UNKNOWN,
0,
&zero_address_frag);
-
+
tag_insert(S_GET_NAME(symbolP), symbolP);
symbol_table_insert(symbolP);
} /* not found */
-
+
return(symbolP);
} /* tag_find_or_make() */
} /* tag_find() */
void obj_read_begin_hook() {
- /* These had better be the same. Usually 18 bytes. */
+ /* These had better be the same. Usually 18 bytes. */
#ifndef BFD_HEADERS
know(sizeof(SYMENT) == sizeof(AUXENT));
know(SYMESZ == AUXESZ);
#endif
tag_init();
-
+
return;
} /* obj_read_begin_hook() */
symbolS *symbol_extern_lastP = NULL;
stack*block_stack;
-symbolS *last_functionP = NULL;
-symbolS *last_tagP;
+ symbolS *last_functionP = NULL;
+ symbolS *last_tagP;
static unsigned int DEFUN_VOID(yank_symbols)
{
- symbolS *symbolP;
- unsigned int symbol_number =0;
-
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbolP ? symbol_next(symbolP) : symbol_rootP) {
- if (!SF_GET_DEBUG(symbolP)) {
- /* Debug symbols do not need all this rubbish */
- symbolS* real_symbolP;
-
- /* L* and C_EFCN symbols never merge. */
- if (!SF_GET_LOCAL(symbolP)
- && (real_symbolP = symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP))
- && real_symbolP != symbolP) {
- /* FIXME-SOON: where do dups come from?
- Maybe tag references before definitions? xoxorich. */
- /* Move the debug data from the debug symbol to the
- real symbol. Do NOT do the oposite (i.e. move from
- real symbol to debug symbol and remove real symbol from the
- list.) Because some pointers refer to the real symbol
- whereas no pointers refer to the debug symbol. */
- c_symbol_merge(symbolP, real_symbolP);
- /* Replace the current symbol by the real one */
- /* The symbols will never be the last or the first
- because : 1st symbol is .file and 3 last symbols are
- .text, .data, .bss */
- symbol_remove(real_symbolP, &symbol_rootP, &symbol_lastP);
- symbol_insert(real_symbolP, symbolP, &symbol_rootP, &symbol_lastP);
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbolP = real_symbolP;
- } /* if not local but dup'd */
-
- if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_E1)) {
- S_SET_SEGMENT(symbolP, SEG_E0);
- } /* push data into text */
-
- S_SET_VALUE(symbolP,
- S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
-
- if (!S_IS_DEFINED(symbolP) && !SF_GET_LOCAL(symbolP))
- {
- S_SET_EXTERNAL(symbolP);
- }
- else if (S_GET_STORAGE_CLASS(symbolP) == C_NULL)
- {
- if (S_GET_SEGMENT(symbolP) == SEG_E0)
- {
- S_SET_STORAGE_CLASS(symbolP, C_LABEL);
- }
- else
- {
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- }
- }
-
- /* Mainly to speed up if not -g */
- if (SF_GET_PROCESS(symbolP))
- {
- /* Handle the nested blocks auxiliary info. */
- if (S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) {
- if (!strcmp(S_GET_NAME(symbolP), ".bb"))
- stack_push(block_stack, (char *) &symbolP);
- else { /* .eb */
- register symbolS* begin_symbolP;
- begin_symbolP = *(symbolS**)stack_pop(block_stack);
- if (begin_symbolP == (symbolS*)0)
- as_warn("mismatched .eb");
- else
- SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number+2);
- }
- }
- /* If we are able to identify the type of a function, and we
- are out of a function (last_functionP == 0) then, the
- function symbol will be associated with an auxiliary
- entry. */
- if (last_functionP == (symbolS*)0 &&
- SF_GET_FUNCTION(symbolP)) {
- last_functionP = symbolP;
-
- if (S_GET_NUMBER_AUXILIARY(symbolP) < 1) {
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
- } /* make it at least 1 */
-
- /* Clobber possible stale .dim information. */
- memset(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
- '\0', sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
- }
- /* The C_FCN doesn't need any additional information.
- I don't even know if this is needed for sdb. But the
- standard assembler generates it, so...
- */
- if (S_GET_STORAGE_CLASS(symbolP) == C_EFCN) {
- if (last_functionP == (symbolS*)0)
- as_fatal("C_EFCN symbol out of scope");
- SA_SET_SYM_FSIZE(last_functionP,
- (long)(S_GET_VALUE(symbolP) -
- S_GET_VALUE(last_functionP)));
- SA_SET_SYM_ENDNDX(last_functionP, symbol_number);
- last_functionP = (symbolS*)0;
- }
- }
- } else if (SF_GET_TAG(symbolP)) {
- /* First descriptor of a structure must point to
- the first slot after the structure description. */
- last_tagP = symbolP;
-
- } else if (S_GET_STORAGE_CLASS(symbolP) == C_EOS) {
- /* +2 take in account the current symbol */
- SA_SET_SYM_ENDNDX(last_tagP, symbol_number + 2);
- } else if (S_GET_STORAGE_CLASS(symbolP) == C_FILE) {
- if (S_GET_VALUE(symbolP)) {
- S_SET_VALUE((symbolS *) S_GET_VALUE(symbolP), symbol_number);
- S_SET_VALUE(symbolP, 0);
- } /* no one points at the first .file symbol */
- } /* if debug or tag or eos or file */
-
- /* We must put the external symbols apart. The loader
- does not bomb if we do not. But the references in
- the endndx field for a .bb symbol are not corrected
- if an external symbol is removed between .bb and .be.
- I.e in the following case :
- [20] .bb endndx = 22
- [21] foo external
- [22] .be
- ld will move the symbol 21 to the end of the list but
- endndx will still be 22 instead of 21. */
-
-
- if (SF_GET_LOCAL(symbolP)) {
- /* remove C_EFCN and LOCAL (L...) symbols */
- /* next pointer remains valid */
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
-
- }
- else if (!S_IS_DEFINED(symbolP)
- && !S_IS_DEBUG(symbolP)
- && !SF_GET_STATICS(symbolP) &&
- S_GET_STORAGE_CLASS(symbolP) == C_EXT)
- { /* C_EXT && !SF_GET_FUNCTION(symbolP)) */
- /* if external, Remove from the list */
- symbolS *hold = symbol_previous(symbolP);
-
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbol_clear_list_pointers(symbolP);
- symbol_append(symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP);
- symbolP = hold;
- } else {
- if (SF_GET_STRING(symbolP)) {
- symbolP->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
- } else {
- symbolP->sy_name_offset = 0;
- } /* fix "long" names */
-
- symbolP->sy_number = symbol_number;
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
- } /* if local symbol */
- } /* traverse the symbol list */
- return symbol_number;
-
+ symbolS *symbolP;
+ unsigned int symbol_number =0;
+
+ for (symbolP = symbol_rootP;
+ symbolP;
+ symbolP = symbolP ? symbol_next(symbolP) : symbol_rootP) {
+ if (!SF_GET_DEBUG(symbolP)) {
+ /* Debug symbols do not need all this rubbish */
+ symbolS* real_symbolP;
+
+ /* L* and C_EFCN symbols never merge. */
+ if (!SF_GET_LOCAL(symbolP)
+ && (real_symbolP = symbol_find_base(S_GET_NAME(symbolP), DO_NOT_STRIP))
+ && real_symbolP != symbolP) {
+ /* FIXME-SOON: where do dups come from?
+ Maybe tag references before definitions? xoxorich. */
+ /* Move the debug data from the debug symbol to the
+ real symbol. Do NOT do the oposite (i.e. move from
+ real symbol to debug symbol and remove real symbol from the
+ list.) Because some pointers refer to the real symbol
+ whereas no pointers refer to the debug symbol. */
+ c_symbol_merge(symbolP, real_symbolP);
+ /* Replace the current symbol by the real one */
+ /* The symbols will never be the last or the first
+ because : 1st symbol is .file and 3 last symbols are
+ .text, .data, .bss */
+ symbol_remove(real_symbolP, &symbol_rootP, &symbol_lastP);
+ symbol_insert(real_symbolP, symbolP, &symbol_rootP, &symbol_lastP);
+ symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
+ symbolP = real_symbolP;
+ } /* if not local but dup'd */
+
+ if (flagseen['R'] && (S_GET_SEGMENT(symbolP) == SEG_E1)) {
+ S_SET_SEGMENT(symbolP, SEG_E0);
+ } /* push data into text */
+
+ S_SET_VALUE(symbolP,
+ S_GET_VALUE(symbolP) + symbolP->sy_frag->fr_address);
+
+ if (!S_IS_DEFINED(symbolP) && !SF_GET_LOCAL(symbolP))
+ {
+ S_SET_EXTERNAL(symbolP);
+ }
+ else if (S_GET_STORAGE_CLASS(symbolP) == C_NULL)
+ {
+ if (S_GET_SEGMENT(symbolP) == SEG_E0)
+ {
+ S_SET_STORAGE_CLASS(symbolP, C_LABEL);
+ }
+ else
+ {
+ S_SET_STORAGE_CLASS(symbolP, C_STAT);
+ }
+ }
+
+ /* Mainly to speed up if not -g */
+ if (SF_GET_PROCESS(symbolP))
+ {
+ /* Handle the nested blocks auxiliary info. */
+ if (S_GET_STORAGE_CLASS(symbolP) == C_BLOCK) {
+ if (!strcmp(S_GET_NAME(symbolP), ".bb"))
+ stack_push(block_stack, (char *) &symbolP);
+ else { /* .eb */
+ register symbolS* begin_symbolP;
+ begin_symbolP = *(symbolS**)stack_pop(block_stack);
+ if (begin_symbolP == (symbolS*)0)
+ as_warn("mismatched .eb");
+ else
+ SA_SET_SYM_ENDNDX(begin_symbolP, symbol_number+2);
+ }
+ }
+ /* If we are able to identify the type of a function, and we
+ are out of a function (last_functionP == 0) then, the
+ function symbol will be associated with an auxiliary
+ entry. */
+ if (last_functionP == (symbolS*)0 &&
+ SF_GET_FUNCTION(symbolP)) {
+ last_functionP = symbolP;
+
+ if (S_GET_NUMBER_AUXILIARY(symbolP) < 1) {
+ S_SET_NUMBER_AUXILIARY(symbolP, 1);
+ } /* make it at least 1 */
+
+ /* Clobber possible stale .dim information. */
+#if 0
+/* Iffed out by steve - this fries the lnnoptr info too */
+ bzero(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen,
+ sizeof(symbolP->sy_symbol.ost_auxent[0].x_sym.x_fcnary.x_ary.x_dimen));
+#endif
+ }
+ /* The C_FCN doesn't need any additional information.
+ I don't even know if this is needed for sdb. But the
+ standard assembler generates it, so...
+ */
+ if (S_GET_STORAGE_CLASS(symbolP) == C_EFCN) {
+ if (last_functionP == (symbolS*)0)
+ as_fatal("C_EFCN symbol out of scope");
+ SA_SET_SYM_FSIZE(last_functionP,
+ (long)(S_GET_VALUE(symbolP) -
+ S_GET_VALUE(last_functionP)));
+ SA_SET_SYM_ENDNDX(last_functionP, symbol_number);
+ last_functionP = (symbolS*)0;
+ }
+ }
+ } else if (SF_GET_TAG(symbolP)) {
+ /* First descriptor of a structure must point to
+ the first slot after the structure description. */
+ last_tagP = symbolP;
+
+ } else if (S_GET_STORAGE_CLASS(symbolP) == C_EOS) {
+ /* +2 take in account the current symbol */
+ SA_SET_SYM_ENDNDX(last_tagP, symbol_number + 2);
+ } else if (S_GET_STORAGE_CLASS(symbolP) == C_FILE) {
+ if (S_GET_VALUE(symbolP)) {
+ S_SET_VALUE((symbolS *) S_GET_VALUE(symbolP), symbol_number);
+ S_SET_VALUE(symbolP, 0);
+ } /* no one points at the first .file symbol */
+ } /* if debug or tag or eos or file */
+
+ /* We must put the external symbols apart. The loader
+ does not bomb if we do not. But the references in
+ the endndx field for a .bb symbol are not corrected
+ if an external symbol is removed between .bb and .be.
+ I.e in the following case :
+ [20] .bb endndx = 22
+ [21] foo external
+ [22] .be
+ ld will move the symbol 21 to the end of the list but
+ endndx will still be 22 instead of 21. */
+
+
+ if (SF_GET_LOCAL(symbolP)) {
+ /* remove C_EFCN and LOCAL (L...) symbols */
+ /* next pointer remains valid */
+ symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
+
+ }
+ else if (!S_IS_DEFINED(symbolP)
+ && !S_IS_DEBUG(symbolP)
+ && !SF_GET_STATICS(symbolP) &&
+ S_GET_STORAGE_CLASS(symbolP) == C_EXT)
+ { /* C_EXT && !SF_GET_FUNCTION(symbolP)) */
+ /* if external, Remove from the list */
+ symbolS *hold = symbol_previous(symbolP);
+
+ symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
+ symbol_clear_list_pointers(symbolP);
+ symbol_append(symbolP, symbol_extern_lastP, &symbol_externP, &symbol_extern_lastP);
+ symbolP = hold;
+ } else {
+ if (SF_GET_STRING(symbolP)) {
+ symbolP->sy_name_offset = string_byte_count;
+ string_byte_count += strlen(S_GET_NAME(symbolP)) + 1;
+ } else {
+ symbolP->sy_name_offset = 0;
+ } /* fix "long" names */
+
+ symbolP->sy_number = symbol_number;
+ symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
+ } /* if local symbol */
+ } /* traverse the symbol list */
+ return symbol_number;
+
}
static unsigned int DEFUN_VOID(glue_symbols)
{
- unsigned int symbol_number = 0;
- symbolS *symbolP;
- for (symbolP = symbol_externP; symbol_externP;) {
- symbolS *tmp = symbol_externP;
-
- /* append */
- symbol_remove(tmp, &symbol_externP, &symbol_extern_lastP);
- symbol_append(tmp, symbol_lastP, &symbol_rootP, &symbol_lastP);
-
- /* and process */
- if (SF_GET_STRING(tmp)) {
- tmp->sy_name_offset = string_byte_count;
- string_byte_count += strlen(S_GET_NAME(tmp)) + 1;
- } else {
- tmp->sy_name_offset = 0;
- } /* fix "long" names */
-
- tmp->sy_number = symbol_number;
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(tmp);
- } /* append the entire extern chain */
- return symbol_number;
-
+ unsigned int symbol_number = 0;
+ symbolS *symbolP;
+ for (symbolP = symbol_externP; symbol_externP;) {
+ symbolS *tmp = symbol_externP;
+
+ /* append */
+ symbol_remove(tmp, &symbol_externP, &symbol_extern_lastP);
+ symbol_append(tmp, symbol_lastP, &symbol_rootP, &symbol_lastP);
+
+ /* and process */
+ if (SF_GET_STRING(tmp)) {
+ tmp->sy_name_offset = string_byte_count;
+ string_byte_count += strlen(S_GET_NAME(tmp)) + 1;
+ } else {
+ tmp->sy_name_offset = 0;
+ } /* fix "long" names */
+
+ tmp->sy_number = symbol_number;
+ symbol_number += 1 + S_GET_NUMBER_AUXILIARY(tmp);
+ } /* append the entire extern chain */
+ return symbol_number;
+
}
static unsigned int DEFUN_VOID(tie_tags)
{
- unsigned int symbol_number = 0;
-
- symbolS*symbolP;
- for (symbolP = symbol_rootP; symbolP; symbolP =
- symbol_next(symbolP))
- {
- symbolP->sy_number = symbol_number;
-
-
-
- if (SF_GET_TAGGED(symbolP))
- {
- SA_SET_SYM_TAGNDX
- (symbolP,
- ((symbolS*) SA_GET_SYM_TAGNDX(symbolP))->sy_number);
- }
-
- symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
- }
- return symbol_number;
-
+ unsigned int symbol_number = 0;
+
+ symbolS*symbolP;
+ for (symbolP = symbol_rootP; symbolP; symbolP =
+ symbol_next(symbolP))
+ {
+ symbolP->sy_number = symbol_number;
+
+
+
+ if (SF_GET_TAGGED(symbolP))
+ {
+ SA_SET_SYM_TAGNDX
+ (symbolP,
+ ((symbolS*) SA_GET_SYM_TAGNDX(symbolP))->sy_number);
+ }
+
+ symbol_number += 1 + S_GET_NUMBER_AUXILIARY(symbolP);
+ }
+ return symbol_number;
+
}
static void
- DEFUN(crawl_symbols,(headers, abfd),
- struct internal_filehdr *headers AND
- bfd *abfd)
+DEFUN(crawl_symbols,(headers, abfd),
+ struct internal_filehdr *headers AND
+ bfd *abfd)
{
-
- unsigned int i;
- unsigned int ptr = 0;
-
-
- symbolS *symbolP;
-
- /* Initialize the stack used to keep track of the matching .bb .be */
-
- block_stack = stack_init(512, sizeof(symbolS*));
- /* JF deal with forward references first... */
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbol_next(symbolP))
- {
-
- if (symbolP->sy_forward) {
- S_SET_VALUE(symbolP, (S_GET_VALUE(symbolP)
- + S_GET_VALUE(symbolP->sy_forward)
- + symbolP->sy_forward->sy_frag->fr_address));
-
- if (SF_GET_GET_SEGMENT(symbolP)) {
- S_SET_SEGMENT(symbolP, S_GET_SEGMENT(symbolP->sy_forward));
- } /* forward segment also */
-
- symbolP->sy_forward=0;
- } /* if it has a forward reference */
- } /* walk the symbol chain */
-
-
- /* The symbol list should be ordered according to the following sequence
- * order :
- * . .file symbol
- * . debug entries for functions
- * . fake symbols for the sections, including.text .data and .bss
- * . defined symbols
- * . undefined symbols
- * But this is not mandatory. The only important point is to put the
- * undefined symbols at the end of the list.
- */
-
- if (symbol_rootP == NULL
- || S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE) {
- c_dot_file_symbol("fake");
- }
- /* Is there a .file symbol ? If not insert one at the beginning. */
-
- /*
- * Build up static symbols for the sections, they are filled in later
- */
-
-
- for (i = SEG_E0; i < SEG_E9; i++)
- {
- if (segment_info[i].scnhdr.s_name[0])
- {
- segment_info[i].dot =
- c_section_symbol(segment_info[i].scnhdr.s_name,
- i-SEG_E0+1);
-
- }
- }
-
-
- /* Take all the externals out and put them into another chain */
- headers->f_nsyms = yank_symbols();
- /* Take the externals and glue them onto the end.*/
- headers->f_nsyms += glue_symbols();
-
- headers->f_nsyms = tie_tags();
- know(symbol_externP == NULL);
- know(symbol_extern_lastP == NULL);
-
- return;
+
+ unsigned int i;
+ unsigned int ptr = 0;
+
+
+ symbolS *symbolP;
+
+ /* Initialize the stack used to keep track of the matching .bb .be */
+
+ block_stack = stack_init(512, sizeof(symbolS*));
+ /* JF deal with forward references first... */
+ for (symbolP = symbol_rootP;
+ symbolP;
+ symbolP = symbol_next(symbolP))
+ {
+
+ if (symbolP->sy_forward) {
+ S_SET_VALUE(symbolP, (S_GET_VALUE(symbolP)
+ + S_GET_VALUE(symbolP->sy_forward)
+ + symbolP->sy_forward->sy_frag->fr_address));
+
+ if (SF_GET_GET_SEGMENT(symbolP)) {
+ S_SET_SEGMENT(symbolP, S_GET_SEGMENT(symbolP->sy_forward));
+ } /* forward segment also */
+
+ symbolP->sy_forward=0;
+ } /* if it has a forward reference */
+ } /* walk the symbol chain */
+
+
+ /* The symbol list should be ordered according to the following sequence
+ * order :
+ * . .file symbol
+ * . debug entries for functions
+ * . fake symbols for the sections, including.text .data and .bss
+ * . defined symbols
+ * . undefined symbols
+ * But this is not mandatory. The only important point is to put the
+ * undefined symbols at the end of the list.
+ */
+
+ if (symbol_rootP == NULL
+ || S_GET_STORAGE_CLASS(symbol_rootP) != C_FILE) {
+ c_dot_file_symbol("fake");
+ }
+ /* Is there a .file symbol ? If not insert one at the beginning. */
+
+ /*
+ * Build up static symbols for the sections, they are filled in later
+ */
+
+
+ for (i = SEG_E0; i < SEG_E9; i++)
+ {
+ if (segment_info[i].scnhdr.s_name[0])
+ {
+ segment_info[i].dot =
+ c_section_symbol(segment_info[i].scnhdr.s_name,
+ i-SEG_E0+1);
+
+ }
+ }
+
+
+ /* Take all the externals out and put them into another chain */
+ headers->f_nsyms = yank_symbols();
+ /* Take the externals and glue them onto the end.*/
+ headers->f_nsyms += glue_symbols();
+
+ headers->f_nsyms = tie_tags();
+ know(symbol_externP == NULL);
+ know(symbol_extern_lastP == NULL);
+
+ return;
}
/*
void DEFUN(w_strings,(where),
char *where)
{
- symbolS *symbolP;
-
- /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
- md_number_to_chars(where, string_byte_count, sizeof(string_byte_count));
- where += sizeof(string_byte_count);
- for (symbolP = symbol_rootP;
- symbolP;
- symbolP = symbol_next(symbolP))
- {
- unsigned int size;
-
- if (SF_GET_STRING(symbolP)) {
- size = strlen(S_GET_NAME(symbolP)) + 1;
-
- memcpy(where, S_GET_NAME(symbolP),size);
- where += size;
-
- }
- }
-
+ symbolS *symbolP;
+
+ /* Gotta do md_ byte-ordering stuff for string_byte_count first - KWK */
+ md_number_to_chars(where, string_byte_count, sizeof(string_byte_count));
+ where += sizeof(string_byte_count);
+ for (symbolP = symbol_rootP;
+ symbolP;
+ symbolP = symbol_next(symbolP))
+ {
+ unsigned int size;
+
+ if (SF_GET_STRING(symbolP)) {
+ size = strlen(S_GET_NAME(symbolP)) + 1;
+
+ memcpy(where, S_GET_NAME(symbolP),size);
+ where += size;
+
+ }
+ }
+
}
static void
- DEFUN(do_linenos_for,(abfd, file_cursor),
- bfd *abfd AND
- unsigned long *file_cursor)
+DEFUN(do_linenos_for,(abfd, file_cursor),
+ bfd *abfd AND
+ unsigned long *file_cursor)
{
- unsigned int idx;
+ unsigned int idx;
+
+ for (idx = SEG_E0; idx < SEG_E9; idx++)
+ {
+ segment_info_type *s = segment_info + idx;
+
+
+ if (s->scnhdr.s_nlnno != 0)
+ {
+ struct lineno_list *line_ptr ;
+
+ struct external_lineno *buffer =
+ (struct external_lineno *)xmalloc(s->scnhdr.s_nlnno * LINESZ);
+
+ struct external_lineno *dst= buffer;
+
+ /* Run through the table we've built and turn it into its external
+ form, take this chance to remove duplicates */
+
+ for (line_ptr = s->lineno_list_head;
+ line_ptr != (struct lineno_list *)NULL;
+ line_ptr = line_ptr->next)
+ {
+
+ if (line_ptr->line.l_lnno == 0)
+ {
+ /* Turn a pointer to a symbol into the symbols' index */
+ line_ptr->line.l_addr.l_symndx =
+ ( (symbolS *)line_ptr->line.l_addr.l_symndx)->sy_number;
+ }
+ else
+ {
+ line_ptr->line.l_addr.l_paddr += ((struct frag * )(line_ptr->frag))->fr_address;
+ }
+
+
+ (void) bfd_coff_swap_lineno_out(abfd, &(line_ptr->line), dst);
+ dst++;
- for (idx = SEG_E0; idx < SEG_E9; idx++)
- {
- segment_info_type *s = segment_info + idx;
-
-
- if (s->scnhdr.s_nlnno != 0)
- {
- struct lineno_list *line_ptr ;
-
- struct external_lineno *buffer =
- (struct external_lineno *)xmalloc(s->scnhdr.s_nlnno * LINESZ);
-
- struct external_lineno *dst= buffer;
-
- /* Run through the table we've built and turn it into its external
- form, take this chance to remove duplicates */
-
- for (line_ptr = s->lineno_list_head;
- line_ptr != (struct lineno_list *)NULL;
- line_ptr = line_ptr->next)
- {
-
- if (line_ptr->line.l_lnno == 0)
- {
- /* Turn a pointer to a symbol into the symbols' index */
- line_ptr->line.l_addr.l_symndx =
- ( (symbolS *)line_ptr->line.l_addr.l_symndx)->sy_number;
- }
- else
- {
- line_ptr->line.l_addr.l_paddr += ((struct frag * )(line_ptr->frag))->fr_address;
- }
-
-
- (void) bfd_coff_swap_lineno_out(abfd, &(line_ptr->line), dst);
- dst++;
-
- }
-
- s->scnhdr.s_lnnoptr = *file_cursor;
-
- bfd_write(buffer, 1, s->scnhdr.s_nlnno* LINESZ, abfd);
- free(buffer);
-
- *file_cursor += s->scnhdr.s_nlnno * LINESZ;
- }
- }
+ }
+
+ s->scnhdr.s_lnnoptr = *file_cursor;
+
+ bfd_write(buffer, 1, s->scnhdr.s_nlnno* LINESZ, abfd);
+ free(buffer);
+
+ *file_cursor += s->scnhdr.s_nlnno * LINESZ;
+ }
+ }
}
static void DEFUN_VOID(remove_subsegs)
{
- unsigned int i;
+ unsigned int i;
+
+ for (i = SEG_E0; i < SEG_UNKNOWN; i++)
+ {
+ frchainS *head = segment_info[i].frchainP;
+ fragS dummy;
+ fragS * prev_frag = &dummy;
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- frchainS *head = segment_info[i].frchainP;
- fragS dummy;
- fragS * prev_frag = &dummy;
-
- while (head && head->frch_seg == i)
- {
- prev_frag->fr_next = head->frch_root;
- prev_frag = head->frch_last;
- head = head->frch_next;
- }
- prev_frag->fr_next = 0;
- }
+ while (head && head->frch_seg == i)
+ {
+ prev_frag->fr_next = head->frch_root;
+ prev_frag = head->frch_last;
+ head = head->frch_next;
+ }
+ prev_frag->fr_next = 0;
+ }
}
extern void DEFUN_VOID(write_object_file)
{
- int i;
- struct frchain *frchain_ptr;
-
- struct internal_filehdr filehdr;
- struct internal_aouthdr aouthdr;
- unsigned long file_cursor;
- bfd *abfd;
- unsigned int addr = 0;
- abfd = bfd_openw(out_file_name, TARGET_FORMAT);
-
-
- if (abfd == 0) {
- as_perror ("FATAL: Can't create %s", out_file_name);
- exit(42);
+ int i;
+ struct frchain *frchain_ptr;
+
+ struct internal_filehdr filehdr;
+ struct internal_aouthdr aouthdr;
+ unsigned long file_cursor;
+ bfd *abfd;
+ unsigned int addr = 0;
+ abfd = bfd_openw(out_file_name, TARGET_FORMAT);
+
+
+ if (abfd == 0) {
+ as_perror ("FATAL: Can't create %s", out_file_name);
+ exit(42);
}
- bfd_set_format(abfd, bfd_object);
- bfd_set_arch_mach(abfd, BFD_ARCH, 0);
-
-
-
- string_byte_count = 4;
-
- for (frchain_ptr = frchain_root;
- frchain_ptr != (struct frchain *)NULL;
- frchain_ptr = frchain_ptr->frch_next) {
- /* Run through all the sub-segments and align them up. Also close any
- open frags. We tack a .fill onto the end of the frag chain so
- that any .align's size can be worked by looking at the next
- frag */
-
- subseg_new(frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
+ bfd_set_format(abfd, bfd_object);
+ bfd_set_arch_mach(abfd, BFD_ARCH, 0);
+
+
+
+ string_byte_count = 4;
+
+ for (frchain_ptr = frchain_root;
+ frchain_ptr != (struct frchain *)NULL;
+ frchain_ptr = frchain_ptr->frch_next) {
+ /* Run through all the sub-segments and align them up. Also close any
+ open frags. We tack a .fill onto the end of the frag chain so
+ that any .align's size can be worked by looking at the next
+ frag */
+
+ subseg_new(frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
#define SUB_SEGMENT_ALIGN 1
- frag_align(SUB_SEGMENT_ALIGN,0);
- frag_wane(frag_now);
- frag_now->fr_fix = 0;
- know( frag_now->fr_next == NULL );
+ frag_align(SUB_SEGMENT_ALIGN,0);
+ frag_wane(frag_now);
+ frag_now->fr_fix = 0;
+ know( frag_now->fr_next == NULL );
}
-
-
- remove_subsegs();
-
-
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- relax_segment(segment_info[i].frchainP->frch_root, i);
- }
-
-
-
-
-
- filehdr.f_nscns = 0;
-
- /* Find out how big the sections are */
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
-
- if (segment_info[i].scnhdr.s_name[0])
- {
- filehdr.f_nscns++;
- }
- segment_info[i].scnhdr.s_paddr = addr;
- if (i == SEG_E2) {
- /* THis is a special case, we leave the size alone, which will have */
- /* been made up from all and any lcomms seen */
- }
- else {
- addr += size_section(abfd, i);
- }
- }
-
-
-
- /* Turn the gas native symbol table shape into a coff symbol table */
- crawl_symbols(&filehdr, abfd);
-#ifndef TC_H8300
- for (i = SEG_E0; i < SEG_UNKNOWN; i++)
- {
- fixup_segment(segment_info[i].fix_root, i);
- }
-#endif
-
- file_cursor = FILHSZ + SCNHSZ * filehdr.f_nscns ;
-
- bfd_seek(abfd, file_cursor, 0);
-
-
- do_relocs_for(abfd, &file_cursor);
-
- do_linenos_for(abfd, &file_cursor);
-
-
- /* Plant the data */
-
- fill_section(abfd,&filehdr, &file_cursor);
-
- filehdr.f_magic = COFF_MAGIC;
- filehdr.f_timdat = 0;
- filehdr.f_flags = 0;
-
-
-
+
+
+ remove_subsegs();
+
+
+ for (i = SEG_E0; i < SEG_UNKNOWN; i++)
+ {
+ relax_segment(segment_info[i].frchainP->frch_root, i);
+ }
+
+
+
+
+
+ filehdr.f_nscns = 0;
+
+ /* Find out how big the sections are */
+ for (i = SEG_E0; i < SEG_UNKNOWN; i++)
+ {
+
+ if (segment_info[i].scnhdr.s_name[0])
{
-
- unsigned int symtable_size = filehdr.f_nsyms * SYMESZ;
- char *buffer1 = malloc(symtable_size + string_byte_count + 4);
- char *ptr = buffer1;
- filehdr.f_symptr = bfd_tell(abfd);
- w_symbols(abfd, buffer1, symbol_rootP);
- w_strings(buffer1 + symtable_size);
- bfd_write(buffer1, 1,symtable_size + string_byte_count + 4, abfd);
- free(buffer1);
-
+ filehdr.f_nscns++;
}
- coff_header_append(abfd, &filehdr, &aouthdr);
-
- bfd_close_all_done(abfd);
+
+ if (i == SEG_E2)
+ {
+ /* THis is a special case, we leave the size alone, which will have */
+ /* been made up from all and any lcomms seen */
+ }
+ else {
+ addr += size_section(abfd, i);
+ }
+ }
+
+
+
+ /* Turn the gas native symbol table shape into a coff symbol table */
+ crawl_symbols(&filehdr, abfd);
+#ifndef TC_H8300
+ for (i = SEG_E0; i < SEG_UNKNOWN; i++)
+ {
+ fixup_segment(segment_info[i].fix_root, i);
+ }
+#endif
+
+ file_cursor = FILHSZ + SCNHSZ * filehdr.f_nscns ;
+
+ bfd_seek(abfd, file_cursor, 0);
+
+
+ do_relocs_for(abfd, &file_cursor);
+
+ do_linenos_for(abfd, &file_cursor);
+
+
+ /* Plant the data */
+
+ fill_section(abfd,&filehdr, &file_cursor);
+
+ filehdr.f_magic = COFF_MAGIC;
+ filehdr.f_timdat = time(0);
+ filehdr.f_flags = COFF_FLAGS ;
+
+ if (!had_lineno)
+ {
+ filehdr.f_flags |= F_LNNO;
+ }
+ if (!had_reloc)
+ {
+ filehdr.f_flags |= F_RELFLG;
+ }
+
+
+
+
+
+
+
+ {
+
+ unsigned int symtable_size = filehdr.f_nsyms * SYMESZ;
+ char *buffer1 = malloc(symtable_size + string_byte_count + 4);
+ char *ptr = buffer1;
+ filehdr.f_symptr = bfd_tell(abfd);
+ w_symbols(abfd, buffer1, symbol_rootP);
+ w_strings(buffer1 + symtable_size);
+ bfd_write(buffer1, 1,symtable_size + string_byte_count + 4, abfd);
+ free(buffer1);
+
+ }
+ coff_header_append(abfd, &filehdr, &aouthdr);
+
+ bfd_close_all_done(abfd);
}
static void DEFUN(change_to_section,(name, len, exp),
- char *name AND
- unsigned int len AND
- unsigned int exp)
+ char *name AND
+ unsigned int len AND
+ unsigned int exp)
{
- unsigned int i;
- /* Find out if we've already got a section of this name etc */
- for(i = SEG_E0; i < SEG_E9 && segment_info[i].scnhdr.s_name[0] ; i++)
- {
- if (strncmp(segment_info[i].scnhdr.s_name, name, len) == 0)
- {
- subseg_new(i, exp);
- return;
-
- }
- }
- /* No section, add one */
- strncpy(segment_info[i].scnhdr.s_name, name, 8);
- subseg_new(i, exp);
+ unsigned int i;
+ /* Find out if we've already got a section of this name etc */
+ for(i = SEG_E0; i < SEG_E9 && segment_info[i].scnhdr.s_name[0] ; i++)
+ {
+ if (strncmp(segment_info[i].scnhdr.s_name, name, len) == 0)
+ {
+ subseg_new(i, exp);
+ return;
+
+ }
+ }
+ /* No section, add one */
+ strncpy(segment_info[i].scnhdr.s_name, name, 8);
+ subseg_new(i, exp);
}
static void
- DEFUN_VOID(obj_coff_section)
+DEFUN_VOID(obj_coff_section)
{
- /* Strip out the section name */
- char *section_name ;
- char *section_name_end;
- char c;
-
- unsigned int len;
- unsigned int exp;
-
- section_name = input_line_pointer;
- c = get_symbol_end();
- section_name_end = input_line_pointer;
-
- len = section_name_end - section_name ;
+ /* Strip out the section name */
+ char *section_name ;
+ char *section_name_end;
+ char c;
+
+ unsigned int len;
+ unsigned int exp;
+
+ section_name = input_line_pointer;
+ c = get_symbol_end();
+ section_name_end = input_line_pointer;
+
+ len = section_name_end - section_name ;
+ input_line_pointer++;
+ SKIP_WHITESPACE();
+ if (c == ',')
+ {
+ exp = get_absolute_expression();
+ }
+ else if ( *input_line_pointer == ',')
+ {
+
input_line_pointer++;
- SKIP_WHITESPACE();
- if (c == ',')
- {
- exp = get_absolute_expression();
- }
- else if ( *input_line_pointer == ',')
- {
-
- input_line_pointer++;
- exp = get_absolute_expression();
- }
- else
- {
- exp = 0;
- }
-
- change_to_section(section_name, len,exp);
- *section_name_end = c;
-
+ exp = get_absolute_expression();
+ }
+ else
+ {
+ exp = 0;
+ }
+
+ change_to_section(section_name, len,exp);
+*section_name_end = c;
+
}
static void obj_coff_text()
{
- change_to_section(".text",5, get_absolute_expression());
+ change_to_section(".text",5, get_absolute_expression());
}
static void obj_coff_data()
{
- change_to_section(".data",5, get_absolute_expression());
+ change_to_section(".data",5, get_absolute_expression());
}
void c_symbol_merge(debug, normal)
{
S_SET_DATA_TYPE(normal, S_GET_DATA_TYPE(debug));
S_SET_STORAGE_CLASS(normal, S_GET_STORAGE_CLASS(debug));
-
+
if (S_GET_NUMBER_AUXILIARY(debug) > S_GET_NUMBER_AUXILIARY(normal)) {
S_SET_NUMBER_AUXILIARY(normal, S_GET_NUMBER_AUXILIARY(debug));
} /* take the most we have */
-
+
if (S_GET_NUMBER_AUXILIARY(debug) > 0) {
memcpy((char*)&normal->sy_symbol.ost_auxent[0], (char*)&debug->sy_symbol.ost_auxent[0], S_GET_NUMBER_AUXILIARY(debug) * AUXESZ);
} /* Move all the auxiliary information */
-
+
/* Move the debug flags. */
SF_SET_DEBUG_FIELD(normal, SF_GET_DEBUG_FIELD(debug));
} /* c_symbol_merge() */
static int
- DEFUN(c_line_new,(symbol, paddr, line_number, frag),
- symbolS *symbol AND
- long paddr AND
- unsigned short line_number AND
- fragS* frag)
+DEFUN(c_line_new,(symbol, paddr, line_number, frag),
+ symbolS *symbol AND
+ long paddr AND
+ unsigned short line_number AND
+ fragS* frag)
{
- struct lineno_list* new_line =
- (struct lineno_list *)xmalloc(sizeof(struct lineno_list));
-
- segment_info_type *s = segment_info + now_seg;
- new_line->line.l_lnno = line_number;
-
- if (line_number == 0)
- {
- new_line->line.l_addr.l_symndx = (long)symbol;
- }
- else
- {
- new_line->line.l_addr.l_paddr = paddr;
- }
-
- new_line->frag = (char*)frag;
- new_line->next = (struct lineno_list*)NULL;
-
-
- if (s->lineno_list_head == (struct lineno_list *)NULL)
- {
- s->lineno_list_head = new_line;
- }
- else
- {
- s->lineno_list_tail->next = new_line;
- }
- s->lineno_list_tail = new_line;
- return LINESZ * s->scnhdr.s_nlnno ++;
+ struct lineno_list* new_line =
+ (struct lineno_list *)xmalloc(sizeof(struct lineno_list));
+
+ segment_info_type *s = segment_info + now_seg;
+ new_line->line.l_lnno = line_number;
+
+ had_lineno = 1;
+
+ if (line_number == 0)
+ {
+last_line_symbol = symbol;
+ new_line->line.l_addr.l_symndx = (long)symbol;
+ }
+ else
+ {
+ new_line->line.l_addr.l_paddr = paddr;
+ }
+
+ new_line->frag = (char*)frag;
+ new_line->next = (struct lineno_list*)NULL;
+
+
+ if (s->lineno_list_head == (struct lineno_list *)NULL)
+ {
+ s->lineno_list_head = new_line;
+ }
+ else
+ {
+ s->lineno_list_tail->next = new_line;
+ }
+ s->lineno_list_tail = new_line;
+ return LINESZ * s->scnhdr.s_nlnno ++;
}
void c_dot_file_symbol(filename)
char *filename;
{
- symbolS* symbolP;
-
- symbolP = symbol_new(".file",
- SEG_DEBUG,
- 0,
- &zero_address_frag);
-
- S_SET_STORAGE_CLASS(symbolP, C_FILE);
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
- SA_SET_FILE_FNAME(symbolP, filename);
+ symbolS* symbolP;
+
+ symbolP = symbol_new(".file",
+ SEG_DEBUG,
+ 0,
+ &zero_address_frag);
+
+ S_SET_STORAGE_CLASS(symbolP, C_FILE);
+ S_SET_NUMBER_AUXILIARY(symbolP, 1);
+ SA_SET_FILE_FNAME(symbolP, filename);
#ifndef NO_LISTING
- {
- extern int listing;
- if (listing)
- {
- listing_source_file(filename);
- }
-
- }
-
+ {
+ extern int listing;
+ if (listing)
+ {
+ listing_source_file(filename);
+ }
+
+ }
+
#endif
- SF_SET_DEBUG(symbolP);
- S_SET_VALUE(symbolP, (long) previous_file_symbol);
-
- previous_file_symbol = symbolP;
-
- /* Make sure that the symbol is first on the symbol chain */
- if (symbol_rootP != symbolP) {
- if (symbolP == symbol_lastP) {
- symbol_lastP = symbol_lastP->sy_previous;
- } /* if it was the last thing on the list */
-
- symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
- symbol_insert(symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
- symbol_rootP = symbolP;
- } /* if not first on the list */
-
+ SF_SET_DEBUG(symbolP);
+ S_SET_VALUE(symbolP, (long) previous_file_symbol);
+
+ previous_file_symbol = symbolP;
+
+ /* Make sure that the symbol is first on the symbol chain */
+ if (symbol_rootP != symbolP) {
+ if (symbolP == symbol_lastP) {
+ symbol_lastP = symbol_lastP->sy_previous;
+ } /* if it was the last thing on the list */
+
+ symbol_remove(symbolP, &symbol_rootP, &symbol_lastP);
+ symbol_insert(symbolP, symbol_rootP, &symbol_rootP, &symbol_lastP);
+ symbol_rootP = symbolP;
+ } /* if not first on the list */
+
} /* c_dot_file_symbol() */
/*
char *name;
int idx;
{
- symbolS *symbolP;
-
- symbolP = symbol_new(name,idx,
- 0,
- &zero_address_frag);
-
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- S_SET_NUMBER_AUXILIARY(symbolP, 1);
-
- SF_SET_STATICS(symbolP);
-
- return symbolP;
+ symbolS *symbolP;
+
+ symbolP = symbol_new(name,idx,
+ 0,
+ &zero_address_frag);
+
+ S_SET_STORAGE_CLASS(symbolP, C_STAT);
+ S_SET_NUMBER_AUXILIARY(symbolP, 1);
+
+ SF_SET_STATICS(symbolP);
+
+ return symbolP;
} /* c_section_symbol() */
static void
- DEFUN(w_symbols,(abfd, where, symbol_rootP),
- bfd *abfd AND
- char *where AND
- symbolS *symbol_rootP)
+DEFUN(w_symbols,(abfd, where, symbol_rootP),
+bfd *abfd AND
+char *where AND
+symbolS *symbol_rootP)
{
- symbolS *symbolP;
- unsigned int i;
-
- /* First fill in those values we have only just worked out */
- for (i = SEG_E0; i < SEG_E9; i++)
- {
- symbolP = segment_info[i].dot;
- if (symbolP)
- {
-
- SA_SET_SCN_SCNLEN(symbolP, segment_info[i].scnhdr.s_size);
- SA_SET_SCN_NRELOC(symbolP, segment_info[i].scnhdr.s_nreloc);
- SA_SET_SCN_NLINNO(symbolP, segment_info[i].scnhdr.s_nlnno);
-
- }
- }
-
- /*
- * Emit all symbols left in the symbol chain.
- */
- for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
- /* Used to save the offset of the name. It is used to point
- to the string in memory but must be a file offset. */
- register char * temp;
-
- tc_coff_symbol_emit_hook(symbolP);
-
- temp = S_GET_NAME(symbolP);
- if (SF_GET_STRING(symbolP)) {
- S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
- S_SET_ZEROES(symbolP, 0);
+ symbolS *symbolP;
+ unsigned int i;
+
+ /* First fill in those values we have only just worked out */
+ for (i = SEG_E0; i < SEG_E9; i++)
+ {
+ symbolP = segment_info[i].dot;
+ if (symbolP)
+ {
+
+ SA_SET_SCN_SCNLEN(symbolP, segment_info[i].scnhdr.s_size);
+ SA_SET_SCN_NRELOC(symbolP, segment_info[i].scnhdr.s_nreloc);
+ SA_SET_SCN_NLINNO(symbolP, segment_info[i].scnhdr.s_nlnno);
+
+ }
+ }
+
+ /*
+ * Emit all symbols left in the symbol chain.
+ */
+ for (symbolP = symbol_rootP; symbolP; symbolP = symbol_next(symbolP)) {
+ /* Used to save the offset of the name. It is used to point
+ to the string in memory but must be a file offset. */
+ register char * temp;
+
+ tc_coff_symbol_emit_hook(symbolP);
+
+ temp = S_GET_NAME(symbolP);
+ if (SF_GET_STRING(symbolP)) {
+ S_SET_OFFSET(symbolP, symbolP->sy_name_offset);
+ S_SET_ZEROES(symbolP, 0);
} else {
- memset(symbolP->sy_symbol.ost_entry.n_name, '\0', SYMNMLEN);
+ bzero(symbolP->sy_symbol.ost_entry.n_name, SYMNMLEN);
strncpy(symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
- }
- where = symbol_to_chars(abfd, where, symbolP);
- S_SET_NAME(symbolP,temp);
+ }
+ where = symbol_to_chars(abfd, where, symbolP);
+ S_SET_NAME(symbolP,temp);
}
-
+
} /* w_symbols() */
static void DEFUN_VOID(obj_coff_lcomm)
{
- char *name;
- char c;
- int temp;
- char *p;
- symbolS *symbolP;
- name = input_line_pointer;
-
-
-
- c = get_symbol_end();
- p = input_line_pointer;
- *p = c;
- SKIP_WHITESPACE();
- if (*input_line_pointer != ',') {
- as_bad("Expected comma after name");
- ignore_rest_of_line();
- return;
+ char *name;
+ char c;
+ int temp;
+ char *p;
+ symbolS *symbolP;
+ name = input_line_pointer;
+
+
+
+ c = get_symbol_end();
+ p = input_line_pointer;
+ *p = c;
+ SKIP_WHITESPACE();
+ if (*input_line_pointer != ',') {
+ as_bad("Expected comma after name");
+ ignore_rest_of_line();
+ return;
}
- if (*input_line_pointer == '\n') {
- as_bad("Missing size expression");
- return;
+ if (*input_line_pointer == '\n') {
+ as_bad("Missing size expression");
+ return;
}
- input_line_pointer++;
- if ((temp = get_absolute_expression ()) < 0) {
- as_warn("lcomm length (%d.) <0! Ignored.", temp);
- ignore_rest_of_line();
- return;
+ input_line_pointer++;
+ if ((temp = get_absolute_expression ()) < 0) {
+ as_warn("lcomm length (%d.) <0! Ignored.", temp);
+ ignore_rest_of_line();
+ return;
}
- *p = 0;
- symbolP = symbol_find_or_make(name);
- S_SET_VALUE(symbolP, segment_info[SEG_E2].scnhdr.s_size);
- S_SET_SEGMENT(symbolP, SEG_E2);
- segment_info[SEG_E2].scnhdr.s_size += temp;
- S_SET_STORAGE_CLASS(symbolP, C_STAT);
- demand_empty_rest_of_line();
+ *p = 0;
+ symbolP = symbol_find_or_make(name);
+ S_SET_VALUE(symbolP, segment_info[SEG_E2].scnhdr.s_size);
+ S_SET_SEGMENT(symbolP, SEG_E2);
+ segment_info[SEG_E2].scnhdr.s_size += temp;
+ S_SET_STORAGE_CLASS(symbolP, C_STAT);
+ demand_empty_rest_of_line();
}
#if 1
static void DEFUN(fixup_segment,(fixP, this_segment_type),
- register fixS * fixP AND
- segT this_segment_type)
+register fixS * fixP AND
+segT this_segment_type)
{
- register symbolS *add_symbolP;
- register symbolS *sub_symbolP;
- register long add_number;
- register int size;
- register char *place;
- register long where;
- register char pcrel;
- register fragS *fragP;
- register segT add_symbol_segment = SEG_ABSOLUTE;
-
-
- for ( ; fixP; fixP = fixP->fx_next)
- {
- fragP = fixP->fx_frag;
- know(fragP);
- where = fixP->fx_where;
- place = fragP->fr_literal + where;
- size = fixP->fx_size;
- add_symbolP = fixP->fx_addsy;
+ register symbolS *add_symbolP;
+ register symbolS *sub_symbolP;
+ register long add_number;
+ register int size;
+ register char *place;
+ register long where;
+ register char pcrel;
+ register fragS *fragP;
+ register segT add_symbol_segment = SEG_ABSOLUTE;
+
+
+ for ( ; fixP; fixP = fixP->fx_next)
+ {
+ fragP = fixP->fx_frag;
+ know(fragP);
+ where = fixP->fx_where;
+ place = fragP->fr_literal + where;
+ size = fixP->fx_size;
+ add_symbolP = fixP->fx_addsy;
#ifdef TC_I960
- if (fixP->fx_callj && TC_S_IS_CALLNAME(add_symbolP)) {
- /* Relocation should be done via the
- associated 'bal' entry point
- symbol. */
-
- if (!TC_S_IS_BALNAME(tc_get_bal_of_call(add_symbolP))) {
- as_bad("No 'bal' entry point for leafproc %s",
- S_GET_NAME(add_symbolP));
- continue;
- }
- fixP->fx_addsy = add_symbolP = tc_get_bal_of_call(add_symbolP);
- } /* callj relocation */
+ if (fixP->fx_callj && TC_S_IS_CALLNAME(add_symbolP)) {
+ /* Relocation should be done via the
+ associated 'bal' entry point
+ symbol. */
+
+ if (!TC_S_IS_BALNAME(tc_get_bal_of_call(add_symbolP))) {
+ as_bad("No 'bal' entry point for leafproc %s",
+ S_GET_NAME(add_symbolP));
+ continue;
+ }
+ fixP->fx_addsy = add_symbolP = tc_get_bal_of_call(add_symbolP);
+ } /* callj relocation */
#endif
- sub_symbolP = fixP->fx_subsy;
- add_number = fixP->fx_offset;
- pcrel = fixP->fx_pcrel;
-
- if (add_symbolP) {
- add_symbol_segment = S_GET_SEGMENT(add_symbolP);
- } /* if there is an addend */
-
- if (sub_symbolP) {
- if (!add_symbolP) {
- /* Its just -sym */
- if (S_GET_SEGMENT(sub_symbolP) != SEG_ABSOLUTE) {
- as_bad("Negative of non-absolute symbol %s", S_GET_NAME(sub_symbolP));
- } /* not absolute */
-
- add_number -= S_GET_VALUE(sub_symbolP);
-
- /* if sub_symbol is in the same segment that add_symbol
- and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
- } else if ((S_GET_SEGMENT(sub_symbolP) == add_symbol_segment)
- && (SEG_NORMAL(add_symbol_segment)
- || (add_symbol_segment == SEG_ABSOLUTE))) {
- /* Difference of 2 symbols from same segment. */
- /* Can't make difference of 2 undefineds: 'value' means */
- /* something different for N_UNDF. */
+ sub_symbolP = fixP->fx_subsy;
+ add_number = fixP->fx_offset;
+ pcrel = fixP->fx_pcrel;
+
+ if (add_symbolP) {
+ add_symbol_segment = S_GET_SEGMENT(add_symbolP);
+ } /* if there is an addend */
+
+ if (sub_symbolP) {
+ if (!add_symbolP) {
+ /* Its just -sym */
+ if (S_GET_SEGMENT(sub_symbolP) != SEG_ABSOLUTE) {
+ as_bad("Negative of non-absolute symbol %s", S_GET_NAME(sub_symbolP));
+ } /* not absolute */
+
+ add_number -= S_GET_VALUE(sub_symbolP);
+
+ /* if sub_symbol is in the same segment that add_symbol
+ and add_symbol is either in DATA, TEXT, BSS or ABSOLUTE */
+ } else if ((S_GET_SEGMENT(sub_symbolP) == add_symbol_segment)
+ && (SEG_NORMAL(add_symbol_segment)
+ || (add_symbol_segment == SEG_ABSOLUTE))) {
+ /* Difference of 2 symbols from same segment. */
+ /* Can't make difference of 2 undefineds: 'value' means */
+ /* something different for N_UNDF. */
#ifdef TC_I960
- /* Makes no sense to use the difference of 2 arbitrary symbols
- * as the target of a call instruction.
- */
- if (fixP->fx_callj) {
- as_bad("callj to difference of 2 symbols");
- }
+ /* Makes no sense to use the difference of 2 arbitrary symbols
+ * as the target of a call instruction.
+ */
+ if (fixP->fx_callj) {
+ as_bad("callj to difference of 2 symbols");
+ }
#endif /* TC_I960 */
- add_number += S_GET_VALUE(add_symbolP) -
- S_GET_VALUE(sub_symbolP);
-
- add_symbolP = NULL;
- fixP->fx_addsy = NULL;
- } else {
- /* Different segments in subtraction. */
- know(!(S_IS_EXTERNAL(sub_symbolP) && (S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)));
-
- if ((S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)) {
- add_number -= S_GET_VALUE(sub_symbolP);
+ add_number += S_GET_VALUE(add_symbolP) -
+ S_GET_VALUE(sub_symbolP);
+
+ add_symbolP = NULL;
+ fixP->fx_addsy = NULL;
+ } else {
+ /* Different segments in subtraction. */
+ know(!(S_IS_EXTERNAL(sub_symbolP) && (S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)));
+
+ if ((S_GET_SEGMENT(sub_symbolP) == SEG_ABSOLUTE)) {
+ add_number -= S_GET_VALUE(sub_symbolP);
} else {
as_bad("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
segment_name(S_GET_SEGMENT(sub_symbolP)),
S_GET_NAME(sub_symbolP), fragP->fr_address + where);
- } /* if absolute */
+ } /* if absolute */
}
- } /* if sub_symbolP */
-
- if (add_symbolP) {
- if (add_symbol_segment == this_segment_type && pcrel) {
- /*
- * This fixup was made when the symbol's segment was
- * SEG_UNKNOWN, but it is now in the local segment.
- * So we know how to do the address without relocation.
- */
+ } /* if sub_symbolP */
+
+ if (add_symbolP) {
+ if (add_symbol_segment == this_segment_type && pcrel) {
+ /*
+ * This fixup was made when the symbol's segment was
+ * SEG_UNKNOWN, but it is now in the local segment.
+ * So we know how to do the address without relocation.
+ */
#ifdef TC_I960
- /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal',
- * in which cases it modifies *fixP as appropriate. In the case
- * of a 'calls', no further work is required, and *fixP has been
- * set up to make the rest of the code below a no-op.
- */
- reloc_callj(fixP);
+ /* reloc_callj() may replace a 'call' with a 'calls' or a 'bal',
+ * in which cases it modifies *fixP as appropriate. In the case
+ * of a 'calls', no further work is required, and *fixP has been
+ * set up to make the rest of the code below a no-op.
+ */
+ reloc_callj(fixP);
#endif /* TC_I960 */
-
- add_number += S_GET_VALUE(add_symbolP);
- add_number -= md_pcrel_from (fixP);
- pcrel = 0; /* Lie. Don't want further pcrel processing. */
- fixP->fx_addsy = NULL; /* No relocations please. */
- } else
- {
- switch (add_symbol_segment)
- {
- case SEG_ABSOLUTE:
+
+ add_number += S_GET_VALUE(add_symbolP);
+ add_number -= md_pcrel_from (fixP);
+ pcrel = 0; /* Lie. Don't want further pcrel processing. */
+ fixP->fx_addsy = NULL; /* No relocations please. */
+ } else
+ {
+ switch (add_symbol_segment)
+ {
+ case SEG_ABSOLUTE:
#ifdef TC_I960
- reloc_callj(fixP); /* See comment about reloc_callj() above*/
+ reloc_callj(fixP); /* See comment about reloc_callj() above*/
#endif /* TC_I960 */
- add_number += S_GET_VALUE(add_symbolP);
- fixP->fx_addsy = NULL;
- add_symbolP = NULL;
- break;
- default:
-
- add_number += S_GET_VALUE(add_symbolP) +
- segment_info[S_GET_SEGMENT(add_symbolP)].scnhdr.s_paddr ;
- break;
-
- case SEG_UNKNOWN:
+ add_number += S_GET_VALUE(add_symbolP);
+ fixP->fx_addsy = NULL;
+ add_symbolP = NULL;
+ break;
+ default:
+
+ add_number += S_GET_VALUE(add_symbolP) +
+ segment_info[S_GET_SEGMENT(add_symbolP)].scnhdr.s_paddr ;
+ break;
+
+ case SEG_UNKNOWN:
#ifdef TC_I960
- if ((int)fixP->fx_bit_fixP == 13) {
- /* This is a COBR instruction. They have only a
- * 13-bit displacement and are only to be used
- * for local branches: flag as error, don't generate
- * relocation.
- */
- as_bad("can't use COBR format with external label");
- fixP->fx_addsy = NULL; /* No relocations please. */
- continue;
- } /* COBR */
+ if ((int)fixP->fx_bit_fixP == 13) {
+ /* This is a COBR instruction. They have only a
+ * 13-bit displacement and are only to be used
+ * for local branches: flag as error, don't generate
+ * relocation.
+ */
+ as_bad("can't use COBR format with external label");
+ fixP->fx_addsy = NULL; /* No relocations please. */
+ continue;
+ } /* COBR */
#endif /* TC_I960 */
-
-
-
- break;
-
-
- } /* switch on symbol seg */
- } /* if not in local seg */
- } /* if there was a + symbol */
-
- if (pcrel) {
- add_number -= md_pcrel_from(fixP);
- if (add_symbolP == 0) {
- fixP->fx_addsy = & abs_symbol;
- } /* if there's an add_symbol */
- } /* if pcrel */
-
- if (!fixP->fx_bit_fixP) {
- if ((size==1 &&
- (add_number& ~0xFF) && (add_number&~0xFF!=(-1&~0xFF))) ||
- (size==2 &&
- (add_number& ~0xFFFF) && (add_number&~0xFFFF!=(-1&~0xFFFF)))) {
- as_bad("Value of %d too large for field of %d bytes at 0x%x",
- add_number, size, fragP->fr_address + where);
- } /* generic error checking */
- } /* not a bit fix */
- /* once this fix has been applied, we don't have to output anything
- nothing more need be done -*/
- md_apply_fix(fixP, add_number);
-
- } /* For each fixS in this segment. */
-
-
-} /* fixup_segment() */
+
+
+
+ break;
+
+
+ } /* switch on symbol seg */
+ } /* if not in local seg */
+ } /* if there was a + symbol */
+
+ if (pcrel) {
+ add_number -= md_pcrel_from(fixP);
+ if (add_symbolP == 0) {
+ fixP->fx_addsy = & abs_symbol;
+ } /* if there's an add_symbol */
+ } /* if pcrel */
+
+ if (!fixP->fx_bit_fixP) {
+ if ((size==1 &&
+ (add_number& ~0xFF) && (add_number&~0xFF!=(-1&~0xFF))) ||
+ (size==2 &&
+ (add_number& ~0xFFFF) && (add_number&~0xFFFF!=(-1&~0xFFFF)))) {
+ as_bad("Value of %d too large for field of %d bytes at 0x%x",
+ add_number, size, fragP->fr_address + where);
+ } /* generic error checking */
+ } /* not a bit fix */
+ /* once this fix has been applied, we don't have to output anything
+ nothing more need be done -*/
+ md_apply_fix(fixP, add_number);
+
+ } /* For each fixS in this segment. */
+
+
+} /* fixup_segment() */
#endif
-/*
- * Local Variables:
- * fill-column: 131
- * End:
- */
-/* end of obj-coffbfd.c */
+
+
/* expr.c -operands, expressions-
- Copyright (C) 1987, 1990, 1991 Free Software Foundation, Inc.
+ Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
#include "obstack.h"
-#ifdef __STDC__
+#if __STDC__ == 1
static void clean_up_expression(expressionS *expressionP);
#else /* __STDC__ */
static void clean_up_expression(); /* Internal. */
-#endif /* __STDC__ */
+#endif /* not __STDC__ */
extern const char EXP_CHARS[]; /* JF hide MD floating pt stuff all the same place */
extern const char FLT_CHARS[];
/* If nonzero, we've been asked to assemble nan, +inf or -inf */
int generic_floating_point_magic;
\f
+floating_constant(expressionP)
+expressionS *expressionP;
+{
+ /* input_line_pointer->*/
+ /* floating-point constant. */
+ int error_code;
+
+ error_code = atof_generic
+ (& input_line_pointer, ".", EXP_CHARS,
+ & generic_floating_point_number);
+
+ if (error_code)
+ {
+ if (error_code == ERROR_EXPONENT_OVERFLOW)
+ {
+ as_bad("bad floating-point constant: exponent overflow, probably assembling junk");
+ }
+ else
+ {
+ as_bad("bad floating-point constant: unknown error code=%d.", error_code);
+ }
+ }
+ expressionP->X_seg = SEG_BIG;
+ /* input_line_pointer->just after constant, */
+ /* which may point to whitespace. */
+ expressionP->X_add_number =-1;
+
+}
+
+
+
+integer_constant(radix, expressionP)
+int radix;
+expressionS *expressionP;
+
+
+{
+ register char * digit_2; /*->2nd digit of number. */
+ char c;
+
+ register valueT number; /* offset or (absolute) value */
+ register short int digit; /* value of next digit in current radix */
+ register short int maxdig = 0; /* highest permitted digit value. */
+ register int too_many_digits = 0; /* if we see >= this number of */
+ register char *name; /* points to name of symbol */
+ register symbolS * symbolP; /* points to symbol */
+
+ int small; /* true if fits in 32 bits. */
+ extern char hex_value[]; /* in hex_value.c */
+
+ /* may be bignum, or may fit in 32 bits. */
+ /*
+ * most numbers fit into 32 bits, and we want this case to be fast.
+ * so we pretend it will fit into 32 bits. if, after making up a 32
+ * bit number, we realise that we have scanned more digits than
+ * comfortably fit into 32 bits, we re-scan the digits coding
+ * them into a bignum. for decimal and octal numbers we are conservative: some
+ * numbers may be assumed bignums when in fact they do fit into 32 bits.
+ * numbers of any radix can have excess leading zeros: we strive
+ * to recognise this and cast them back into 32 bits.
+ * we must check that the bignum really is more than 32
+ * bits, and change it back to a 32-bit number if it fits.
+ * the number we are looking for is expected to be positive, but
+ * if it fits into 32 bits as an unsigned number, we let it be a 32-bit
+ * number. the cavalier approach is for speed in ordinary cases.
+ */
+
+ switch (radix)
+ {
+
+ case 2:
+ maxdig = 2;
+ too_many_digits = 33;
+ break;
+ case 8:
+ maxdig = radix = 8;
+ too_many_digits = 11;
+ break;
+ case 16:
+
+
+ maxdig = radix = 16;
+ too_many_digits = 9;
+ break;
+ case 10:
+ maxdig = radix = 10;
+ too_many_digits = 11;
+ }
+ c = *input_line_pointer;
+ input_line_pointer++;
+ digit_2 = input_line_pointer;
+ for (number=0; (digit=hex_value[c])<maxdig; c = * input_line_pointer ++)
+ {
+ number = number * radix + digit;
+ }
+ /* c contains character after number. */
+ /* input_line_pointer->char after c. */
+ small = input_line_pointer - digit_2 < too_many_digits;
+ if (! small)
+ {
+ /*
+ * we saw a lot of digits. manufacture a bignum the hard way.
+ */
+ LITTLENUM_TYPE * leader; /*->high order littlenum of the bignum. */
+ LITTLENUM_TYPE * pointer; /*->littlenum we are frobbing now. */
+ long carry;
+
+ leader = generic_bignum;
+ generic_bignum [0] = 0;
+ generic_bignum [1] = 0;
+ /* we could just use digit_2, but lets be mnemonic. */
+ input_line_pointer = -- digit_2; /*->1st digit. */
+ c = *input_line_pointer ++;
+ for (; (carry = hex_value [c]) < maxdig; c = * input_line_pointer ++)
+ {
+ for (pointer = generic_bignum;
+ pointer <= leader;
+ pointer ++)
+ {
+ long work;
+
+ work = carry + radix * * pointer;
+ * pointer = work & LITTLENUM_MASK;
+ carry = work >> LITTLENUM_NUMBER_OF_BITS;
+ }
+ if (carry)
+ {
+ if (leader < generic_bignum + SIZE_OF_LARGE_NUMBER - 1)
+ { /* room to grow a longer bignum. */
+ * ++ leader = carry;
+ }
+ }
+ }
+ /* again, c is char after number, */
+ /* input_line_pointer->after c. */
+ know(sizeof (int) * 8 == 32);
+ know(LITTLENUM_NUMBER_OF_BITS == 16);
+ /* hence the constant "2" in the next line. */
+ if (leader < generic_bignum + 2)
+ { /* will fit into 32 bits. */
+ number =
+ ((generic_bignum [1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS)
+ | (generic_bignum [0] & LITTLENUM_MASK);
+ small = 1;
+ }
+ else
+ {
+ number = leader - generic_bignum + 1; /* number of littlenums in the bignum. */
+ }
+ }
+ if (small)
+ {
+ /*
+ * here with number, in correct radix. c is the next char.
+ * note that unlike un*x, we allow "011f" "0x9f" to
+ * both mean the same as the (conventional) "9f". this is simply easier
+ * than checking for strict canonical form. syntax sux!
+ */
+ if (number<10)
+ {
+ if (0
+#ifdef local_labels_fb
+ || c=='b'
+#endif
+#ifdef local_labels_dollar
+ || (c=='$' && local_label_defined[number])
+#endif
+ )
+ {
+ /*
+ * backward ref to local label.
+ * because it is backward, expect it to be defined.
+ */
+ /*
+ * construct a local label.
+ */
+ name = local_label_name ((int)number, 0);
+ if (((symbolP = symbol_find(name)) != NULL) /* seen before */
+ && (S_IS_DEFINED(symbolP))) /* symbol is defined: ok */
+ { /* expected path: symbol defined. */
+ /* local labels are never absolute. don't waste time checking absoluteness. */
+ know(SEG_NORMAL(S_GET_SEGMENT(symbolP)));
+
+ expressionP->X_add_symbol = symbolP;
+ expressionP->X_add_number = 0;
+ expressionP->X_seg = S_GET_SEGMENT(symbolP);
+ }
+ else
+ { /* either not seen or not defined. */
+ as_bad("backw. ref to unknown label \"%d:\", 0 assumed.",
+ number);
+ expressionP->X_add_number = 0;
+ expressionP->X_seg = SEG_ABSOLUTE;
+ }
+ }
+ else
+ {
+ if (0
+#ifdef local_labels_fb
+ || c == 'f'
+#endif
+#ifdef local_labels_dollar
+ || (c=='$' && !local_label_defined[number])
+#endif
+ )
+ {
+ /*
+ * forward reference. expect symbol to be undefined or
+ * unknown. undefined: seen it before. unknown: never seen
+ * it in this pass.
+ * construct a local label name, then an undefined symbol.
+ * don't create a xseg frag for it: caller may do that.
+ * just return it as never seen before.
+ */
+ name = local_label_name((int)number, 1);
+ symbolP = symbol_find_or_make(name);
+ /* we have no need to check symbol properties. */
+#ifndef many_segments
+ /* since "know" puts its arg into a "string", we
+ can't have newlines in the argument. */
+ know(S_GET_SEGMENT(symbolP) == SEG_UNKNOWN || S_GET_SEGMENT(symbolP) == SEG_TEXT || S_GET_SEGMENT(symbolP) == SEG_DATA);
+#endif
+ expressionP->X_add_symbol = symbolP;
+ expressionP->X_seg = SEG_UNKNOWN;
+ expressionP->X_subtract_symbol = NULL;
+ expressionP->X_add_number = 0;
+ }
+ else
+ { /* really a number, not a local label. */
+ expressionP->X_add_number = number;
+ expressionP->X_seg = SEG_ABSOLUTE;
+ input_line_pointer --; /* restore following character. */
+ } /* if (c=='f') */
+ } /* if (c=='b') */
+ }
+ else
+ { /* really a number. */
+ expressionP->X_add_number = number;
+ expressionP->X_seg = SEG_ABSOLUTE;
+ input_line_pointer --; /* restore following character. */
+ } /* if (number<10) */
+ }
+ else
+ {
+ expressionP->X_add_number = number;
+ expressionP->X_seg = SEG_BIG;
+ input_line_pointer --; /*->char following number. */
+ } /* if (small) */
+}
+
+
/*
* Summary of operand().
*
*
*/
\f
+
+
static segT
- operand (expressionP)
-register expressionS * expressionP;
+operand (expressionP)
+ register expressionS * expressionP;
{
- register char c;
- register char *name; /* points to name of symbol */
- register symbolS * symbolP; /* Points to symbol */
-
- extern char hex_value[]; /* In hex_value.c */
+ register char c;
+ register symbolS * symbolP; /* points to symbol */
+ register char *name; /* points to name of symbol */
+ /* invented for humans only, hope */
+ /* optimising compiler flushes it! */
+ register short int radix; /* 2, 8, 10 or 16, 0 when floating */
+ /* 0 means we saw start of a floating- */
+ /* point constant. */
+
+ /* digits, assume it is a bignum. */
+
+
+
+
+ SKIP_WHITESPACE(); /* leading whitespace is part of operand. */
+ c = * input_line_pointer ++; /* input_line_pointer->past char in c. */
+
+ switch (c)
+ {
+#ifdef MRI
+ case '%':
+ integer_constant(2, expressionP);
+ break;
+ case '@':
+ integer_constant(8, expressionP);
+ break;
+ case '$':
+ integer_constant(16, expressionP);
+ break;
+#endif
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ input_line_pointer--;
- SKIP_WHITESPACE(); /* Leading whitespace is part of operand. */
- c = * input_line_pointer ++; /* Input_line_pointer->past char in c. */
- if (isdigit(c) || (c == 'H' && input_line_pointer[0] == '\''))
+ integer_constant(10, expressionP);
+ break;
+
+ case '0':
+ /* non-decimal radix */
+
+
+ c = *input_line_pointer;
+ switch (c)
{
- register valueT number; /* offset or (absolute) value */
- register short int digit; /* value of next digit in current radix */
- /* invented for humans only, hope */
- /* optimising compiler flushes it! */
- register short int radix; /* 2, 8, 10 or 16 */
- /* 0 means we saw start of a floating- */
- /* point constant. */
- register short int maxdig = 0;/* Highest permitted digit value. */
- register int too_many_digits = 0; /* If we see >= this number of */
- /* digits, assume it is a bignum. */
- register char * digit_2; /*->2nd digit of number. */
- int small; /* TRUE if fits in 32 bits. */
-
-
- if (c == 'H' || c == '0') { /* non-decimal radix */
- if ((c = *input_line_pointer ++)=='x' || c=='X' || c=='\'') {
- c = *input_line_pointer ++; /* read past "0x" or "0X" or H' */
- maxdig = radix = 16;
- too_many_digits = 9;
- } else {
- /* If it says '0f' and the line ends or it DOESN'T look like
- a floating point #, its a local label ref. DTRT */
- /* likewise for the b's. xoxorich. */
- if ((c == 'f' || c == 'b' || c == 'B')
- && (!*input_line_pointer ||
- (!strchr("+-.0123456789",*input_line_pointer) &&
- !strchr(EXP_CHARS,*input_line_pointer)))) {
- maxdig = radix = 10;
- too_many_digits = 11;
- c = '0';
- input_line_pointer -= 2;
-
- } else if (c == 'b' || c == 'B') {
- c = *input_line_pointer++;
- maxdig = radix = 2;
- too_many_digits = 33;
-
- } else if (c && strchr(FLT_CHARS,c)) {
- radix = 0; /* Start of floating-point constant. */
- /* input_line_pointer->1st char of number. */
- expressionP->X_add_number = -(isupper(c) ? tolower(c) : c);
-
- } else { /* By elimination, assume octal radix. */
- radix = maxdig = 8;
- too_many_digits = 11;
- }
- } /* c == char after "0" or "0x" or "0X" or "0e" etc. */
- } else {
- maxdig = radix = 10;
- too_many_digits = 11;
- } /* if operand starts with a zero */
-
- if (radix) { /* Fixed-point integer constant. */
- /* May be bignum, or may fit in 32 bits. */
- /*
- * Most numbers fit into 32 bits, and we want this case to be fast.
- * So we pretend it will fit into 32 bits. If, after making up a 32
- * bit number, we realise that we have scanned more digits than
- * comfortably fit into 32 bits, we re-scan the digits coding
- * them into a bignum. For decimal and octal numbers we are conservative: some
- * numbers may be assumed bignums when in fact they do fit into 32 bits.
- * Numbers of any radix can have excess leading zeros: we strive
- * to recognise this and cast them back into 32 bits.
- * We must check that the bignum really is more than 32
- * bits, and change it back to a 32-bit number if it fits.
- * The number we are looking for is expected to be positive, but
- * if it fits into 32 bits as an unsigned number, we let it be a 32-bit
- * number. The cavalier approach is for speed in ordinary cases.
- */
- digit_2 = input_line_pointer;
- for (number=0; (digit=hex_value[c])<maxdig; c = * input_line_pointer ++)
- {
- number = number * radix + digit;
- }
- /* C contains character after number. */
- /* Input_line_pointer->char after C. */
- small = input_line_pointer - digit_2 < too_many_digits;
- if (! small)
- {
- /*
- * We saw a lot of digits. Manufacture a bignum the hard way.
- */
- LITTLENUM_TYPE * leader; /*->high order littlenum of the bignum. */
- LITTLENUM_TYPE * pointer; /*->littlenum we are frobbing now. */
- long carry;
-
- leader = generic_bignum;
- generic_bignum [0] = 0;
- generic_bignum [1] = 0;
- /* We could just use digit_2, but lets be mnemonic. */
- input_line_pointer = -- digit_2; /*->1st digit. */
- c = *input_line_pointer ++;
- for (; (carry = hex_value [c]) < maxdig; c = * input_line_pointer ++)
- {
- for (pointer = generic_bignum;
- pointer <= leader;
- pointer ++)
- {
- long work;
-
- work = carry + radix * * pointer;
- * pointer = work & LITTLENUM_MASK;
- carry = work >> LITTLENUM_NUMBER_OF_BITS;
- }
- if (carry)
- {
- if (leader < generic_bignum + SIZE_OF_LARGE_NUMBER - 1)
- { /* Room to grow a longer bignum. */
- * ++ leader = carry;
- }
- }
- }
- /* Again, C is char after number, */
- /* input_line_pointer->after C. */
- know(sizeof (int) * 8 == 32);
- know(LITTLENUM_NUMBER_OF_BITS == 16);
- /* Hence the constant "2" in the next line. */
- if (leader < generic_bignum + 2)
- { /* Will fit into 32 bits. */
- number =
- ((generic_bignum [1] & LITTLENUM_MASK) << LITTLENUM_NUMBER_OF_BITS)
- | (generic_bignum [0] & LITTLENUM_MASK);
- small = 1;
- }
- else
- {
- number = leader - generic_bignum + 1; /* Number of littlenums in the bignum. */
- }
- }
- if (small)
- {
- /*
- * Here with number, in correct radix. c is the next char.
- * Note that unlike Un*x, we allow "011f" "0x9f" to
- * both mean the same as the (conventional) "9f". This is simply easier
- * than checking for strict canonical form. Syntax sux!
- */
- if (number<10)
- {
- if (0
-#ifdef LOCAL_LABELS_FB
- || c=='b'
-#endif
-#ifdef LOCAL_LABELS_DOLLAR
- || (c=='$' && local_label_defined[number])
-#endif
- )
- {
- /*
- * Backward ref to local label.
- * Because it is backward, expect it to be DEFINED.
- */
- /*
- * Construct a local label.
- */
- name = local_label_name ((int)number, 0);
- if (((symbolP = symbol_find(name)) != NULL) /* seen before */
- && (S_IS_DEFINED(symbolP))) /* symbol is defined: OK */
- { /* Expected path: symbol defined. */
- /* Local labels are never absolute. Don't waste time checking absoluteness. */
- know(SEG_NORMAL(S_GET_SEGMENT(symbolP)));
-
- expressionP->X_add_symbol = symbolP;
- expressionP->X_add_number = 0;
- expressionP->X_seg = S_GET_SEGMENT(symbolP);
- }
- else
- { /* Either not seen or not defined. */
- as_bad("Backw. ref to unknown label \"%d:\", 0 assumed.",
- number);
- expressionP->X_add_number = 0;
- expressionP->X_seg = SEG_ABSOLUTE;
- }
- }
- else
- {
- if (0
-#ifdef LOCAL_LABELS_FB
- || c == 'f'
-#endif
-#ifdef LOCAL_LABELS_DOLLAR
- || (c=='$' && !local_label_defined[number])
-#endif
- )
- {
- /*
- * Forward reference. Expect symbol to be undefined or
- * unknown. Undefined: seen it before. Unknown: never seen
- * it in this pass.
- * Construct a local label name, then an undefined symbol.
- * Don't create a XSEG frag for it: caller may do that.
- * Just return it as never seen before.
- */
- name = local_label_name((int)number, 1);
- symbolP = symbol_find_or_make(name);
- /* We have no need to check symbol properties. */
-#ifndef MANY_SEGMENTS
- /* Since "know" puts its arg into a "string", we
- can't have newlines in the argument. */
- know(S_GET_SEGMENT(symbolP) == SEG_UNKNOWN || S_GET_SEGMENT(symbolP) == SEG_TEXT || S_GET_SEGMENT(symbolP) == SEG_DATA);
-#endif
- expressionP->X_add_symbol = symbolP;
- expressionP->X_seg = SEG_UNKNOWN;
- expressionP->X_subtract_symbol = NULL;
- expressionP->X_add_number = 0;
- }
- else
- { /* Really a number, not a local label. */
- expressionP->X_add_number = number;
- expressionP->X_seg = SEG_ABSOLUTE;
- input_line_pointer --; /* Restore following character. */
- } /* if (c=='f') */
- } /* if (c=='b') */
- }
- else
- { /* Really a number. */
- expressionP->X_add_number = number;
- expressionP->X_seg = SEG_ABSOLUTE;
- input_line_pointer --; /* Restore following character. */
- } /* if (number<10) */
- }
- else
- {
- expressionP->X_add_number = number;
- expressionP->X_seg = SEG_BIG;
- input_line_pointer --; /*->char following number. */
- } /* if (small) */
- } /* (If integer constant) */
- else
- { /* input_line_pointer->*/
- /* floating-point constant. */
- int error_code;
-
- error_code = atof_generic
- (& input_line_pointer, ".", EXP_CHARS,
- & generic_floating_point_number);
-
- if (error_code)
- {
- if (error_code == ERROR_EXPONENT_OVERFLOW)
- {
- as_bad("Bad floating-point constant: exponent overflow, probably assembling junk");
- }
- else
- {
- as_bad("Bad floating-point constant: unknown error code=%d.", error_code);
- }
- }
- expressionP->X_seg = SEG_BIG;
- /* input_line_pointer->just after constant, */
- /* which may point to whitespace. */
- know(expressionP->X_add_number < 0); /* < 0 means "floating point". */
- } /* if (not floating-point constant) */
+
+ default:
+ /* The string was only zero */
+ expressionP->X_add_symbol = 0;
+ expressionP->X_add_number = 0;
+ expressionP->X_seg = SEG_ABSOLUTE;
+ break;
+
+ case 'x':
+ case 'X':
+ input_line_pointer++;
+ integer_constant(16, expressionP);
+ break;
+ case 'B':
+ case 'b':
+ input_line_pointer++;
+ integer_constant(2, expressionP);
+ break;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ integer_constant(8, expressionP);
+ break;
+
+ case 'f':
+ /* if it says '0f' and the line ends or it doesn't look like
+ a floating point #, its a local label ref. dtrt */
+ /* likewise for the b's. xoxorich. */
+ if ((c == 'f' || c == 'b' || c == 'b')
+ && (!*input_line_pointer ||
+ (!strchr("+-.0123456789",*input_line_pointer) &&
+ !strchr(EXP_CHARS,*input_line_pointer))))
+ {
+ input_line_pointer -= 2;
+ integer_constant(10, expressionP);
+ break;
+ }
+
+ case 'd':
+ case 'D':
+ case 'F':
+
+ case 'e':
+ case 'E':
+ case 'g':
+ case 'G':
+
+ input_line_pointer++;
+ floating_constant(expressionP);
+ break;
}
- else if(c=='.' && !is_part_of_name(*input_line_pointer)) {
- extern struct obstack frags;
-
- /*
- JF: '.' is pseudo symbol with value of current location in current
- segment. . .
- */
- symbolP = symbol_new("L0\001",
- now_seg,
- (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
- frag_now);
-
- expressionP->X_add_number=0;
- expressionP->X_add_symbol=symbolP;
- expressionP->X_seg = now_seg;
-
- } else if (is_name_beginner(c)) /* here if did not begin with a digit */
+
+ break;
+ case '(':
+ /* didn't begin with digit & not a name */
+ {
+ (void)expression(expressionP);
+ /* Expression() will pass trailing whitespace */
+ if (* input_line_pointer ++ != ')')
{
- /*
- * Identifier begins here.
- * This is kludged for speed, so code is repeated.
- */
- name = -- input_line_pointer;
- c = get_symbol_end();
- symbolP = symbol_find_or_make(name);
- /*
- * If we have an absolute symbol or a reg, then we know its value now.
- */
- expressionP->X_seg = S_GET_SEGMENT(symbolP);
- switch (expressionP->X_seg)
+ as_bad("Missing ')' assumed");
+ input_line_pointer --;
+ }
+ /* here with input_line_pointer->char after "(...)" */
+ }
+ return;
+
+
+ case '\'':
+ /*
+ * Warning: to conform to other people's assemblers NO ESCAPEMENT is permitted
+ * for a single quote. The next character, parity errors and all, is taken
+ * as the value of the operand. VERY KINKY.
+ */
+ expressionP->X_add_number = * input_line_pointer ++;
+ expressionP->X_seg = SEG_ABSOLUTE;
+ break;
+
+ case '~':
+ case '-':
+ case '+':
+
+ {
+ /* unary operator: hope for SEG_ABSOLUTE */
+ switch(operand (expressionP)) {
+ case SEG_ABSOLUTE:
+ /* input_line_pointer -> char after operand */
+ if ( c=='-' )
{
- case SEG_ABSOLUTE:
- case SEG_REGISTER:
- expressionP->X_add_number = S_GET_VALUE(symbolP);
- break;
-
- default:
- expressionP->X_add_number = 0;
- expressionP->X_add_symbol = symbolP;
+ expressionP -> X_add_number = - expressionP -> X_add_number;
+ /*
+ * Notice: '-' may overflow: no warning is given. This is compatible
+ * with other people's assemblers. Sigh.
+ */
}
- * input_line_pointer = c;
- expressionP->X_subtract_symbol = NULL;
- }
- else if (c=='(')/* didn't begin with digit & not a name */
- {
- (void)expression(expressionP);
- /* Expression() will pass trailing whitespace */
- if (* input_line_pointer ++ != ')')
+ else
{
- as_bad("Missing ')' assumed");
- input_line_pointer --;
+ expressionP -> X_add_number = ~ expressionP -> X_add_number;
}
- /* here with input_line_pointer->char after "(...)" */
- }
- else if (c == '~' || c == '-' || c == '+') {
- /* unary operator: hope for SEG_ABSOLUTE */
- switch (operand (expressionP)) {
- case SEG_ABSOLUTE:
- /* input_line_pointer->char after operand */
- if (c=='-') {
- expressionP->X_add_number = - expressionP->X_add_number;
- /*
- * Notice: '-' may overflow: no warning is given. This is compatible
- * with other people's assemblers. Sigh.
- */
- } else if (c == '~') {
- expressionP->X_add_number = ~ expressionP->X_add_number;
- } else if (c != '+') {
- know(0);
- } /* switch on unary operator */
+ break;
+
+ case SEG_TEXT:
+ case SEG_DATA:
+ case SEG_BSS:
+ case SEG_PASS1:
+ case SEG_UNKNOWN:
+ if(c=='-') { /* JF I hope this hack works */
+ expressionP->X_subtract_symbol=expressionP->X_add_symbol;
+ expressionP->X_add_symbol=0;
+ expressionP->X_seg=SEG_DIFFERENCE;
break;
-
- default: /* unary on non-absolute is unsuported */
- if (!SEG_NORMAL(operand(expressionP)))
- {
- as_bad("Unary operator %c ignored because bad operand follows", c);
- break;
- }
- /* Fall through for normal segments ****/
- case SEG_PASS1:
- case SEG_UNKNOWN:
- if(c=='-') { /* JF I hope this hack works */
- expressionP->X_subtract_symbol=expressionP->X_add_symbol;
- expressionP->X_add_symbol=0;
- expressionP->X_seg=SEG_DIFFERENCE;
- break;
- }
- /* Expression undisturbed from operand(). */
- }
- }
- else if (c=='\'')
+ }
+ default: /* unary on non-absolute is unsuported */
+ as_warn("Unary operator %c ignored because bad operand follows", c);
+ break;
+ /* Expression undisturbed from operand(). */
+ }
+ }
+
+
+
+ break;
+
+ case '.':
+ if( !is_part_of_name(*input_line_pointer))
{
- /*
- * Warning: to conform to other people's assemblers NO ESCAPEMENT is permitted
- * for a single quote. The next character, parity errors and all, is taken
- * as the value of the operand. VERY KINKY.
- */
- expressionP->X_add_number = * input_line_pointer ++;
- expressionP->X_seg = SEG_ABSOLUTE;
+ extern struct obstack frags;
+
+ /*
+ JF: '.' is pseudo symbol with value of current location in current
+ segment. . .
+ */
+ symbolP = symbol_new("L0\001",
+ now_seg,
+ (valueT)(obstack_next_free(&frags)-frag_now->fr_literal),
+ frag_now);
+
+ expressionP->X_add_number=0;
+ expressionP->X_add_symbol=symbolP;
+ expressionP->X_seg = now_seg;
+ break;
+
}
- else
+ else
{
+ goto isname;
+
+
+ }
+
+ case '\n':
/* can't imagine any other kind of operand */
expressionP->X_seg = SEG_ABSENT;
input_line_pointer --;
md_operand (expressionP);
+ break;
+ /* Fall through */
+ default:
+ if (is_name_beginner(c)) /* here if did not begin with a digit */
+ {
+ /*
+ * Identifier begins here.
+ * This is kludged for speed, so code is repeated.
+ */
+isname:
+ name = -- input_line_pointer;
+ c = get_symbol_end();
+ symbolP = symbol_find_or_make(name);
+ /*
+ * If we have an absolute symbol or a reg, then we know its value now.
+ */
+ expressionP->X_seg = S_GET_SEGMENT(symbolP);
+ switch (expressionP->X_seg)
+ {
+ case SEG_ABSOLUTE:
+ case SEG_REGISTER:
+ expressionP->X_add_number = S_GET_VALUE(symbolP);
+ break;
+
+ default:
+ expressionP->X_add_number = 0;
+ expressionP->X_add_symbol = symbolP;
+ }
+ * input_line_pointer = c;
+ expressionP->X_subtract_symbol = NULL;
}
- /*
- * It is more 'efficient' to clean up the expressions when they are created.
- * Doing it here saves lines of code.
- */
- clean_up_expression (expressionP);
- SKIP_WHITESPACE(); /*->1st char after operand. */
- know(* input_line_pointer != ' ');
- return (expressionP->X_seg);
+ else
+ {
+ as_bad("Bad expression");
+ expressionP->X_add_number = 0;
+ expressionP->X_seg = SEG_ABSOLUTE;
+
+ }
+
+ }
+
+
+
+
+
+
+
+ /*
+ * It is more 'efficient' to clean up the expressionS when they are created.
+ * Doing it here saves lines of code.
+ */
+ clean_up_expression (expressionP);
+ SKIP_WHITESPACE(); /*->1st char after operand. */
+ know(* input_line_pointer != ' ');
+ return (expressionP->X_seg);
} /* operand() */
+
\f
/* Internal. Simplify a struct expression for use by expr() */
*/
static void
- clean_up_expression (expressionP)
-register expressionS * expressionP;
+clean_up_expression (expressionP)
+ register expressionS * expressionP;
{
- switch (expressionP->X_seg)
- {
- case SEG_ABSENT:
- case SEG_PASS1:
+ switch (expressionP->X_seg)
+ {
+ case SEG_ABSENT:
+ case SEG_PASS1:
expressionP->X_add_symbol = NULL;
expressionP->X_subtract_symbol = NULL;
expressionP->X_add_number = 0;
break;
-
- case SEG_BIG:
- case SEG_ABSOLUTE:
+
+ case SEG_BIG:
+ case SEG_ABSOLUTE:
expressionP->X_subtract_symbol = NULL;
expressionP->X_add_symbol = NULL;
break;
-
- case SEG_UNKNOWN:
+
+ case SEG_UNKNOWN:
expressionP->X_subtract_symbol = NULL;
break;
-
- case SEG_DIFFERENCE:
+
+ case SEG_DIFFERENCE:
/*
* It does not hurt to 'cancel' NULL==NULL
* when comparing symbols for 'eq'ness.
expressionP->X_seg = SEG_ABSOLUTE;
}
break;
-
- case SEG_REGISTER:
+
+ case SEG_REGISTER:
expressionP->X_add_symbol = NULL;
expressionP->X_subtract_symbol = NULL;
break;
-
- default:
+
+ default:
if (SEG_NORMAL(expressionP->X_seg)) {
- expressionP->X_subtract_symbol = NULL;
+ expressionP->X_subtract_symbol = NULL;
}
else {
BAD_CASE (expressionP->X_seg);
}
break;
- }
+ }
} /* clean_up_expression() */
\f
/*
*/
static segT
- expr_part (symbol_1_PP, symbol_2_P)
-symbolS ** symbol_1_PP;
-symbolS * symbol_2_P;
+expr_part (symbol_1_PP, symbol_2_P)
+ symbolS ** symbol_1_PP;
+ symbolS * symbol_2_P;
{
segT return_value;
#ifndef MANY_SEGMENTS
know((* symbol_1_PP) == NULL || (S_GET_SEGMENT(*symbol_1_PP) == SEG_TEXT) || (S_GET_SEGMENT(*symbol_1_PP) == SEG_DATA) || (S_GET_SEGMENT(*symbol_1_PP) == SEG_BSS) || (!S_IS_DEFINED(* symbol_1_PP)));
know(symbol_2_P == NULL || (S_GET_SEGMENT(symbol_2_P) == SEG_TEXT) || (S_GET_SEGMENT(symbol_2_P) == SEG_DATA) || (S_GET_SEGMENT(symbol_2_P) == SEG_BSS) || (!S_IS_DEFINED(symbol_2_P)));
#endif
- if (* symbol_1_PP)
+ if (* symbol_1_PP)
{
- if (!S_IS_DEFINED(* symbol_1_PP))
+ if (!S_IS_DEFINED(* symbol_1_PP))
{
- if (symbol_2_P)
+ if (symbol_2_P)
{
return_value = SEG_PASS1;
* symbol_1_PP = NULL;
}
- else
+ else
{
know(!S_IS_DEFINED(* symbol_1_PP));
return_value = SEG_UNKNOWN;
}
}
- else
+ else
{
- if (symbol_2_P)
+ if (symbol_2_P)
{
- if (!S_IS_DEFINED(symbol_2_P))
+ if (!S_IS_DEFINED(symbol_2_P))
{
- * symbol_1_PP = NULL;
- return_value = SEG_PASS1;
+ * symbol_1_PP = NULL;
+ return_value = SEG_PASS1;
}
- else
+ else
{
- /* {seg1} - {seg2} */
- as_bad("Expression too complex, 2 symbols forgotten: \"%s\" \"%s\"",
- S_GET_NAME(* symbol_1_PP), S_GET_NAME(symbol_2_P));
- * symbol_1_PP = NULL;
- return_value = SEG_ABSOLUTE;
+ /* {seg1} - {seg2} */
+ as_bad("Expression too complex, 2 symbolS forgotten: \"%s\" \"%s\"",
+ S_GET_NAME(* symbol_1_PP), S_GET_NAME(symbol_2_P));
+ * symbol_1_PP = NULL;
+ return_value = SEG_ABSOLUTE;
}
}
- else
+ else
{
- return_value = S_GET_SEGMENT(* symbol_1_PP);
+ return_value = S_GET_SEGMENT(* symbol_1_PP);
}
}
}
- else
+ else
{ /* (* symbol_1_PP) == NULL */
- if (symbol_2_P)
+ if (symbol_2_P)
{
- * symbol_1_PP = symbol_2_P;
- return_value = S_GET_SEGMENT(symbol_2_P);
+ * symbol_1_PP = symbol_2_P;
+ return_value = S_GET_SEGMENT(symbol_2_P);
}
- else
+ else
{
- * symbol_1_PP = NULL;
- return_value = SEG_ABSOLUTE;
+ * symbol_1_PP = NULL;
+ return_value = SEG_ABSOLUTE;
}
}
#ifndef MANY_SEGMENTS
- know(return_value == SEG_ABSOLUTE || return_value == SEG_TEXT || return_value == SEG_DATA || return_value == SEG_BSS || return_value == SEG_UNKNOWN || return_value == SEG_PASS1);
+ know(return_value == SEG_ABSOLUTE || return_value == SEG_TEXT || return_value == SEG_DATA || return_value == SEG_BSS || return_value == SEG_UNKNOWN || return_value == SEG_PASS1);
#endif
- know((*symbol_1_PP) == NULL || (S_GET_SEGMENT(*symbol_1_PP) == return_value));
- return (return_value);
+ know((*symbol_1_PP) == NULL || (S_GET_SEGMENT(*symbol_1_PP) == return_value));
+ return (return_value);
} /* expr_part() */
\f
/* Expression parser. */
* 3 * / % << >>
*/
static const operator_rankT
- op_rank [] = { 0, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1 };
+op_rank [] = { 0, 3, 3, 3, 3, 3, 2, 2, 2, 2, 1, 1 };
\f
/* Return resultP->X_seg. */
segT expr(rank, resultP)
- register operator_rankT rank; /* Larger # is higher rank. */
- register expressionS *resultP; /* Deliver result here. */
+register operator_rankT rank; /* Larger # is higher rank. */
+register expressionS *resultP; /* Deliver result here. */
{
- expressionS right;
- register operatorT op_left;
- register char c_left; /* 1st operator character. */
- register operatorT op_right;
- register char c_right;
-
- know(rank >= 0);
- (void)operand (resultP);
- know(* input_line_pointer != ' '); /* Operand() gobbles spaces. */
- c_left = * input_line_pointer; /* Potential operator character. */
- op_left = op_encoding [c_left];
- while (op_left != O_illegal && op_rank [(int) op_left] > rank)
+ expressionS right;
+ register operatorT op_left;
+ register char c_left; /* 1st operator character. */
+ register operatorT op_right;
+ register char c_right;
+
+ know(rank >= 0);
+ (void)operand (resultP);
+ know(* input_line_pointer != ' '); /* Operand() gobbles spaces. */
+ c_left = * input_line_pointer; /* Potential operator character. */
+ op_left = op_encoding [c_left];
+ while (op_left != O_illegal && op_rank [(int) op_left] > rank)
{
- input_line_pointer ++; /*->after 1st character of operator. */
- /* Operators "<<" and ">>" have 2 characters. */
- if (* input_line_pointer == c_left && (c_left == '<' || c_left == '>'))
+ input_line_pointer ++; /*->after 1st character of operator. */
+ /* Operators "<<" and ">>" have 2 characters. */
+ if (* input_line_pointer == c_left && (c_left == '<' || c_left == '>'))
{
- input_line_pointer ++;
+ input_line_pointer ++;
} /*->after operator. */
- if (SEG_ABSENT == expr (op_rank[(int) op_left], &right))
+ if (SEG_ABSENT == expr (op_rank[(int) op_left], &right))
{
- as_warn("Missing operand value assumed absolute 0.");
- resultP->X_add_number = 0;
- resultP->X_subtract_symbol = NULL;
- resultP->X_add_symbol = NULL;
- resultP->X_seg = SEG_ABSOLUTE;
+ as_warn("Missing operand value assumed absolute 0.");
+ resultP->X_add_number = 0;
+ resultP->X_subtract_symbol = NULL;
+ resultP->X_add_symbol = NULL;
+ resultP->X_seg = SEG_ABSOLUTE;
}
- know(* input_line_pointer != ' ');
- c_right = * input_line_pointer;
- op_right = op_encoding [c_right];
- if (* input_line_pointer == c_right && (c_right == '<' || c_right == '>'))
+ know(* input_line_pointer != ' ');
+ c_right = * input_line_pointer;
+ op_right = op_encoding [c_right];
+ if (* input_line_pointer == c_right && (c_right == '<' || c_right == '>'))
{
- input_line_pointer ++;
+ input_line_pointer ++;
} /*->after operator. */
- know((int) op_right == 0 || op_rank [(int) op_right] <= op_rank[(int) op_left]);
- /* input_line_pointer->after right-hand quantity. */
- /* left-hand quantity in resultP */
- /* right-hand quantity in right. */
- /* operator in op_left. */
- if (resultP->X_seg == SEG_PASS1 || right . X_seg == SEG_PASS1)
+ know((int) op_right == 0 || op_rank [(int) op_right] <= op_rank[(int) op_left]);
+ /* input_line_pointer->after right-hand quantity. */
+ /* left-hand quantity in resultP */
+ /* right-hand quantity in right. */
+ /* operator in op_left. */
+ if (resultP->X_seg == SEG_PASS1 || right . X_seg == SEG_PASS1)
{
- resultP->X_seg = SEG_PASS1;
+ resultP->X_seg = SEG_PASS1;
}
- else
+ else
{
- if (resultP->X_seg == SEG_BIG)
+ if (resultP->X_seg == SEG_BIG)
{
- as_warn("Left operand of %c is a %s. Integer 0 assumed.",
- c_left, resultP->X_add_number > 0 ? "bignum" : "float");
- resultP->X_seg = SEG_ABSOLUTE;
- resultP->X_add_symbol = 0;
- resultP->X_subtract_symbol = 0;
- resultP->X_add_number = 0;
+ as_warn("Left operand of %c is a %s. Integer 0 assumed.",
+ c_left, resultP->X_add_number > 0 ? "bignum" : "float");
+ resultP->X_seg = SEG_ABSOLUTE;
+ resultP->X_add_symbol = 0;
+ resultP->X_subtract_symbol = 0;
+ resultP->X_add_number = 0;
}
- if (right . X_seg == SEG_BIG)
+ if (right . X_seg == SEG_BIG)
{
- as_warn("Right operand of %c is a %s. Integer 0 assumed.",
- c_left, right . X_add_number > 0 ? "bignum" : "float");
- right . X_seg = SEG_ABSOLUTE;
- right . X_add_symbol = 0;
- right . X_subtract_symbol = 0;
- right . X_add_number = 0;
+ as_warn("Right operand of %c is a %s. Integer 0 assumed.",
+ c_left, right . X_add_number > 0 ? "bignum" : "float");
+ right . X_seg = SEG_ABSOLUTE;
+ right . X_add_symbol = 0;
+ right . X_subtract_symbol = 0;
+ right . X_add_number = 0;
}
- if (op_left == O_subtract)
+ if (op_left == O_subtract)
{
- /*
- * Convert - into + by exchanging symbols and negating number.
- * I know -infinity can't be negated in 2's complement:
- * but then it can't be subtracted either. This trick
- * does not cause any further inaccuracy.
- */
-
- register symbolS * symbolP;
-
- right . X_add_number = - right . X_add_number;
- symbolP = right . X_add_symbol;
- right . X_add_symbol = right . X_subtract_symbol;
- right . X_subtract_symbol = symbolP;
- if (symbolP)
+ /*
+ * Convert - into + by exchanging symbolS and negating number.
+ * I know -infinity can't be negated in 2's complement:
+ * but then it can't be subtracted either. This trick
+ * does not cause any further inaccuracy.
+ */
+
+ register symbolS * symbolP;
+
+ right . X_add_number = - right . X_add_number;
+ symbolP = right . X_add_symbol;
+ right . X_add_symbol = right . X_subtract_symbol;
+ right . X_subtract_symbol = symbolP;
+ if (symbolP)
{
- right . X_seg = SEG_DIFFERENCE;
+ right . X_seg = SEG_DIFFERENCE;
}
- op_left = O_add;
+ op_left = O_add;
}
- \f
- if (op_left == O_add)
+\f
+ if (op_left == O_add)
{
- segT seg1;
- segT seg2;
+ segT seg1;
+ segT seg2;
#ifndef MANY_SEGMENTS
- know(resultP->X_seg == SEG_DATA || resultP->X_seg == SEG_TEXT || resultP->X_seg == SEG_BSS || resultP->X_seg == SEG_UNKNOWN || resultP->X_seg == SEG_DIFFERENCE || resultP->X_seg == SEG_ABSOLUTE || resultP->X_seg == SEG_PASS1);
- know(right.X_seg == SEG_DATA || right.X_seg == SEG_TEXT || right.X_seg == SEG_BSS || right.X_seg == SEG_UNKNOWN || right.X_seg == SEG_DIFFERENCE || right.X_seg == SEG_ABSOLUTE || right.X_seg == SEG_PASS1);
+ know(resultP->X_seg == SEG_DATA || resultP->X_seg == SEG_TEXT || resultP->X_seg == SEG_BSS || resultP->X_seg == SEG_UNKNOWN || resultP->X_seg == SEG_DIFFERENCE || resultP->X_seg == SEG_ABSOLUTE || resultP->X_seg == SEG_PASS1);
+ know(right.X_seg == SEG_DATA || right.X_seg == SEG_TEXT || right.X_seg == SEG_BSS || right.X_seg == SEG_UNKNOWN || right.X_seg == SEG_DIFFERENCE || right.X_seg == SEG_ABSOLUTE || right.X_seg == SEG_PASS1);
#endif
- clean_up_expression (& right);
- clean_up_expression (resultP);
-
- seg1 = expr_part (& resultP->X_add_symbol, right . X_add_symbol);
- seg2 = expr_part (& resultP->X_subtract_symbol, right . X_subtract_symbol);
- if (seg1 == SEG_PASS1 || seg2 == SEG_PASS1) {
- need_pass_2 = 1;
- resultP->X_seg = SEG_PASS1;
- } else if (seg2 == SEG_ABSOLUTE)
- resultP->X_seg = seg1;
- else if (seg1 != SEG_UNKNOWN
- && seg1 != SEG_ABSOLUTE
- && seg2 != SEG_UNKNOWN
- && seg1 != seg2) {
- know(seg2 != SEG_ABSOLUTE);
- know(resultP->X_subtract_symbol);
+ clean_up_expression (& right);
+ clean_up_expression (resultP);
+
+ seg1 = expr_part (& resultP->X_add_symbol, right . X_add_symbol);
+ seg2 = expr_part (& resultP->X_subtract_symbol, right . X_subtract_symbol);
+ if (seg1 == SEG_PASS1 || seg2 == SEG_PASS1) {
+ need_pass_2 = 1;
+ resultP->X_seg = SEG_PASS1;
+ } else if (seg2 == SEG_ABSOLUTE)
+ resultP->X_seg = seg1;
+ else if (seg1 != SEG_UNKNOWN
+ && seg1 != SEG_ABSOLUTE
+ && seg2 != SEG_UNKNOWN
+ && seg1 != seg2) {
+ know(seg2 != SEG_ABSOLUTE);
+ know(resultP->X_subtract_symbol);
#ifndef MANY_SEGMENTS
- know(seg1 == SEG_TEXT || seg1 == SEG_DATA || seg1== SEG_BSS);
- know(seg2 == SEG_TEXT || seg2 == SEG_DATA || seg2== SEG_BSS);
+ know(seg1 == SEG_TEXT || seg1 == SEG_DATA || seg1== SEG_BSS);
+ know(seg2 == SEG_TEXT || seg2 == SEG_DATA || seg2== SEG_BSS);
#endif
- know(resultP->X_add_symbol);
- know(resultP->X_subtract_symbol);
- as_bad("Expression too complex: forgetting %s - %s",
- S_GET_NAME(resultP->X_add_symbol),
- S_GET_NAME(resultP->X_subtract_symbol));
- resultP->X_seg = SEG_ABSOLUTE;
- /* Clean_up_expression() will do the rest. */
- } else
- resultP->X_seg = SEG_DIFFERENCE;
-
- resultP->X_add_number += right . X_add_number;
- clean_up_expression (resultP);
- }
- else
+ know(resultP->X_add_symbol);
+ know(resultP->X_subtract_symbol);
+ as_bad("Expression too complex: forgetting %s - %s",
+ S_GET_NAME(resultP->X_add_symbol),
+ S_GET_NAME(resultP->X_subtract_symbol));
+ resultP->X_seg = SEG_ABSOLUTE;
+ /* Clean_up_expression() will do the rest. */
+ } else
+ resultP->X_seg = SEG_DIFFERENCE;
+
+ resultP->X_add_number += right . X_add_number;
+ clean_up_expression (resultP);
+ }
+ else
{ /* Not +. */
- if (resultP->X_seg == SEG_UNKNOWN || right . X_seg == SEG_UNKNOWN)
+ if (resultP->X_seg == SEG_UNKNOWN || right . X_seg == SEG_UNKNOWN)
{
- resultP->X_seg = SEG_PASS1;
- need_pass_2 = 1;
+ resultP->X_seg = SEG_PASS1;
+ need_pass_2 = 1;
}
- else
+ else
{
- resultP->X_subtract_symbol = NULL;
- resultP->X_add_symbol = NULL;
- /* Will be SEG_ABSOLUTE. */
- if (resultP->X_seg != SEG_ABSOLUTE || right . X_seg != SEG_ABSOLUTE)
+ resultP->X_subtract_symbol = NULL;
+ resultP->X_add_symbol = NULL;
+ /* Will be SEG_ABSOLUTE. */
+ if (resultP->X_seg != SEG_ABSOLUTE || right . X_seg != SEG_ABSOLUTE)
{
- as_bad("Relocation error. Absolute 0 assumed.");
- resultP->X_seg = SEG_ABSOLUTE;
- resultP->X_add_number = 0;
+ as_bad("Relocation error. Absolute 0 assumed.");
+ resultP->X_seg = SEG_ABSOLUTE;
+ resultP->X_add_number = 0;
}
- else
+ else
{
- switch (op_left)
+ switch (op_left)
{
case O_bit_inclusive_or:
- resultP->X_add_number |= right . X_add_number;
- break;
-
+ resultP->X_add_number |= right . X_add_number;
+ break;
+
case O_modulus:
- if (right . X_add_number)
+ if (right . X_add_number)
{
- resultP->X_add_number %= right . X_add_number;
+ resultP->X_add_number %= right . X_add_number;
}
- else
+ else
{
- as_warn("Division by 0. 0 assumed.");
- resultP->X_add_number = 0;
+ as_warn("Division by 0. 0 assumed.");
+ resultP->X_add_number = 0;
}
- break;
-
+ break;
+
case O_bit_and:
- resultP->X_add_number &= right . X_add_number;
- break;
-
+ resultP->X_add_number &= right . X_add_number;
+ break;
+
case O_multiply:
- resultP->X_add_number *= right . X_add_number;
- break;
-
+ resultP->X_add_number *= right . X_add_number;
+ break;
+
case O_divide:
- if (right . X_add_number)
+ if (right . X_add_number)
{
- resultP->X_add_number /= right . X_add_number;
+ resultP->X_add_number /= right . X_add_number;
}
- else
+ else
{
as_warn("Division by 0. 0 assumed.");
resultP->X_add_number = 0;
/* listing.c - mainting assembly listings
Copyright (C) 1991, 1992 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 2, 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. */
+
+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 2, 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. */
/*
- Contributed by Steve Chamberlain
- sac@cygnus.com
-
-
- A listing page looks like:
-
- LISTING_HEADER sourcefilename pagenumber
- TITLE LINE
- SUBTITLE LINE
- linenumber address data source
- linenumber address data source
- linenumber address data source
- linenumber address data source
-
- If not overridden, the listing commands are:
-
- .title "stuff"
- Put "stuff" onto the title line
- .sbttl "stuff"
- Put stuff onto the subtitle line
-
+ Contributed by Steve Chamberlain
+ sac@cygnus.com
+
+
+ A listing page looks like:
+
+ LISTING_HEADER sourcefilename pagenumber
+ TITLE LINE
+ SUBTITLE LINE
+ linenumber address data source
+ linenumber address data source
+ linenumber address data source
+ linenumber address data source
+
+ If not overridden, the listing commands are:
+
+ .title "stuff"
+ Put "stuff" onto the title line
+ .sbttl "stuff"
+ Put stuff onto the subtitle line
+
If these commands come within 10 lines of the top of the page, they
will affect the page they are on, as well as any subsequent page
-
- .eject
- Thow a page
- .list
- Increment the enable listing counter
- .nolist
- Decrement the enable listing counter
-
- .psize Y[,X]
- Set the paper size to X wide and Y high. Setting a psize Y of
- zero will suppress form feeds except where demanded by .eject
-
- If the counter goes below zero, listing is suppressed.
-
-
- Listings are a maintained by read calling various listing_<foo>
- functions. What happens most is that the macro NO_LISTING is not
- defined (from the Makefile), then the macro LISTING_NEWLINE expands
- into a call to listing_newline. The call is done from read.c, every
- time it sees a newline, and -l is on the command line.
-
- The function listing_newline remembers the frag associated with the
- newline, and creates a new frag - note that this is wasteful, but not
- a big deal, since listing slows things down a lot anyway. The
- function also rememebers when the filename changes.
-
- When all the input has finished, and gas has had a chance to settle
- down, the listing is output. This is done by running down the list of
- frag/source file records, and opening the files as needed and printing
- out the bytes and chars associated with them.
-
- The only things which the architecture can change about the listing
- are defined in these macros:
-
- LISTING_HEADER The name of the architecture
- LISTING_WORD_SIZE The make of the number of bytes in a word, this determines
- the clumping of the output data. eg a value of
- 2 makes words look like 1234 5678, whilst 1
- would make the same value look like 12 34 56
- 78
- LISTING_LHS_WIDTH Number of words of above size for the lhs
-
- LISTING_LHS_WIDTH_SECOND Number of words for the data on the lhs
- for the second line
-
- LISTING_LHS_CONT_LINES Max number of lines to use up for a continutation
- LISTING_RHS_WIDTH Number of chars from the input file to print
- on a line
- */
+
+ .eject
+ Thow a page
+ .list
+ Increment the enable listing counter
+ .nolist
+ Decrement the enable listing counter
+
+ .psize Y[,X]
+ Set the paper size to X wide and Y high. Setting a psize Y of
+ zero will suppress form feeds except where demanded by .eject
+
+ If the counter goes below zero, listing is suppressed.
+
+
+ Listings are a maintained by read calling various listing_<foo>
+ functions. What happens most is that the macro NO_LISTING is not
+ defined (from the Makefile), then the macro LISTING_NEWLINE expands
+ into a call to listing_newline. The call is done from read.c, every
+ time it sees a newline, and -l is on the command line.
+
+ The function listing_newline remembers the frag associated with the
+ newline, and creates a new frag - note that this is wasteful, but not
+ a big deal, since listing slows things down a lot anyway. The
+ function also rememebers when the filename changes.
+
+ When all the input has finished, and gas has had a chance to settle
+ down, the listing is output. This is done by running down the list of
+ frag/source file records, and opening the files as needed and printing
+ out the bytes and chars associated with them.
+
+ The only things which the architecture can change about the listing
+ are defined in these macros:
+
+ LISTING_HEADER The name of the architecture
+ LISTING_WORD_SIZE The make of the number of bytes in a word, this determines
+ the clumping of the output data. eg a value of
+ 2 makes words look like 1234 5678, whilst 1
+ would make the same value look like 12 34 56
+ 78
+ LISTING_LHS_WIDTH Number of words of above size for the lhs
+
+ LISTING_LHS_WIDTH_SECOND Number of words for the data on the lhs
+ for the second line
+
+ LISTING_LHS_CONT_LINES Max number of lines to use up for a continutation
+ LISTING_RHS_WIDTH Number of chars from the input file to print
+ on a line
+*/
#include "as.h"
#include <obstack.h>
#include "targ-cpu.h"
#ifndef NO_LISTING
-
#ifndef LISTING_HEADER
#define LISTING_HEADER "GAS LISTING"
#endif
#endif
+
+
/* This structure remembers which .s were used */
-typedef struct file_info_struct {
- char *filename;
- int linenum;
- FILE *file;
- struct file_info_struct *next;
- int end_pending;
+typedef struct file_info_struct
+{
+ char *filename;
+ int linenum;
+ FILE *file;
+ struct file_info_struct *next;
+ int end_pending;
+
} file_info_type ;
+
+/* this structure rememebrs which line from which file goes into which
+ frag */
+typedef struct list_info_struct
+{
+ /* Frag which this line of source is nearest to */
+ fragS *frag;
+ /* The actual line in the source file */
+ unsigned int line;
+ /* Pointer to the file info struct for the file which this line
+ belongs to */
+ file_info_type *file;
+
+ /* Next in list */
+ struct list_info_struct *next;
-/* this structure rememebrs which line from which file goes into which frag */
-typedef struct list_info_struct {
- /* Frag which this line of source is nearest to */
- fragS *frag;
- /* The actual line in the source file */
- unsigned int line;
- /* Pointer to the file info struct for the file which this line
- belongs to */
- file_info_type *file;
-
- /* Next in list */
- struct list_info_struct *next;
-
-
- /* Pointer to the file info struct for the high level language
- source line that belongs here */
- file_info_type *hll_file;
-
- /* High level language source line */
- int hll_line;
-
-
- /* Pointer to any error message associated with this line */
- char *message;
-
- enum {
- EDICT_NONE,
- EDICT_SBTTL,
- EDICT_TITLE,
- EDICT_NOLIST,
- EDICT_LIST,
- EDICT_EJECT,
- } edict;
- char *edict_arg;
+
+ /* Pointer to the file info struct for the high level language
+ source line that belongs here */
+ file_info_type *hll_file;
+
+ /* High level language source line */
+ int hll_line;
+
+
+ /* Pointer to any error message associated with this line */
+ char *message;
+
+ enum
+ {
+ EDICT_NONE,
+ EDICT_SBTTL,
+ EDICT_TITLE,
+ EDICT_NOLIST,
+ EDICT_LIST,
+ EDICT_EJECT
+ } edict;
+ char *edict_arg;
+
} list_info_type;
+
static struct list_info_struct *head;
struct list_info_struct *listing_tail;
extern int listing;
extern unsigned int physical_input_line;
extern fragS *frag_now;
+
static int paper_width = 200;
static int paper_height = 60;
+
/* this static array is used to keep the text of data to be printed
- before the start of the line. It is stored so we can give a bit
- more info on the next line. To much, and large initialized arrays
- will use up lots of paper. */
+ before the start of the line.
+ It is stored so we can give a bit more info on the next line. To much, and large
+ initialized arrays will use up lots of paper.
+ */
static char data_buffer[100];
static unsigned int data_buffer_size;
+
static void
- listing_message(name, message)
-char *name;
-char *message;
-{
- unsigned int l = strlen(name) + strlen(message) + 1;
- char *n = malloc(l);
- strcpy(n,name);
- strcat(n,message);
- if (listing_tail != (list_info_type *)NULL) {
- listing_tail->message = n;
- }
+DEFUN(listing_message,(name, message),
+ char *name AND
+ char *message)
+{
+ unsigned int l = strlen(name) + strlen(message)+1;
+ char *n = malloc(l);
+ strcpy(n,name);
+ strcat(n,message);
+ if(listing_tail != (list_info_type *)NULL)
+ {
+ listing_tail->message = n;
+ }
+
+}
+
+
- return;
-} /* lising_message() */
void
- listing_warning(message)
-char *message;
+DEFUN(listing_warning,(message),
+ char *message)
{
- listing_message("Warning:", message);
+ listing_message("Warning:", message);
}
-void
- listing_error(message)
-char *message;
+void
+DEFUN(listing_error,(message),
+ char *message)
{
- listing_message("Error:", message);
+ listing_message("Error:", message);
}
+
+
+
static file_info_type *file_info_head;
static file_info_type *
- file_info(file_name)
-char *file_name;
+DEFUN(file_info, (file_name),
+ char *file_name)
{
- /* Find an entry with this file name */
- file_info_type *p = file_info_head;
-
- while (p != (file_info_type *)NULL) {
- if (strcmp(p->filename, file_name) == 0)
- return(p);
- p = p->next;
- }
-
- /* Make new entry */
-
- p = (file_info_type *) xmalloc(sizeof(file_info_type));
- p->next = file_info_head;
- file_info_head = p;
- p->filename = xmalloc(strlen(file_name)+1);
- strcpy(p->filename, file_name);
- p->linenum = 0;
- p->end_pending = 0;
-
- p->file = fopen(p->filename,"r");
- return(p);
-} /* file_info() */
+ /* Find an entry with this file name */
+ file_info_type *p = file_info_head;
+
+ while (p != (file_info_type *)NULL)
+ {
+ if (strcmp(p->filename, file_name) == 0)
+ return p;
+ p = p->next;
+ }
+
+ /* Make new entry */
+
+ p = (file_info_type *)xmalloc(sizeof(file_info_type));
+ p->next = file_info_head;
+ file_info_head = p;
+ p->filename = xmalloc(strlen(file_name)+1);
+ strcpy(p->filename, file_name);
+ p->linenum = 0;
+ p->end_pending = 0;
+
+ p->file = fopen(p->filename,"r");
+ return p;
+
+}
static void
- new_frag()
+DEFUN_VOID(new_frag)
{
- frag_wane(frag_now);
- frag_new(0);
+
+ frag_wane(frag_now);
+ frag_new(0);
+
}
void
- listing_newline(ps)
-char *ps;
+DEFUN(listing_newline,(ps),
+ char *ps)
{
- char *s = ps;
- extern char *file_name;
- static unsigned int last_line = 0xffff ;
-
-
- list_info_type *new;
- if (physical_input_line != last_line) {
- last_line = physical_input_line;
- new_frag();
-
- new = (list_info_type *) malloc(sizeof(list_info_type));
- new->frag = frag_now;
- new->line = physical_input_line ;
- new->file = file_info(file_name);
-
- if (listing_tail) {
- listing_tail->next = new;
- } else {
- head = new;
- }
-
- listing_tail = new;
- new->next = (list_info_type *) NULL;
- new->message = (char *) NULL;
- new->edict = EDICT_NONE;
- new->hll_file = (file_info_type*) NULL;
- new->hll_line = 0;
- new_frag();
- }
+ char *s = ps;
+ extern char *file_name;
+ static unsigned int last_line =0xffff ;
- return;
-} /* listing_newline() */
+
+ list_info_type *new;
+ if (physical_input_line != last_line)
+ {
+ last_line = physical_input_line;
+ new_frag();
+
+ new = (list_info_type *)malloc(sizeof(list_info_type));
+ new->frag = frag_now;
+ new->line = physical_input_line ;
+ new->file = file_info(file_name);
+
+ if (listing_tail)
+ {
+ listing_tail->next = new;
+ }
+ else
+ {
+ head = new;
+ }
+ listing_tail = new;
+ new->next = (list_info_type *)NULL;
+ new->message = (char *)NULL;
+ new->edict = EDICT_NONE;
+ new->hll_file = (file_info_type*)NULL;
+ new->hll_line = 0;
+ new_frag();
+ }
+}
-/* This function returns the next source line from the file supplied,
- truncated to size. It appends a fake line to the end of each input
- file to make. */
+/*
+ This function returns the next source line from the file supplied,
+ truncated to size. It appends a fake line to the end of each input
+ file to make
+*/
static char *
- buffer_line(file, line, size)
-file_info_type *file;
-char *line;
-unsigned int size;
+DEFUN(buffer_line,(file, line, size),
+ file_info_type *file AND
+ char *line AND
+ unsigned int size)
{
- unsigned int count = 0;
- int c;
-
- char *p = line;
-
- /* If we couldn't open the file, return an empty line */
- if (file->file == (FILE*) NULL) {
- return("");
- }
-
- if (file->end_pending == 10) {
- *p ++ = '\n';
- rewind(file->file);
- file->linenum = 0;
- file->end_pending = 0;
- }
-
- c = fgetc(file->file);
- size -= 1; /* leave room for null */
-
- while (c != EOF && c != '\n') {
- if (count < size)
- *p++ = c;
- count++;
-
- c = fgetc(file->file);
- }
-
- if (c == EOF) {
- file->end_pending ++;
- *p++ = 'E';
- *p++ = 'O';
- *p++ = 'F';
- }
-
- file->linenum++;
- *p++ = 0;
- return(line);
-} /* buffer_line() */
+ unsigned int count = 0;
+ int c;
+
+ char *p = line;
+
+ /* If we couldn't open the file, return an empty line */
+ if (file->file == (FILE*)NULL)
+ {
+ return "";
+ }
+
+ if (file->end_pending == 10) {
+ *p ++ = '\n';
+ rewind(file->file);
+ file->linenum = 0;
+ file->end_pending = 0;
+ }
+ c = fgetc(file->file);
+ size -= 1; /* leave room for null */
+
+ while (c != EOF && c != '\n')
+ {
+ if (count < size)
+ *p++ = c;
+ count++;
+
+ c= fgetc(file->file);
+ }
+ if (c == EOF)
+ {
+ file->end_pending ++;
+ *p++ = 'E';
+ *p++ = 'O';
+ *p++ = 'F';
+ }
+ file->linenum++;
+ *p++ = 0;
+ return line;
+}
+
static char *fn;
static char *subtitle; /* current subtitle */
static unsigned int on_page; /* number of lines printed on current page */
-static void
- listing_page(list)
-list_info_type *list;
-{
- /* Grope around, see if we can see a title or subtitle edict
- coming up soon (we look down 10 lines of the page and see
- if it's there). */
-
- if ((eject || (on_page >= paper_height)) && paper_height != 0) {
- unsigned int c = 10;
- int had_title = 0;
- int had_subtitle = 0;
-
- page++;
-
- while (c != 0 && list) {
- if (list->edict == EDICT_SBTTL && !had_subtitle) {
- had_subtitle = 1;
- subtitle = list->edict_arg;
- }
-
- if (list->edict == EDICT_TITLE && !had_title) {
- had_title = 1;
- title = list->edict_arg;
- }
- list = list->next;
- --c;
- }
-
- if (page > 1) {
- printf("\f");
- }
-
- printf("%s %s \t\t\tpage %d\n", LISTING_HEADER, fn, page);
- printf("%s\n", title);
- printf("%s\n", subtitle);
- on_page = 3;
- eject = 0;
- }
- return;
-} /* listing_page() */
+static void
+DEFUN(listing_page,(list),
+ list_info_type *list)
+{
+ /* Grope around, see if we can see a title or subtitle edict coming up
+ soon (we look down 10 lines of the page and see if it's there)*/
+ if ((eject || (on_page >= paper_height)) && paper_height != 0)
+ {
+ unsigned int c = 10;
+ int had_title = 0;
+ int had_subtitle = 0;
+
+ page++;
+
+ while (c != 0 && list)
+ {
+ if (list->edict == EDICT_SBTTL && !had_subtitle)
+ {
+ had_subtitle = 1;
+ subtitle = list->edict_arg;
+ }
+ if (list->edict == EDICT_TITLE && !had_title)
+ {
+ had_title = 1;
+ title = list->edict_arg;
+ }
+ list = list->next;
+ c--;
+ }
+
+
+ if (page > 1)
+ {
+ printf("\f");
+ }
+
+ printf("%s %s \t\t\tpage %d\n", LISTING_HEADER, fn, page);
+ printf("%s\n", title);
+ printf("%s\n", subtitle);
+ on_page = 3;
+ eject = 0;
+ }
+}
static unsigned int
- calc_hex(list)
-list_info_type *list;
+DEFUN(calc_hex,(list),
+ list_info_type *list)
{
- list_info_type *first = list;
- list_info_type *last = first;
- unsigned int address = ~0;
-
- fragS *frag;
- fragS *frag_ptr;
-
- unsigned int byte_in_frag = 0;
-
- int anything = 0;
-
- /* Find first frag which says it belongs to this line */
- frag = list->frag;
- while (frag && frag->line != list)
- frag = frag->fr_next;
-
- frag_ptr = frag;
-
- data_buffer_size = 0;
-
- /* Dump all the frags which belong to this line */
- while (frag_ptr != (fragS *)NULL && frag_ptr->line == first) {
- /* Print as many bytes from the fixed part as is sensible */
- while(byte_in_frag < frag_ptr->fr_fix && data_buffer_size < sizeof(data_buffer)-10) {
- if (address == ~0) {
- address = frag_ptr->fr_address;
- }
-
- sprintf(data_buffer + data_buffer_size, "%02X", (frag_ptr->fr_literal[byte_in_frag]) & 0xff);
- data_buffer_size += 2;
- byte_in_frag++;
- }
-
- /* Print as many bytes from the variable part as is sensible */
- while (byte_in_frag < frag_ptr->fr_var * frag_ptr->fr_offset
- && data_buffer_size < sizeof(data_buffer)-10) {
- if (address == ~0) {
- address = frag_ptr->fr_address;
- }
- data_buffer[data_buffer_size++] = '*';
- data_buffer[data_buffer_size++] = '*';
-
- byte_in_frag++;
- }
-
- frag_ptr = frag_ptr->fr_next;
- }
-
- data_buffer[data_buffer_size++] = 0;
- return address;
-} /* calc_hex() */
+ list_info_type *first = list;
+ list_info_type *last = first;
+ unsigned int address = ~0;
+
+ fragS *frag;
+ fragS *frag_ptr;
+
+ unsigned int byte_in_frag = 0;
+
+ int anything = 0;
+
+ /* Find first frag which says it belongs to this line */
+ frag = list->frag;
+ while (frag && frag->line != list)
+ frag = frag->fr_next;
+
+ frag_ptr = frag;
+
+ data_buffer_size = 0;
+
+ /* Dump all the frags which belong to this line */
+ while (frag_ptr != (fragS *)NULL && frag_ptr->line == first)
+ {
+ /* Print as many bytes from the fixed part as is sensible */
+ while(byte_in_frag < frag_ptr->fr_fix && data_buffer_size < sizeof(data_buffer)-10)
+ {
+ if (address == ~0)
+ {
+ address = frag_ptr->fr_address;
+ }
+
+ sprintf(data_buffer + data_buffer_size,
+ "%02X",
+ (frag_ptr->fr_literal[byte_in_frag]) & 0xff);
+ data_buffer_size += 2;
+ byte_in_frag++;
+ }
+ {
+ unsigned int var_rep_max = byte_in_frag;
+ unsigned int var_rep_idx = byte_in_frag;
+
+ /* Print as many bytes from the variable part as is sensible */
+ while (byte_in_frag < frag_ptr->fr_var * frag_ptr->fr_offset
+ && data_buffer_size < sizeof(data_buffer)-10)
+ {
+ if (address == ~0)
+ {
+ address = frag_ptr->fr_address;
+ }
+sprintf(data_buffer + data_buffer_size,
+ "%02X",
+ (frag_ptr->fr_literal[var_rep_idx]) & 0xff);
+#if 0
+ data_buffer[data_buffer_size++] = '*';
+ data_buffer[data_buffer_size++] = '*';
+#endif
+ data_buffer_size +=2;
+
+ var_rep_idx ++;
+ byte_in_frag++;
+
+ if (var_rep_idx >= frag_ptr->fr_var)
+ var_rep_idx = var_rep_max;
+ }
+ }
+
+ frag_ptr = frag_ptr->fr_next;
+ }
+ data_buffer[data_buffer_size++] = 0;
+ return address;
+}
+
+
+
+
+
static void
- print_lines(list, string, address)
-list_info_type *list;
-char *string;
-unsigned int address;
-{
- unsigned int idx;
- unsigned int nchars;
- unsigned int lines;
- unsigned int byte_in_word =0;
- char *src = data_buffer;
+DEFUN(print_lines,(list, string, address),
+list_info_type *list AND
+char *string AND
+unsigned int address)
+{
+ unsigned int idx;
+ unsigned int nchars;
+ unsigned int lines;
+ unsigned int byte_in_word =0;
+ char *src = data_buffer;
+
+ /* Print the stuff on the first line */
+ listing_page(list);
+ nchars = (LISTING_WORD_SIZE*2 +1) * LISTING_LHS_WIDTH ;
+ /* Print the hex for the first line */
+ if (address == ~0)
+ {
+ printf("% 4d ", list->line);
+ for (idx = 0; idx < nchars; idx++)
+ printf(" ");
+
+ printf("\t%s\n", string ? string : "");
+ on_page++;
+ listing_page(0);
+
+ }
+ else
+ {
+ if (had_errors())
+ {
+ printf("% 4d ???? ", list->line);
+ }
+ else
+ {
+ printf("% 4d %04x ", list->line, address);
+ }
+
+ /* And the data to go along with it */
+ idx = 0;
+
+ while (*src && idx < nchars)
+ {
+ printf("%c%c", src[0], src[1]);
+ src += 2;
+ byte_in_word++;
+ if (byte_in_word == LISTING_WORD_SIZE)
+ {
+ printf(" ");
+ idx++;
+ byte_in_word = 0;
+ }
+ idx+=2;
+ }
+
+ for (;idx < nchars; idx++)
+ printf(" ");
+
+ printf("\t%s\n", string ? string : "");
+ on_page++;
+ listing_page(list);
+ if (list->message)
+ {
+ printf("**** %s\n",list->message);
+ listing_page(list);
+ on_page++;
+ }
+
+ for (lines = 0;
+ lines < LISTING_LHS_CONT_LINES
+ && *src;
+ lines++) {
+ nchars = ((LISTING_WORD_SIZE*2) +1) * LISTING_LHS_WIDTH_SECOND -1;
+ idx = 0;
+ /* Print any more lines of data, but more compactly */
+ printf("% 4d ", list->line);
+
+ while (*src && idx < nchars)
+ {
+ printf("%c%c", src[0], src[1]);
+ src+=2;
+ idx+=2;
+ byte_in_word++;
+ if (byte_in_word == LISTING_WORD_SIZE)
+ {
+ printf(" ");
+ idx++;
+ byte_in_word = 0;
+ }
+ }
- /* Print the stuff on the first line */
+ printf("\n");
+ on_page++;
listing_page(list);
- nchars = (LISTING_WORD_SIZE * 2 + 1) * LISTING_LHS_WIDTH ;
- /* Print the hex for the first line */
- if (address == ~0) {
- printf("% 4d ", list->line);
- for (idx = 0; idx < nchars; idx++)
- printf(" ");
-
- printf("\t%s\n", string ? string : "");
- on_page++;
- listing_page(0);
- } else {
- if (had_errors()) {
- printf("% 4d ???? ", list->line);
- } else {
- printf("% 4d %04x ", list->line, address);
- }
-
- /* And the data to go along with it */
- idx = 0;
-
- while (*src && idx < nchars) {
- printf("%c%c", src[0], src[1]);
- src += 2;
- byte_in_word++;
-
- if (byte_in_word == LISTING_WORD_SIZE) {
- printf(" ");
- idx++;
- byte_in_word = 0;
- }
- idx+=2;
- }
-
- for (;idx < nchars; idx++)
- printf(" ");
-
- printf("\t%s\n", string ? string : "");
- on_page++;
- listing_page(list);
- if (list->message) {
- printf("**** %s\n",list->message);
- listing_page(list);
- on_page++;
- }
-
- for (lines = 0; lines < LISTING_LHS_CONT_LINES && *src; lines++) {
- nchars = ((LISTING_WORD_SIZE*2) +1) * LISTING_LHS_WIDTH_SECOND -1;
- idx = 0;
- /* Print any more lines of data, but more compactly */
- printf("% 4d ", list->line);
-
- while (*src && idx < nchars) {
- printf("%c%c", src[0], src[1]);
- src+=2;
- idx+=2;
- byte_in_word++;
- if (byte_in_word == LISTING_WORD_SIZE) {
- printf(" ");
- idx++;
- byte_in_word = 0;
- }
- }
-
- printf("\n");
- on_page++;
- listing_page(list);
- }
- }
-} /* print_lines() */
+ }
+
+
+ }
+}
+
+
+
+
static void
- list_symbol_table()
+DEFUN_VOID(list_symbol_table)
{
- extern symbolS *symbol_rootP;
- symbolS *ptr;
-
- eject = 1;
- listing_page(0);
- printf("DEFINED SYMBOLS\n");
- on_page++;
-
- for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr)) {
- if (ptr->sy_frag->line) {
- if (strlen(S_GET_NAME(ptr))) {
- printf("%20s:%-5d %2d:%08x %s \n",
- ptr->sy_frag->line->file->filename,
- ptr->sy_frag->line->line,
- S_GET_SEGMENT(ptr),
- S_GET_VALUE(ptr),
- S_GET_NAME(ptr));
-
- on_page++;
- listing_page(0);
- }
- }
-
- }
-
- printf("\n");
+ extern symbolS *symbol_rootP;
+
+ symbolS *ptr ;
+ eject = 1;
+ listing_page(0);
+ printf("DEFINED SYMBOLS\n");
+ on_page++;
+
+ for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr))
+ {
+ if (ptr->sy_frag->line)
+ {
+ if (strlen(S_GET_NAME(ptr)))
+ {
+ printf("%20s:%-5d %2d:%08x %s \n",
+ ptr->sy_frag->line->file->filename,
+ ptr->sy_frag->line->line,
+ S_GET_SEGMENT(ptr),
+ S_GET_VALUE(ptr),
+ S_GET_NAME(ptr));
+
on_page++;
listing_page(0);
- printf("UNDEFINED SYMBOLS\n");
+ }
+ }
+
+ }
+ printf("\n");
+ on_page++;
+ listing_page(0);
+ printf("UNDEFINED SYMBOLS\n");
+ on_page++;
+ listing_page(0);
+
+ for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr))
+ {
+ if (ptr && strlen(S_GET_NAME(ptr)) != 0)
+ {
+ if (ptr->sy_frag->line == 0)
+ {
+ printf("%s\n", S_GET_NAME(ptr));
on_page++;
listing_page(0);
-
- for (ptr = symbol_rootP; ptr != (symbolS*)NULL; ptr = symbol_next(ptr)) {
- if (ptr && strlen(S_GET_NAME(ptr)) != 0) {
- if (ptr->sy_frag->line == 0) {
- printf("%s\n", S_GET_NAME(ptr));
- on_page++;
- listing_page(0);
- }
- }
- }
-
- return;
-} /* list_symbol_table() */
+ }
+ }
+ }
+}
void
- print_source(current_file, list, buffer, width)
-file_info_type *current_file;
-list_info_type *list;
-char *buffer;
-unsigned int width;
-{
- if (current_file->file) {
- while (current_file->linenum < list->hll_line) {
- char * p = buffer_line(current_file, buffer, width);
- printf("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p);
- on_page++;
- listing_page(list);
- }
- }
-
- return;
-} /* print_source() */
+DEFUN(print_source,(current_file, list, buffer, width),
+ file_info_type *current_file AND
+ list_info_type *list AND
+ char *buffer AND
+ unsigned int width)
+{
+ if (current_file->file) {
+ while (current_file->linenum < list->hll_line)
+ {
+ char * p = buffer_line(current_file, buffer, width);
+ printf("%4d:%-13s **** %s\n", current_file->linenum, current_file->filename, p);
+ on_page++;
+ listing_page(list);
+ }
+ }
+}
/* Sometimes the user doesn't want to be bothered by the debugging
records inserted by the compiler, see if the line is suspicioous */
static int
- debugging_pseudo(line)
-char *line;
+DEFUN(debugging_pseudo,(line),
+ char *line)
{
- while (isspace(*line))
- line++;
-
- if (*line != '.') return 0;
-
- line++;
-
- if (strncmp(line, "def",3) == 0) return 1;
- if (strncmp(line, "val",3) == 0) return 1;
- if (strncmp(line, "scl",3) == 0) return 1;
- if (strncmp(line, "line",4) == 0) return 1;
- if (strncmp(line, "endef",5) == 0) return 1;
- if (strncmp(line, "ln",2) ==0) return 1;
- if (strncmp(line, "type",4) ==0) return 1;
- if (strncmp(line, "size",4) == 0) return 1;
- if (strncmp(line, "dim",3) ==0) return 1;
- if (strncmp(line, "tag",3) == 0) return 1;
-
- return(0);
-} /* debugging_pseudo() */
+ while (isspace(*line))
+ line++;
+
+ if(*line != '.') return 0;
+
+ line++;
+
+ if (strncmp(line, "def",3) == 0) return 1;
+ if (strncmp(line, "val",3) == 0) return 1;
+ if (strncmp(line, "scl",3) == 0) return 1;
+ if (strncmp(line, "line",4) == 0) return 1;
+ if (strncmp(line, "endef",5) == 0) return 1;
+ if (strncmp(line, "ln",2) ==0) return 1;
+ if (strncmp(line, "type",4) ==0) return 1;
+ if (strncmp(line, "size",4) == 0) return 1;
+ if (strncmp(line, "dim",3) ==0) return 1;
+ if (strncmp(line, "tag",3) == 0) return 1;
+
+ return 0;
+
+}
void
- listing_listing(name)
-char *name;
-{
- char *buffer;
- char *message;
- char *p;
- file_info_type *current_hll_file = (file_info_type *) NULL;
- int on_page = 0;
- int show_listing = 1;
- list_info_type *list = head;
- unsigned int addr = 0;
- unsigned int page = 1;
- unsigned int prev = 0;
- unsigned int width;
-
- buffer = malloc(LISTING_RHS_WIDTH);
+DEFUN(listing_listing,(name),
+ char *name)
+{
+ list_info_type *list = head;
+ file_info_type *current_hll_file = (file_info_type *)NULL;
+
+ unsigned int page= 1;
+ unsigned int prev = 0;
+ char *message;
+ char *buffer;
+ char *p;
+ unsigned int addr = 0;
+ int on_page = 0;
+ int show_listing = 1;
+ unsigned int width;
+
+ buffer = malloc(LISTING_RHS_WIDTH);
+ eject = 1;
+ list = head;
+
+ while (list != (list_info_type *)NULL && 0)
+ {
+ if (list->next)
+ list->frag = list->next->frag;
+ list = list->next;
+
+ }
+
+ list = head->next;
+
+
+ while ( list)
+ {
+ width = LISTING_RHS_WIDTH > paper_width ? paper_width :
+ LISTING_RHS_WIDTH;
+
+ switch (list->edict) {
+ case EDICT_LIST:
+ show_listing++;
+ break;
+ case EDICT_NOLIST:
+ show_listing--;
+ break;
+ case EDICT_EJECT:
+ break;
+ case EDICT_NONE:
+ break;
+ case EDICT_TITLE:
+ title = list->edict_arg;
+ break;
+ case EDICT_SBTTL:
+ subtitle = list->edict_arg;
+ break;
+ default:
+ abort();
+ }
+
+ if (show_listing > 0)
+ {
+ /* Scan down the list and print all the stuff which can be done
+ with this line (or lines) */
+ message = 0;
+
+ if (list->hll_file)
+ {
+ current_hll_file = list->hll_file;
+ }
+
+ if (current_hll_file && list->hll_line && listing & LISTING_HLL)
+ {
+ print_source(current_hll_file, list, buffer, width);
+ }
+
+ p = buffer_line(list->file, buffer, width);
+
+ if (! ((listing & LISTING_NODEBUG) && debugging_pseudo(p)))
+ {
+ print_lines(list, p, calc_hex(list));
+ }
+
+ if (list->edict == EDICT_EJECT)
+ {
eject = 1;
- list = head;
-
- while (list != (list_info_type *)NULL && 0) {
- if (list->next)
- list->frag = list->next->frag;
- list = list->next;
- }
-
- list = head->next;
-
- while (list) {
- width = LISTING_RHS_WIDTH > paper_width ? paper_width : LISTING_RHS_WIDTH;
-
- switch (list->edict) {
- case EDICT_LIST:
- show_listing++;
- break;
- case EDICT_NOLIST:
- show_listing--;
- break;
- case EDICT_EJECT:
- break;
- case EDICT_NONE:
- break;
- case EDICT_TITLE:
- title = list->edict_arg;
- break;
- case EDICT_SBTTL:
- subtitle = list->edict_arg;
- break;
- default:
- abort();
- }
-
- if (show_listing > 0) {
- /* Scan down the list and print all the stuff which can be done
- with this line (or lines) */
- message = 0;
-
- if (list->hll_file) {
- current_hll_file = list->hll_file;
- }
-
- if (current_hll_file && list->hll_line && listing & LISTING_HLL) {
- print_source(current_hll_file, list, buffer, width);
- }
-
- p = buffer_line(list->file, buffer, width);
-
- if (! ((listing & LISTING_NODEBUG) && debugging_pseudo(p))) {
- print_lines(list, p, calc_hex(list));
- }
-
- if (list->edict == EDICT_EJECT) {
- eject = 1;
- }
- } else {
-
- p = buffer_line(list->file, buffer, width);
- }
-
- list = list->next;
- }
- free(buffer);
-} /* listing_listing() */
+ }
+ }
+ else
+ {
+
+ p = buffer_line(list->file, buffer, width);
+ }
+
+ list = list->next;
+ }
+ free(buffer);
+}
void
- listing_print(name)
-char *name;
+DEFUN(listing_print,(name),
+ char *name)
{
- title = "";
- subtitle = "";
-
- if (listing & LISTING_NOFORM)
- {
- paper_height = 0;
- }
-
- if (listing & LISTING_LISTING)
- {
- listing_listing(name);
-
- }
- if (listing & LISTING_SYMBOLS)
- {
- list_symbol_table();
- }
-} /* listing_print() */
+ title = "";
+ subtitle = "";
+
+ if (listing & LISTING_NOFORM)
+ {
+ paper_height = 0;
+ }
+
+ if (listing & LISTING_LISTING)
+ {
+ listing_listing(name);
+
+ }
+ if (listing & LISTING_SYMBOLS)
+ {
+ list_symbol_table();
+ }
+}
void
- listing_file(name)
-char *name;
+DEFUN(listing_file,(name),
+char *name)
{
- fn = name;
+ fn = name;
}
void
- listing_eject()
+DEFUN_VOID(listing_eject)
{
- listing_tail->edict = EDICT_EJECT;
- return;
+ listing_tail->edict = EDICT_EJECT;
}
void
- listing_flags()
+DEFUN_VOID(listing_flags)
{
-
+
+}
+void
+DEFUN(listing_list,(on),
+ unsigned int on)
+{
+ listing_tail->edict = on ? EDICT_LIST : EDICT_NOLIST;
}
+
void
- listing_list(on)
-unsigned int on;
+DEFUN_VOID(listing_psize)
{
- listing_tail->edict = on ? EDICT_LIST : EDICT_NOLIST;
+ paper_height = get_absolute_expression();
+
+ if (paper_height < 0 || paper_height > 1000)
+ {
+ paper_height = 0;
+ as_warn("strantge paper height, set to no form");
+ }
+ if (*input_line_pointer == ',')
+ {
+ input_line_pointer++;
+ paper_width = get_absolute_expression();
+ }
}
void
- listing_psize()
+DEFUN(listing_title,(depth),
+ unsigned int depth)
{
- paper_height = get_absolute_expression();
-
- if (paper_height < 0 || paper_height > 1000) {
- paper_height = 0;
- as_warn("strantge paper height, set to no form");
+ char *start;
+ char *title;
+ unsigned int length;
+
+ SKIP_WHITESPACE();
+ if (*input_line_pointer=='\"') {
+ input_line_pointer++;
+ start = input_line_pointer;
+
+ while (*input_line_pointer)
+ {
+ if (*input_line_pointer == '\"')
+ {
+ length = input_line_pointer - start;
+ title = malloc(length + 1);
+ memcpy(title, start, length);
+ title[length] = 0;
+ listing_tail->edict = depth ? EDICT_SBTTL : EDICT_TITLE;
+ listing_tail->edict_arg = title;
+ input_line_pointer++;
+ demand_empty_rest_of_line();
+ return;
}
-
- if (*input_line_pointer == ',') {
- input_line_pointer++;
- paper_width = get_absolute_expression();
+ else if (*input_line_pointer == '\n')
+ {
+ as_bad("New line in title");
+ demand_empty_rest_of_line();
+ return;
}
-
- return;
-} /* listing_psize() */
+ else
+ {
+ input_line_pointer++;
+ }
+ }
+ }
+ else
+ {
+ as_bad("expecting title in quotes");
+ }
+}
+
void
- listing_title(depth)
-unsigned int depth;
+DEFUN(listing_source_line,(line),
+ unsigned int line)
{
- char *start;
- char *title;
- unsigned int length;
-
- SKIP_WHITESPACE();
-
- if (*input_line_pointer=='\"') {
- input_line_pointer++;
- start = input_line_pointer;
-
- while (*input_line_pointer) {
- if (*input_line_pointer == '\"') {
- length = input_line_pointer - start;
- title = malloc(length + 1);
- memcpy(title, start, length);
- title[length] = 0;
- listing_tail->edict = depth ? EDICT_SBTTL : EDICT_TITLE;
- listing_tail->edict_arg = title;
- input_line_pointer++;
- demand_empty_rest_of_line();
- return;
- } else if (*input_line_pointer == '\n') {
- as_bad("New line in title");
- demand_empty_rest_of_line();
- return;
- } else {
- input_line_pointer++;
- }
- }
- } else {
- as_bad("expecting title in quotes");
- }
-
- return;
-} /* listing_title() */
+ new_frag();
+ listing_tail->hll_line = line;
+ new_frag();
+
+}
+void
+DEFUN(listing_source_file,(file),
+ char *file)
+{
+ listing_tail->hll_file = file_info(file);
+}
-void
- listing_source_line(line)
-unsigned int line;
+
+#else
+
+
+/* Dummy functions for when compiled without listing enabled */
+
+void
+DEFUN_VOID(listing_flags)
+{
+ s_ignore();
+}
+
+void DEFUN_VOID(listing_list)
{
- new_frag();
- listing_tail->hll_line = line;
- new_frag();
- return;
-} /* lising_source_line() */
+ s_ignore();
+}
+
+void DEFUN_VOID(listing_eject)
+{
+ s_ignore();
+}
+void DEFUN(listing_psize)
+{
+ s_ignore();
+}
+void DEFUN(listing_title, (depth),
+unsigned int depth)
+{
+ s_ignore();
+}
void
- listing_source_file(file)
-char *file;
+DEFUN(listing_file,(name),
+char *name)
{
- listing_tail->hll_file = file_info(file);
+
+}
+
+void DEFUN(listing_newline,(name),
+char *name)
+{
+
}
-#endif /* not NO_LISTING */
+void DEFUN(listing_source_line,(n),
+unsigned int n)
+{
+
+}
+void DEFUN(listing_source_file, (n),
+char *n)
+{
+
+}
+
+
+
+#endif
-/* end of listing.c */