+Mon Sep 13 16:48:38 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * read.c (s_desc): Only compile and use if S_SET_DESC is defined.
+ * struc-symbol.h: Declare verify_symbol_chain and
+ verify_symbol_chain_2 even if not SYMBOLS_NEED_BACKPOINTERS.
+ * symbols.c (verify_symbol_chain): Removed useless expression.
+ * write.c (headers, the_object_file): Only use if not
+ BFD_ASSEMBLER and not BFD.
+ (fixup_segment, cvs_frag_to_fill): Only use if BFD_ASSEMBLER or
+ not BFD.
+ (merge_data_into_text): Only use if BFD_ASSEMBLER or (not BFD and
+ not OBJ_AOUT).
+ * write.h: Declare relax_segment.
+ * config/obj-coffbfd.c (stack_pop, stack_push, stack_init): Made
+ static.
+ (stack_top): Commented out, since it's not used.
+ Fixed up pseudo-op functions to take an ignored int argument.
+ (size_section): Added default BAD_CASE to switch.
+ Changed bzero calls to memset.
+ * config/obj-coffbfd.h (S_IS_LOCAL): Call strchr on S_GET_NAME
+ (s), not on s itself.
+ * config/tc-a29k.c (s_use): Take ignored int argument. Only
+ define if OBJ_COFF is not defined.
+ * config/tc-i386.c: (fits_in_signed_byte, smallest_imm_type): Make
+ argument signed again.
+ * config/tc-m68k.c (s_bss, s_even, s_proc): Take ignored int
+ argument.
+ (m68k_ip): Fully bracket initialization of archs.
+ Correct several formats for __LINE__ to be %d rather than %s.
+ (init_table): Fully bracket initialization.
+ Cast values larger than 0x7f assigned to fr_opcode to char.
+
+ * subsegs.c: Renamed non-BFD_ASSEMBLER subseg_new to subseg_set.
+ Wrote non-BFD_ASSEMBLER subseg_new. Now subseg_new always takes a
+ section name, and subseg_set always takes a segT. Changed all
+ callers as appropriate.
+ * config/obj-coffbfd.c (change_to_section): Renamed to
+ obj_coff_add_segment. Corrected. Made callers use subseg_new.
+ * config/obj-coffbfd.h (obj_segment_name, obj_add_segment):
+ Define.
+
Mon Sep 13 13:15:03 1993 Doug Evans (dje@canuck.cygnus.com)
* config/tc-sparc.h (LOCAL_LABEL): Remove test for name[0] == 'L'.
/* assembler mnemonic, lower case, no '.' */
char *poc_name;
/* Do the work */
- void (*poc_handler) ();
+ void (*poc_handler) PARAMS ((int));
/* Value to pass to handler */
int poc_val;
};
int had_errors PARAMS ((void));
int had_warnings PARAMS ((void));
+void print_version_id PARAMS ((void));
char *app_push PARAMS ((void));
char *atof_ieee PARAMS ((char *str, int what_kind, LITTLENUM_TYPE * words));
char *input_scrub_include_file PARAMS ((char *filename, char *position));
#if 0 /* incompatible with solaris 2 native cc */
char *strstr PARAMS ((const char *s, const char *wanted));
#endif
-char *xmalloc PARAMS ((long size));
-char *xrealloc PARAMS ((char *ptr, long n));
-int do_scrub_next_char PARAMS ((int (*get) (), void (*unget) ()));
+char *xmalloc PARAMS ((unsigned long size));
+char *xrealloc PARAMS ((char *ptr, unsigned long n));
+int do_scrub_next_char PARAMS ((int (*get) (void), void (*unget) (int)));
int gen_to_words PARAMS ((LITTLENUM_TYPE * words, int precision,
long exponent_bits));
int had_err PARAMS ((void));
-int had_errors PARAMS ((void));
-int had_warnings PARAMS ((void));
int ignore_input PARAMS ((void));
int scrub_from_file PARAMS ((void));
-int scrub_from_file PARAMS ((void));
int scrub_from_string PARAMS ((void));
int seen_at_least_1_file PARAMS ((void));
void app_pop PARAMS ((char *arg));
void scrub_to_string PARAMS ((int ch));
void subsegs_begin PARAMS ((void));
void subseg_change PARAMS ((segT seg, int subseg));
-#ifdef BFD_ASSEMBLER
segT subseg_new PARAMS ((const char *name, subsegT subseg));
void subseg_set PARAMS ((segT seg, subsegT subseg));
-#else
-void subseg_new PARAMS ((segT seg, subsegT subseg));
-#endif
/* this one starts the chain of target dependant headers */
#include "targ-env.h"
#include "as.h"
#include "aout/stab_gnu.h"
+#ifdef BFD_ASSEMBLER
#include "aout/aout64.h"
+#endif
#include "obstack.h"
#ifndef BFD_ASSEMBLER
#endif
static void obj_aout_stab PARAMS ((int what));
-static void obj_aout_line PARAMS ((void));
-static void obj_aout_desc PARAMS ((void));
+static void obj_aout_line PARAMS ((int));
+static void obj_aout_desc PARAMS ((int));
const pseudo_typeS obj_pseudo_table[] =
{
#endif /* ! BFD_ASSEMBLER */
static void
-obj_aout_line ()
+obj_aout_line (ignore)
+ int ignore;
{
/* Assume delimiter is part of expression.
BSD4.2 as fails with delightful bug, so we
{
case 'd':
S_SET_NAME (symbolP, NULL); /* .stabd feature. */
- S_SET_VALUE (symbolP, (char*) obstack_next_free (&frags) - frag_now->fr_literal);
+ S_SET_VALUE (symbolP, (valueT) frag_now_fix ());
symbolP->sy_frag = frag_now;
break;
{
if (S_GET_TYPE (symbolP) == N_SLINE)
{
- listing_source_line (S_GET_DESC (symbolP));
+ listing_source_line ((unsigned int) S_GET_DESC (symbolP));
}
else if (S_GET_TYPE (symbolP) == N_SO || S_GET_TYPE (symbolP) == N_SOL)
{
} /* obj_aout_stab() */
static void
-obj_aout_desc ()
+obj_aout_desc (ignore)
+ int ignore;
{
register char *name;
register char c;
if (strcmp (section_name, ".text") == 0)
{
- subseg_new (SEG_TEXT, (subsegT) exp);
+ subseg_set (SEG_TEXT, (subsegT) exp);
}
if (strcmp (section_name, ".data") == 0)
{
if (flagseen['R'])
- subseg_new (SEG_TEXT, (subsegT) exp + 1000);
+ subseg_set (SEG_TEXT, (subsegT) exp + 1000);
else
- subseg_new (SEG_DATA, (subsegT) exp);
+ subseg_set (SEG_DATA, (subsegT) exp);
}
*section_name_end = c;
char *where,
symbolS * symbol_rootP));
+static char *stack_pop PARAMS ((stack * st));
+static char *stack_push PARAMS ((stack * st, char *element));
+#if 0
+static char *stack_top PARAMS ((stack * st));
+#endif
+static stack *stack_init PARAMS ((unsigned long chunk_size,
+ unsigned long element_size));
-static void EXFUN (obj_coff_def, (int what));
-static void EXFUN (obj_coff_lcomm, (void));
-static void EXFUN (obj_coff_dim, (void));
-static void EXFUN (obj_coff_text, (void));
-static void EXFUN (obj_coff_data, (void));
-static void EXFUN( obj_coff_bss,(void));
-static void EXFUN( obj_coff_ident,(void));
-static void EXFUN (obj_coff_endef, (void));
-static void EXFUN (obj_coff_line, (void));
-static void EXFUN (obj_coff_ln, (int));
-static void EXFUN (obj_coff_scl, (void));
-static void EXFUN (obj_coff_size, (void));
-static void EXFUN (obj_coff_tag, (void));
-static void EXFUN (obj_coff_type, (void));
-static void EXFUN (obj_coff_val, (void));
-void EXFUN (obj_coff_section, (void));
-static void EXFUN (tag_init, (void));
-static void EXFUN (tag_insert, (char *name, symbolS * symbolP));
+static void tag_init PARAMS ((void));
+static void tag_insert PARAMS ((char *name, symbolS * symbolP));
static struct hash_control *tag_hash;
+
static symbolS *def_symbol_in_progress = NULL;
+static void obj_coff_def PARAMS ((int));
+static void obj_coff_lcomm PARAMS ((int));
+static void obj_coff_dim PARAMS ((int));
+static void obj_coff_text PARAMS ((int));
+static void obj_coff_data PARAMS ((int));
+static void obj_coff_bss PARAMS ((int));
+static void obj_coff_ident PARAMS ((int));
+static void obj_coff_endef PARAMS ((int));
+static void obj_coff_line PARAMS ((int));
+static void obj_coff_ln PARAMS ((int));
+static void obj_coff_scl PARAMS ((int));
+static void obj_coff_size PARAMS ((int));
+static void obj_coff_tag PARAMS ((int));
+static void obj_coff_type PARAMS ((int));
+static void obj_coff_val PARAMS ((int));
+void obj_coff_section PARAMS ((int));
+
const pseudo_typeS obj_pseudo_table[] =
{
{"def", obj_coff_def, 0},
case rs_align:
size += frag->fr_fix;
size += relax_align (size, frag->fr_offset);
+ break;
+ default:
+ BAD_CASE (frag->fr_type);
+ break;
}
frag = frag->fr_next;
}
/* Additional information */
symbolP->sy_symbol.ost_flags = 0;
/* Auxiliary entries */
- bzero ((char *) &symbolP->sy_symbol.ost_auxent[0], AUXESZ);
+ memset ((char *) &symbolP->sy_symbol.ost_auxent[0], 0, AUXESZ);
#ifdef STRIP_UNDERSCORE
/* Remove leading underscore at the beginning of the symbol.
} /* obj_symbol_new_hook() */
/* stack stuff */
-stack *
+static stack *
stack_init (chunk_size, element_size)
unsigned long chunk_size;
unsigned long element_size;
free (st);
}
-char *
+static char *
stack_push (st, element)
stack *st;
char *element;
return st->data + st->pointer;
} /* stack_push() */
-char *
+static char *
stack_pop (st)
stack *st;
{
- if ((st->pointer -= st->element_size) < 0)
+ if (st->pointer < st->element_size)
{
st->pointer = 0;
return (char *) 0;
}
-
+ st->pointer -= st->element_size;
return st->data + st->pointer;
}
-char *
+#if 0
+/* Not used. */
+static char *
stack_top (st)
stack *st;
{
return st->data + st->pointer - st->element_size;
}
-
+#endif
/*
* Handle .ln directives.
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));
+ memset (def_symbol_in_progress, 0, sizeof (*def_symbol_in_progress));
symbol_name = input_line_pointer;
name_end = get_symbol_end ();
} /* obj_coff_def() */
unsigned int dim_index;
+
static void
-DEFUN_VOID (obj_coff_endef)
+obj_coff_endef (ignore)
+ int ignore;
{
symbolS *symbolP = 0;
/* DIM BUG FIX sac@cygnus.com */
}
static void
-DEFUN_VOID (obj_coff_dim)
+obj_coff_dim (ignore)
+ int ignore;
{
register int dim_index;
} /* obj_coff_dim() */
static void
-obj_coff_line ()
+obj_coff_line (ignore)
+ int ignore;
{
int this_base;
} /* obj_coff_line() */
static void
-obj_coff_size ()
+obj_coff_size (ignore)
+ int ignore;
{
if (def_symbol_in_progress == NULL)
{
} /* obj_coff_size() */
static void
-obj_coff_scl ()
+obj_coff_scl (ignore)
+ int ignore;
{
if (def_symbol_in_progress == NULL)
{
} /* obj_coff_scl() */
static void
-obj_coff_tag ()
+obj_coff_tag (ignore)
+ int ignore;
{
char *symbol_name;
char name_end;
} /* obj_coff_tag() */
static void
-obj_coff_type ()
+obj_coff_type (ignore)
+ int ignore;
{
if (def_symbol_in_progress == NULL)
{
} /* obj_coff_type() */
static void
-obj_coff_val ()
+obj_coff_val (ignore)
+ int ignore;
{
if (def_symbol_in_progress == NULL)
{
/* FIXME: this is to avoid an error message in the
FIXME case mentioned just above. */
- while (! is_end_of_line[*input_line_pointer])
+ while (! is_end_of_line[(unsigned char) *input_line_pointer])
++input_line_pointer;
}
else
char *name;
symbolS *symbolP;
{
- register char *error_string;
+ register const char *error_string;
if (*(error_string = hash_jam (tag_hash, name, (char *) symbolP)))
{
object_headers *h AND
bfd * abfd)
{
-
unsigned int i;
- symbolS *symbolP;
/* Initialize the stack used to keep track of the matching .bb .be */
that any .align's size can be worked by looking at the next
frag */
- subseg_new (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
+ subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
#ifndef SUB_SEGMENT_ALIGN
#define SUB_SEGMENT_ALIGN(SEG) 1
#endif
{
unsigned int symtable_size = H_GET_SYMBOL_TABLE_SIZE (&headers);
char *buffer1 = xmalloc (symtable_size + string_byte_count + 1);
- char *ptr = buffer1;
+
H_SET_SYMBOL_TABLE_POINTER (&headers, bfd_tell (abfd));
w_symbols (abfd, buffer1, symbol_rootP);
if (string_byte_count > 0)
bfd_errmsg (bfd_error));
}
+/* Add a new segment. This is called from subseg_new via the
+ obj_new_segment macro. */
-static void
-DEFUN (change_to_section, (name, len, exp),
- char *name AND
- unsigned int len AND
- unsigned int exp)
+segT
+obj_coff_add_segment (name)
+ const char *name;
{
+ unsigned int len;
unsigned int i;
- /* Find out if we've already got a section of this name etc */
+
+ /* Find out if we've already got a section of this name. */
+ len = strlen (name);
+ if (len < sizeof (segment_info[i].scnhdr.s_name))
+ ++len;
+ else
+ len = sizeof (segment_info[i].scnhdr.s_name);
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
+ && (len == sizeof (segment_info[i].scnhdr.s_name)
+ || segment_info[i].scnhdr.s_name[len] == '\0'))
+ return (segT) i;
+
+ if (i == SEG_E9)
{
- if (strncmp (segment_info[i].scnhdr.s_name, name, len) == 0)
- {
- subseg_new (i, exp);
- return;
- }
+ as_bad ("Too many new sections; can't add \"%s\"", name);
+ return now_seg;
}
- /* No section, add one */
- strncpy (segment_info[i].scnhdr.s_name, name, 8);
+
+ /* Add a new section. */
+ strncpy (segment_info[i].scnhdr.s_name, name,
+ sizeof (segment_info[i].scnhdr.s_name));
segment_info[i].scnhdr.s_flags = STYP_REG;
- subseg_new (i, exp);
+
+ return (segT) i;
}
/*
*/
void
-DEFUN_VOID (obj_coff_section)
+obj_coff_section (ignore)
+ int ignore;
{
/* Strip out the section name */
char *section_name;
{
++input_line_pointer;
while (*input_line_pointer != '"'
- && ! is_end_of_line[*input_line_pointer])
+ && ! is_end_of_line[(unsigned char) *input_line_pointer])
{
switch (*input_line_pointer)
{
}
}
- change_to_section (section_name, len, exp);
+ subseg_new (section_name, exp);
segment_info[now_seg].scnhdr.s_flags |= flags;
static void
-obj_coff_text ()
+obj_coff_text (ignore)
+ int ignore;
{
- change_to_section (".text", 5, get_absolute_expression ());
+ subseg_new (".text", get_absolute_expression ());
}
static void
-obj_coff_data ()
+obj_coff_data (ignore)
+ int ignore;
{
if (flagseen['R'])
- change_to_section (".text", 5, get_absolute_expression () + 1000);
+ subseg_new (".text", get_absolute_expression () + 1000);
else
- change_to_section (".data", 5, get_absolute_expression ());
+ subseg_new (".data", get_absolute_expression ());
}
static void
-obj_coff_bss()
+obj_coff_bss (ignore)
+ int ignore;
{
if (*input_line_pointer == '\n') /* .bss */
- change_to_section(".bss",4, get_absolute_expression());
+ subseg_new(".bss", get_absolute_expression());
else /* .bss id,expr */
- obj_coff_lcomm();
+ obj_coff_lcomm(0);
}
static void
-obj_coff_ident()
+obj_coff_ident (ignore)
+ int ignore;
{
segT current_seg = now_seg; /* save current seg */
subsegT current_subseg = now_subseg;
- change_to_section (".comment", 8, 0); /* .comment seg */
+ subseg_new (".comment", 0); /* .comment seg */
stringer (1); /* read string */
- subseg_new (current_seg, current_subseg); /* restore current seg */
+ subseg_set (current_seg, current_subseg); /* restore current seg */
}
void
}
else
{
- bzero (symbolP->sy_symbol.ost_entry.n_name, SYMNMLEN);
+ memset (symbolP->sy_symbol.ost_entry.n_name, 0, SYMNMLEN);
strncpy (symbolP->sy_symbol.ost_entry.n_name, temp, SYMNMLEN);
}
where = symbol_to_chars (abfd, where, symbolP);
} /* w_symbols() */
static void
-DEFUN_VOID (obj_coff_lcomm)
+obj_coff_lcomm (ignore)
+ int ignore;
{
char *name;
char c;
segT current_seg = now_seg; /* save current seg */
subsegT current_subseg = now_subseg;
- subseg_new (SEG_E2, 1);
+ subseg_set (SEG_E2, 1);
symbolP->sy_frag = frag_now;
p = frag_var(rs_org, 1, 1, (relax_substateT)0, symbolP,
temp, (char *)0);
*p = 0;
- subseg_new (current_seg, current_subseg); /* restore current seg */
+ subseg_set (current_seg, current_subseg); /* restore current seg */
S_SET_SEGMENT(symbolP, SEG_E2);
S_SET_STORAGE_CLASS(symbolP, C_STAT);
}
}
else
{
- as_bad ("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %d.",
+ as_bad ("Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %ld.",
segment_name (S_GET_SEGMENT (sub_symbolP)),
- S_GET_NAME (sub_symbolP), fragP->fr_address + where);
+ S_GET_NAME (sub_symbolP),
+ (long) (fragP->fr_address + where));
} /* if absolute */
}
} /* if sub_symbolP */
(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);
+ as_bad ("Value of %ld too large for field of %d bytes at 0x%lx",
+ (long) add_number, size,
+ (unsigned long) (fragP->fr_address + where));
} /* generic error checking */
#endif
#ifdef WARN_SIGNED_OVERFLOW_WORD
if (!flagseen['J']
&& size == 2
&& add_number > 0x7fff)
- as_bad ("Signed .word overflow; switch may be too large; %d at 0x%x",
- add_number, fragP->fr_address + where);
+ as_bad ("Signed .word overflow; switch may be too large; %ld at 0x%lx",
+ (long) add_number,
+ (unsigned long) (fragP->fr_address + where));
#endif
} /* not a bit fix */
/* once this fix has been applied, we don't have to output anything
#define S_IS_LOCAL(s) \
((s)->sy_symbol.ost_entry.n_scnum == C_REGISTER_SECTION \
|| (S_LOCAL_NAME(s) && !flagseen['L']) \
- || (strchr (s, '\001') != NULL))
+ || (strchr (S_GET_NAME (s), '\001') != NULL))
/* True if a symbol is not defined in this file */
#define S_IS_EXTERN(s) ((s)->sy_symbol.ost_entry.n_scnum == 0 \
&& S_GET_VALUE (s) == 0)
stack;
+#define obj_segment_name(i) (segment_info[(int) (i)].scnhdr.s_name)
+#define obj_add_segment(s) obj_coff_add_segment (s)
-char *EXFUN (stack_pop, (stack * st));
-char *EXFUN (stack_push, (stack * st, char *element));
-char *EXFUN (stack_top, (stack * st));
-stack *EXFUN (stack_init, (unsigned long chunk_size, unsigned long element_size));
-void EXFUN (c_dot_file_symbol, (char *filename));
-void EXFUN (obj_extra_stuff, (object_headers * headers));
-void EXFUN (stack_delete, (stack * st));
+extern segT obj_coff_add_segment PARAMS ((const char *));
-segT EXFUN (s_get_segment,(struct symbol * ptr));
+extern void obj_coff_section PARAMS ((int));
-void EXFUN (c_section_header, (
+extern void c_dot_file_symbol PARAMS ((char *filename));
+extern void obj_extra_stuff PARAMS ((object_headers * headers));
+extern void stack_delete PARAMS ((stack * st));
- struct internal_scnhdr * header,
- char *name,
- long core_address,
- long size,
- long data_ptr,
- long reloc_ptr,
- long lineno_ptr,
- long reloc_number,
- long lineno_number,
- long alignment));
+extern segT s_get_segment PARAMS ((struct symbol * ptr));
+
+extern void c_section_header PARAMS ((struct internal_scnhdr * header,
+ char *name,
+ long core_address,
+ long size,
+ long data_ptr,
+ long reloc_ptr,
+ long lineno_ptr,
+ long reloc_number,
+ long lineno_number,
+ long alignment));
/* sanity check */
#include "aout/stab_gnu.h"
#include "obstack.h"
+static int obj_elf_write_symbol_p PARAMS ((symbolS *sym));
+
static void obj_elf_stab PARAMS ((int what));
static void obj_elf_xstab PARAMS ((int what));
-static void obj_elf_line PARAMS ((void));
-void obj_elf_desc PARAMS ((void));
-void obj_elf_version PARAMS ((void));
-static void obj_elf_size PARAMS ((void));
-static void obj_elf_type PARAMS ((void));
-static void obj_elf_ident PARAMS ((void));
-static void obj_elf_weak PARAMS ((void));
-static void obj_elf_local PARAMS ((void));
-static void obj_elf_common PARAMS ((void));
+static void obj_elf_line PARAMS ((int));
+void obj_elf_desc PARAMS ((int));
+void obj_elf_version PARAMS ((int));
+static void obj_elf_size PARAMS ((int));
+static void obj_elf_type PARAMS ((int));
+static void obj_elf_ident PARAMS ((int));
+static void obj_elf_weak PARAMS ((int));
+static void obj_elf_local PARAMS ((int));
+static void obj_elf_common PARAMS ((int));
const pseudo_typeS obj_pseudo_table[] =
{
}
static void
-obj_elf_common ()
+obj_elf_common (ignore)
+ int ignore;
{
char *name;
char c;
{
segT old_sec;
int old_subsec;
- char *p;
+ char *pfrag;
int align;
/* allocate_bss: */
if (S_GET_SEGMENT (symbolP) == bss_section)
symbolP->sy_frag->fr_symbol = 0;
symbolP->sy_frag = frag_now;
- p = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size,
- (char *) 0);
- *p = 0;
+ pfrag = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP, size,
+ (char *) 0);
+ *pfrag = 0;
S_SET_SEGMENT (symbolP, bss_section);
S_CLEAR_EXTERNAL (symbolP);
subseg_set (old_sec, old_subsec);
else
{
allocate_common:
- S_SET_VALUE (symbolP, size);
+ S_SET_VALUE (symbolP, (valueT) size);
S_SET_EXTERNAL (symbolP);
/* should be common, but this is how gas does it for now */
S_SET_SEGMENT (symbolP, &bfd_und_section);
}
static void
-obj_elf_local ()
+obj_elf_local (ignore)
+ int ignore;
{
char *name;
int c;
}
static void
-obj_elf_weak ()
+obj_elf_weak (ignore)
+ int ignore;
{
char *name;
int c;
p++;
c = *p;
*p = 0;
- string = xmalloc (p - input_line_pointer + 1);
+ string = xmalloc ((unsigned long) (p - input_line_pointer + 1));
strcpy (string, input_line_pointer);
*p = c;
input_line_pointer = p;
while (*input_line_pointer == ',')
{
flagword bit;
- int len, inv;
+ unsigned int len;
+ int inv;
char *p, oldp;
input_line_pointer++;
}
void
-obj_elf_previous ()
+obj_elf_previous (ignore)
+ int ignore;
{
if (previous_section == 0)
{
previous_section = 0;
}
-int
+static int
obj_elf_write_symbol_p (sym)
symbolS *sym;
{
}
static void
-obj_elf_line ()
+obj_elf_line (ignore)
+ int ignore;
{
/* Assume delimiter is part of expression. BSD4.2 as fails with
delightful bug, so we are not being incompatible here. */
/* Create the stab sections, if they are not already created. */
{
- char *newsecname = xmalloc (strlen (secname) + 4);
+ char *newsecname = xmalloc ((unsigned long) (strlen (secname) + 4));
strcpy (newsecname, secname);
strcat (newsecname, "str");
seg = bfd_get_section_by_name (stdoutput, newsecname);
return;
}
- subseg_new ((char *) seg->name, subseg);
+ subseg_set (seg, subseg);
if (seg_is_new)
/* allocate and discard -- filled in later */
md_number_to_chars (p, 0, 4);
}
- subseg_new ((char *) saved_seg->name, subseg);
+ subseg_set (saved_seg, subseg);
if ((what == 's' || what == 'n')
&& symbolP->sy_value.X_op == O_constant)
switch (S_GET_TYPE (symbolP))
{
case N_SLINE:
- listing_source_line (S_GET_DESC (symbolP));
+ listing_source_line ((unsigned int) S_GET_DESC (symbolP));
break;
case N_SO:
case N_SOL:
}
void
-obj_elf_desc ()
+obj_elf_desc (ignore)
+ int ignore;
{
char *name;
char c;
}
void
-obj_elf_version ()
+obj_elf_version (ignore)
+ int ignore;
{
char *name;
unsigned int c;
/* process the version string */
- subseg_new ((char *) note_secp->name, 0);
+ subseg_set (note_secp, 0);
len = strlen (name);
i_note.namesz = ((len + 1) + 3) & ~3; /* round this to word boundary */
}
frag_align (2, 0);
- subseg_new ((char *) seg->name, subseg);
+ subseg_set (seg, subseg);
}
else
{
}
static void
-obj_elf_size ()
+obj_elf_size (ignore)
+ int ignore;
{
char *name = input_line_pointer;
char c = get_symbol_end ();
}
static void
-obj_elf_type ()
+obj_elf_type (ignore)
+ int ignore;
{
char *name = input_line_pointer;
char c = get_symbol_end ();
}
static void
-obj_elf_ident ()
+obj_elf_ident (ignore)
+ int ignore;
{
static segT comment_section;
segT old_section = now_seg;
assert (fragp->fr_type == rs_fill);
assert (fragp->fr_address == 0 && fragp->fr_fix >= 12);
- bfd_h_put_16 (abfd, nsyms, fragp->fr_literal + 6);
- bfd_h_put_32 (abfd, strsz, fragp->fr_literal + 8);
+ bfd_h_put_16 (abfd, (bfd_vma) nsyms, fragp->fr_literal + 6);
+ bfd_h_put_32 (abfd, (bfd_vma) strsz, fragp->fr_literal + 8);
}
void
memcpy (segment_info[i].name, s, p - s);
segment_info[i].name[p - s] = 0;
ok:
- subseg_new (i, 0);
+ subseg_set (i, 0);
while (!is_end_of_line[*p])
p++;
input_line_pointer = p;
}
bfd_set_format (abfd, bfd_object);
bfd_set_arch_mach (abfd, bfd_arch_h8300, 0);
- subseg_new (1, 0);
- subseg_new (2, 0);
- subseg_new (3, 0);
+ subseg_set (1, 0);
+ subseg_set (2, 0);
+ subseg_set (3, 0);
for (frchain_ptr = frchain_root;
frchain_ptr != (struct frchain *) NULL;
frchain_ptr = frchain_ptr->frch_next)
that any .align's size can be worked by looking at the next
frag. */
- subseg_new (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
+ subseg_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
#ifndef SUB_SEGMENT_ALIGN
#define SUB_SEGMENT_ALIGN(SEG) 2
#endif
register int temp;
temp = get_absolute_expression ();
- subseg_new (SEG_DATA, (subsegT) temp);
+ subseg_set (SEG_DATA, (subsegT) temp);
const_flag = 1;
demand_empty_rest_of_line ();
}
#define machine_it a29k_it
const relax_typeS md_relax_table[] =
-{0};
+{
+ { 0, 0, 0, 0 }
+};
#define IMMEDIATE_BIT 0x01000000 /* Turns RB into Immediate */
#define ABSOLUTE_BIT 0x01000000 /* Turns PC-relative to Absolute */
static void machine_ip PARAMS ((char *str));
/* static void print_insn PARAMS ((struct machine_it *insn)); */
+#ifndef OBJ_COFF
static void s_data1 PARAMS ((void));
-static void s_use PARAMS ((void));
+static void s_use PARAMS ((int));
+#endif
const pseudo_typeS
md_pseudo_table[] =
*/
#define ANNUL (1 << 29)
+#ifndef OBJ_COFF
+
static void
-s_use ()
+s_use (ignore)
+ int ignore;
{
if (strncmp (input_line_pointer, ".text", 5) == 0)
if (strncmp (input_line_pointer, ".lit", 4) == 0)
{
input_line_pointer += 4;
- subseg_new (SEG_DATA, 200);
+ subseg_set (SEG_DATA, 200);
demand_empty_rest_of_line ();
return;
}
static void
s_data1 ()
{
- subseg_new (SEG_DATA, 1);
+ subseg_set (SEG_DATA, 1);
demand_empty_rest_of_line ();
return;
}
+#endif /* OBJ_COFF */
+
/* Install symbol definition that maps REGNAME to REGNO.
FIXME-SOON: These are not recognized in mixed case. */
void
md_begin ()
{
- register char *retval = NULL;
+ register const char *retval = NULL;
int lose = 0;
register int skipnext = 0;
register unsigned int i;
skipnext = 1;
}
- retval = hash_insert (op_hash, name, &machine_opcodes[i]);
+ retval = hash_insert (op_hash, name, (PTR) &machine_opcodes[i]);
if (retval != NULL && *retval != '\0')
{
fprintf (stderr, "internal error: can't hash `%s': %s\n",
}
else
{
- as_bad ("Immediate value of %d is too large",
- operand->X_add_number);
+ as_bad ("Immediate value of %ld is too large",
+ (long) operand->X_add_number);
continue;
}
}
}
else
{
- as_bad ("Immediate value of %d is too large",
- operand->X_add_number);
+ as_bad ("Immediate value of %ld is too large",
+ (long) operand->X_add_number);
continue;
}
}
return;
}
- subseg_new (SEG_DATA, 0); /* .data */
+ subseg_set (SEG_DATA, 0); /* .data */
frag_align (2, 0); /* .align 2 */
record_alignment (now_seg, 2);
colon (BR_TAB_NAME); /* BR_TAB_NAME: */
/* Treat empty string as absolute 0 */
expP->X_add_symbol = expP->X_op_symbol = NULL;
expP->X_add_number = 0;
- exp->X_op = O_constant;
+ expP->X_op = O_constant;
}
else
{
save_in = input_line_pointer; /* Save global */
input_line_pointer = textP; /* Make parser work for us */
- seg = expression (expP);
+ (void) expression (expP);
if (input_line_pointer - textP != strlen (textP))
{
/* Did not consume all of the input */
input_line_pointer = save_in; /* Restore global */
}
- return seg;
}
segT current_seg = now_seg;
subsegT current_subseg = now_subseg;
- subseg_new (SEG_BSS, 1); /* switch to bss */
+ subseg_set (SEG_BSS, 1); /* switch to bss */
if (bss_align)
frag_align (bss_align, 0);
*p = 0;
S_SET_SEGMENT (symbolP, SEG_BSS);
- subseg_new (current_seg, current_subseg);
+ subseg_set (current_seg, current_subseg);
}
}
else
#endif
static int insn_uses_reg PARAMS ((struct mips_cl_insn *ip,
- int reg, int fpr));
+ unsigned int reg, int fpr));
static void append_insn PARAMS ((struct mips_cl_insn * ip,
expressionS * p,
bfd_reloc_code_real_type r));
void
md_begin ()
{
- register char *retval = NULL;
+ register const char *retval = NULL;
register unsigned int i = 0;
if (mips_isa == -1)
{
const char *name = mips_opcodes[i].name;
- retval = hash_insert (op_hash, name, &mips_opcodes[i]);
+ retval = hash_insert (op_hash, name, (PTR) &mips_opcodes[i]);
if (retval != NULL && *retval != '\0')
{
fprintf (stderr, "internal error: can't hash `%s': %s\n",
static int
insn_uses_reg (ip, reg, fpr)
struct mips_cl_insn *ip;
- int reg;
+ unsigned int reg;
int fpr;
{
/* Don't report on general register 0, since it never changes. */
because there is no instruction that sets both $f0 and $f1
and requires a delay. */
if ((ip->insn_mo->pinfo & INSN_READ_FPR_S)
- && ((ip->insn_opcode >> OP_SH_FS) & OP_MASK_FS) == (reg &~ 1))
+ && (((ip->insn_opcode >> OP_SH_FS) & OP_MASK_FS)
+ == (reg &~ (unsigned) 1)))
return 1;
if ((ip->insn_mo->pinfo & INSN_READ_FPR_T)
- && ((ip->insn_opcode >> OP_SH_FT) & OP_MASK_FT) == (reg &~ 1))
+ && (((ip->insn_opcode >> OP_SH_FT) & OP_MASK_FT)
+ == (reg &~ (unsigned) 1)))
return 1;
}
else
{
assert (S_GET_SEGMENT (insn_label) == now_seg);
insn_label->sy_frag = frag_now;
- S_SET_VALUE (insn_label, frag_now_fix ());
+ S_SET_VALUE (insn_label, (valueT) frag_now_fix ());
}
}
}
{
assert (S_GET_SEGMENT (insn_label) == now_seg);
insn_label->sy_frag = frag_now;
- S_SET_VALUE (insn_label, frag_now_fix ());
+ S_SET_VALUE (insn_label, (valueT) frag_now_fix ());
}
}
mips_no_prev_insn ();
char *save_in;
char *err;
unsigned char temp[8];
- int length;
+ int len;
+ unsigned int length;
segT seg;
subsegT subseg;
char *p;
save_in = input_line_pointer;
input_line_pointer = s;
- err = md_atof (f64 ? 'd' : 'f', (char *) temp, &length);
+ err = md_atof (f64 ? 'd' : 'f', (char *) temp, &len);
+ length = len;
s = input_line_pointer;
input_line_pointer = save_in;
if (err != NULL && *err != '\0')
offset_expr.X_add_number = 0;
/* Put the floating point number into the section. */
- p = frag_more (length);
+ p = frag_more ((int) length);
memcpy (p, temp, length);
/* Switch back to the original section. */
return 0;
}
insn |= value & 0xFFFF;
- md_number_to_chars ((char *) buf, insn, 4);
+ md_number_to_chars ((char *) buf, (valueT) insn, 4);
break;
default:
{
assert (S_GET_SEGMENT (insn_label) == now_seg);
insn_label->sy_frag = frag_now;
- S_SET_VALUE (insn_label, frag_now_fix ());
+ S_SET_VALUE (insn_label, (valueT) frag_now_fix ());
insn_label = NULL;
}
}
switch (sec)
{
case 't':
- s_text ();
+ s_text (0);
break;
case 'r':
#ifdef OBJ_ECOFF
/* Fall through. */
#endif
case 'd':
- s_data ();
+ s_data (0);
break;
case 'b':
-#ifdef BFD_ASSEMBLER
subseg_set (bss_section, (subsegT) get_absolute_expression ());
-#else
- subseg_new (bss_section, (subsegT) get_absolute_expression ());
-#endif
demand_empty_rest_of_line ();
break;
case 's':
s_extern (x)
int x;
{
- long size;
+ valueT size;
symbolS *symbolP;
symbolP = get_symbol ();
{"byte", cons, 1},
{"comm", s_comm, 0},
{"data", s_data, 0},
+#ifdef S_SET_DESC
{"desc", s_desc, 0},
+#endif
/* dim */
{"double", float_cons, 'd'},
/* dsect */
static void
pobegin ()
{
- char *errtxt; /* error text */
+ const char *errtxt; /* error text */
const pseudo_typeS *pop;
po_hash = hash_new ();
char *ends;
char *new_buf;
char *new_tmp;
- int new_length;
+ unsigned int new_length;
char *tmp_buf = 0;
extern char *scrub_string, *scrub_last_string;
if (!ends)
{
- int tmp_len;
- int num;
+ unsigned int tmp_len;
+ unsigned int num;
/* The end of the #APP wasn't in this buffer. We
keep reading in buffers until we find the #NO_APP
} /* read_a_source_file() */
void
-s_abort ()
+s_abort (ignore)
+ int ignore;
{
as_fatal (".abort detected. Abandoning ship.");
} /* s_abort() */
temp_fill = 0;
/* Only make a frag if we HAVE to. . . */
if (temp && !need_pass_2)
- frag_align (temp, (int) temp_fill);
+ frag_align ((int) temp, (int) temp_fill);
- record_alignment (now_seg, temp);
+ record_alignment (now_seg, (int) temp);
demand_empty_rest_of_line ();
} /* s_align_bytes() */
/* For machines where ".align 4" means align to 2**4 boundary. */
void
-s_align_ptwo ()
+s_align_ptwo (ignore)
+ int ignore;
{
register int temp;
register long temp_fill;
} /* s_align_ptwo() */
void
-s_comm ()
+s_comm (ignore)
+ int ignore;
{
register char *name;
register char c;
} /* s_comm() */
void
-s_data ()
+s_data (ignore)
+ int ignore;
{
segT section;
register int temp;
else
section = data_section;
-#ifdef BFD_ASSEMBLER
subseg_set (section, (subsegT) temp);
-#else
- subseg_new (section, (subsegT) temp);
-#endif
#ifdef OBJ_VMS
const_flag = 0;
specific pseudo-ops. */
void
-s_app_line ()
+s_app_line (ignore)
+ int ignore;
{
int l;
}
void
-s_fill ()
+s_fill (ignore)
+ int ignore;
{
long temp_repeat = 0;
long temp_size = 1;
if (temp_size && !need_pass_2)
{
p = frag_var (rs_fill, (int) temp_size, (int) temp_size, (relax_substateT) 0, (symbolS *) 0, temp_repeat, (char *) 0);
- memset (p, 0, (int) temp_size);
+ memset (p, 0, (unsigned int) temp_size);
/* The magic number BSD_FILL_SIZE_CROCK_4 is from BSD 4.2 VAX
* flavoured AS. The following bizzare behaviour is to be
* compatible with above. I guess they tried to take up to 8
* bytes from a 4-byte expression and they forgot to sign
* extend. Un*x Sux. */
#define BSD_FILL_SIZE_CROCK_4 (4)
- md_number_to_chars (p, temp_fill,
+ md_number_to_chars (p, (valueT) temp_fill,
(temp_size > BSD_FILL_SIZE_CROCK_4
? BSD_FILL_SIZE_CROCK_4
: (int) temp_size));
}
void
-s_globl ()
+s_globl (ignore)
+ int ignore;
{
char *name;
int c;
(S_GET_SEGMENT (symbolP) == bss_seg
|| (!S_IS_DEFINED (symbolP) && S_GET_VALUE (symbolP) == 0)))
{
- char *p;
+ char *pfrag;
-#ifdef BFD_ASSEMBLER
subseg_set (bss_seg, 1);
-#else
- subseg_new (bss_seg, 1);
-#endif
if (align)
frag_align (align, 0);
symbolP->sy_frag->fr_symbol = NULL;
symbolP->sy_frag = frag_now;
- p = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
- temp, (char *)0);
- *p = 0;
+ pfrag = frag_var (rs_org, 1, 1, (relax_substateT)0, symbolP,
+ temp, (char *)0);
+ *pfrag = 0;
S_SET_SEGMENT (symbolP, bss_seg);
as_bad ("Ignoring attempt to re-define symbol %s.", name);
}
-#ifdef BFD_ASSEMBLER
subseg_set (current_seg, current_subseg);
-#else
- subseg_new (current_seg, current_subseg);
-#endif
demand_empty_rest_of_line ();
} /* s_lcomm() */
-void
-s_long ()
-{
- cons (4);
-}
-
-void
-s_int ()
-{
- cons (4);
-}
-
void
-s_lsym ()
+s_lsym (ignore)
+ int ignore;
{
register char *name;
register char c;
} /* s_lsym() */
void
-s_org ()
+s_org (ignore)
+ int ignore;
{
register segT segment;
expressionS exp;
} /* s_org() */
void
-s_set ()
+s_set (ignore)
+ int ignore;
{
register char *name;
register char delim;
} /* s_space() */
void
-s_text ()
+s_text (ignore)
+ int ignore;
{
register int temp;
temp = get_absolute_expression ();
-#ifdef BFD_ASSEMBLER
subseg_set (text_section, (subsegT) temp);
-#else
- subseg_new (text_section, (subsegT) temp);
-#endif
demand_empty_rest_of_line ();
} /* s_text() */
\f
else
S_CLEAR_EXTERNAL (symbolP);
#endif /* OBJ_AOUT or OBJ_BOUT */
- S_SET_VALUE (symbolP, exp.X_add_number);
+ S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
symbolP->sy_frag = &zero_address_frag;
break;
case O_register:
S_SET_SEGMENT (symbolP, reg_section);
- S_SET_VALUE (symbolP, exp.X_add_number);
+ S_SET_VALUE (symbolP, (valueT) exp.X_add_number);
symbolP->sy_frag = &zero_address_frag;
break;
/* end-of-line. */
void
cons (nbytes)
- register unsigned int nbytes; /* 1=.byte, 2=.word, 4=.long */
+ register int nbytes; /* 1=.byte, 2=.word, 4=.long */
{
expressionS exp;
do
{
- TC_PARSE_CONS_EXPRESSION (&exp, nbytes);
- emit_expr (&exp, nbytes);
+ TC_PARSE_CONS_EXPRESSION (&exp, (unsigned int) nbytes);
+ emit_expr (&exp, (unsigned int) nbytes);
}
while (*input_line_pointer++ == ',');
op = O_constant;
}
- p = frag_more (nbytes);
+ p = frag_more ((int) nbytes);
#ifndef WORKING_DOT_WORD
/* If we have the difference of two symbols in a word, save it on
{ /* Leading bits contain both 0s & 1s. */
as_warn ("Value 0x%lx truncated to 0x%lx.", get, use);
}
- md_number_to_chars (p, use, nbytes); /* put bytes in right order. */
+ /* put bytes in right order. */
+ md_number_to_chars (p, (valueT) use, (int) nbytes);
}
else
{
- md_number_to_chars (p, (long) 0, nbytes);
+ md_number_to_chars (p, (valueT) 0, (int) nbytes);
/* Now we need to generate a fixS to record the symbol value.
This is easy for BFD. For other targets it can be more
#ifdef TC_CONS_FIX_NEW
TC_CONS_FIX_NEW (frag_now, p - frag_now->fr_literal, nbytes, exp);
#else
- fix_new_exp (frag_now, p - frag_now->fr_literal, nbytes, exp, 0,
+ fix_new_exp (frag_now, p - frag_now->fr_literal, (int) nbytes, exp, 0,
/* @@ Should look at CPU word size. */
nbytes == 2 ? BFD_RELOC_16
: nbytes == 8 ? BFD_RELOC_64
p[i] = *src++;
}
else
- memcpy (p, bignum_low, (int) nbytes);
+ memcpy (p, bignum_low, (unsigned int) nbytes);
}
/* C contains character after number. */
SKIP_WHITESPACE ();
static void
grow_bignum ()
{
- register long length;
+ register unsigned long length;
bignum_high++;
if (bignum_high >= bignum_limit)
while (--count >= 0)
{
p = frag_more (length);
- memcpy (p, temp, length);
+ memcpy (p, temp, (unsigned int) length);
}
}
SKIP_WHITESPACE ();
filename = demand_copy_string (&i);
demand_empty_rest_of_line ();
- path = xmalloc (i + include_dir_maxlen + 5 /* slop */ );
+ path = xmalloc ((unsigned long) i + include_dir_maxlen + 5 /* slop */ );
for (i = 0; i < include_dir_count; i++)
{
strcpy (path, include_dirs[i]);
{
if (strncmp (segment_info[i].scnhdr.s_name, name, len) == 0)
{
- subseg_new (i, exp);
+ subseg_set (i, exp);
return;
}
}
/* No section, add one */
strncpy (segment_info[i].scnhdr.s_name, name, 8);
segment_info[i].scnhdr.s_flags = 0 /* STYP_NOLOAD */;
- subseg_new (i, exp);
+ subseg_set (i, exp);
#endif
#endif
}
bfd_set_section_flags (stdoutput, seg, SEC_READONLY | SEC_ALLOC);
}
#else
- change_to_section(newsecname, strlen(newsecname), 0);
+ subseg_new (newsecname, 0);
#endif
/* free (newsecname);*/
}
-#ifdef BFD_ASSEMBLER
subseg_set (seg, save_subseg);
-#else
-/* subseg_new (seg, save_subseg); */
-#endif
old_gdb_string_index = gdb_string_index;
i = 0;
while ((c = *string++))
i++;
gdb_string_index++;
}
-#ifdef BFD_ASSEMBLER
subseg_set (save_seg, save_subseg);
-#else
-/* subseg_new (save_seg, save_subseg); */
-#endif
}
return old_gdb_string_index;
}
segT seg;
subsegT saved_subseg = now_subseg;
subsegT subseg;
- int valu;
+ valueT valu;
#ifdef SEPARATE_STAB_SECTIONS
int seg_is_new = 0;
#endif
seg_is_new = 1;
}
#else
- change_to_section (secname, strlen(secname), 0);
+ subseg_new (secname, 0);
#endif
#endif /* SEPARATE_STAB_SECTIONS */
if (goof)
{
ignore_rest_of_line ();
-#ifdef BFD_ASSEMBLER
subseg_set (saved_seg, saved_subseg);
-#else
- subseg_new (saved_seg, saved_subseg);
-#endif
return;
}
-#ifdef BFD_ASSEMBLER
subseg_set (seg, subseg);
-#endif
#if 0 /* needed for elf only? */
if (seg_is_new)
{
char *toP;
- change_to_section(secname, strlen(secname), 0);
+ subseg_new (secname, 0);
toP = frag_more (8);
/* the string index portion of the stab */
md_number_to_chars (toP, (valueT) S_GET_OFFSET_2(symbol), 4);
char *p = frag_more (4);
md_number_to_chars (p, 0, 4);
}
-#ifdef BFD_ASSEMBLER
subseg_set (saved_seg, subseg);
#else
-/* subseg_new (saved_seg, subseg); */
-#endif
-#else
if (what == 's' || what == 'n')
{
pseudo_set (symbol);
switch (S_GET_TYPE (symbol))
{
case N_SLINE:
- listing_source_line (S_GET_DESC (symbol));
+ listing_source_line ((unsigned int) S_GET_DESC (symbol));
break;
case N_SO:
case N_SOL:
#endif /* !NO_LISTING */
#ifdef SEPARATE_STAB_SECTIONS
- subseg_new (saved_seg, saved_subseg);
+ subseg_set (saved_seg, saved_subseg);
#endif
demand_empty_rest_of_line ();
s_stab_generic (what, secname);
}
+#ifdef S_SET_DESC
+
/* Frob invented at RMS' request. Set the n_desc of a symbol. */
void
-s_desc ()
+s_desc (ignore)
+ int ignore;
{
char *name;
char c;
demand_empty_rest_of_line ();
} /* s_desc() */
+#endif /* defined (S_SET_DESC) */
+
/* end of read.c */
/* subsegs.c - subsegments -
Copyright (C) 1987, 1990, 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. */
#include "subsegs.h"
#include "obstack.h"
+frchainS *frchain_root, *frchain_now;
+
+#ifndef BFD_ASSEMBLER
#ifdef MANY_SEGMENTS
segment_info_type segment_info[SEG_MAXIMUM_ORDINAL];
-frchainS* frchain_root,
- * frchain_now;
-
#else
-frchainS* frchain_root,
- * frchain_now, /* Commented in "subsegs.h". */
- * data0_frchainP,
- * bss0_frchainP;
+/* Commented in "subsegs.h". */
+frchainS *data0_frchainP, *bss0_frchainP;
-#endif
-char * const /* in: segT out: char* */
- seg_name[] = {
- "absolute",
+#endif /* MANY_SEGMENTS */
+char *const seg_name[] =
+{
+ "absolute",
#ifdef MANY_SEGMENTS
- "e0","e1","e2","e3","e4","e5","e6","e7","e8","e9",
+ "e0", "e1", "e2", "e3", "e4", "e5", "e6", "e7", "e8", "e9",
#else
- "text",
- "data",
- "bss",
-#endif
- "unknown",
- "absent",
- "pass1",
- "ASSEMBLER-INTERNAL-LOGIC-ERROR!",
- "bignum/flonum",
- "difference",
- "debug",
- "transfert vector preload",
- "transfert vector postload",
- "register",
- "",
- }; /* Used by error reporters, dumpers etc. */
+ "text",
+ "data",
+ "bss",
+#endif /* MANY_SEGMENTS */
+ "unknown",
+ "ASSEMBLER-INTERNAL-LOGIC-ERROR!",
+ "expr",
+ "debug",
+ "transfert vector preload",
+ "transfert vector postload",
+ "register",
+ "",
+}; /* Used by error reporters, dumpers etc. */
+#endif /* BFD_ASSEMBLER */
+static void subseg_set_rest PARAMS ((segT, subsegT));
\f
void
- subsegs_begin()
+subsegs_begin ()
{
- /* Check table(s) seg_name[], seg_N_TYPE[] is in correct order */
-#ifdef MANY_SEGMENTS
-#else
- know( SEG_ABSOLUTE == 0 );
- know( SEG_TEXT == 1 );
- know( SEG_DATA == 2 );
- know( SEG_BSS == 3 );
- know( SEG_UNKNOWN == 4 );
- know( SEG_ABSENT == 5 );
- know( SEG_PASS1 == 6 );
- know( SEG_GOOF == 7 );
- know( SEG_BIG == 8 );
- know( SEG_DIFFERENCE == 9 );
- know( SEG_DEBUG == 10 );
- know( SEG_NTV == 11 );
- know( SEG_PTV == 12 );
- know( SEG_REGISTER == 13 );
- know( SEG_MAXIMUM_ORDINAL == SEG_REGISTER );
- /* know( segment_name (SEG_MAXIMUM_ORDINAL + 1) [0] == 0 );*/
+ /* Check table(s) seg_name[], seg_N_TYPE[] is in correct order */
+#if !defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
+ know (SEG_ABSOLUTE == 0);
+ know (SEG_TEXT == 1);
+ know (SEG_DATA == 2);
+ know (SEG_BSS == 3);
+ know (SEG_UNKNOWN == 4);
+ know (SEG_GOOF == 5);
+ know (SEG_EXPR == 6);
+ know (SEG_DEBUG == 7);
+ know (SEG_NTV == 8);
+ know (SEG_PTV == 9);
+ know (SEG_REGISTER == 10);
+ know (SEG_MAXIMUM_ORDINAL == SEG_REGISTER);
#endif
-
- obstack_begin( &frags, 5000);
- frchain_root = NULL;
- frchain_now = NULL; /* Warn new_subseg() that we are booting. */
- /* Fake up 1st frag. */
- /* It won't be used=> is ok if obstack... */
- /* pads the end of it for alignment. */
- frag_now=(fragS *)obstack_alloc(&frags,SIZEOF_STRUCT_FRAG);
- memset(frag_now, SIZEOF_STRUCT_FRAG, 0);
- /* This 1st frag will not be in any frchain. */
- /* We simply give subseg_new somewhere to scribble. */
- now_subseg = 42; /* Lie for 1st call to subseg_new. */
+
+ obstack_begin (&frags, 5000);
+ frchain_root = NULL;
+ frchain_now = NULL; /* Warn new_subseg() that we are booting. */
+ /* Fake up 1st frag. It won't be used=> is ok if obstack...
+ pads the end of it for alignment. */
+ frag_now = (fragS *) obstack_alloc (&frags, SIZEOF_STRUCT_FRAG);
+ memset (frag_now, SIZEOF_STRUCT_FRAG, 0);
+
+#ifndef BFD_ASSEMBLER
+ /* This 1st frag will not be in any frchain.
+ We simply give subseg_new somewhere to scribble. */
+ now_subseg = 42; /* Lie for 1st call to subseg_new. */
#ifdef MANY_SEGMENTS
- {
- int i;
- for (i = SEG_E0; i < SEG_UNKNOWN; i++) {
- subseg_new(i, 0);
- segment_info[i].frchainP = frchain_now;
- }
- }
+ {
+ int i;
+ for (i = SEG_E0; i < SEG_UNKNOWN; i++)
+ {
+ subseg_set (i, 0);
+ segment_info[i].frchainP = frchain_now;
+ }
+ }
#else
- subseg_new (SEG_DATA, 0); /* .data 0 */
- data0_frchainP = frchain_now;
+ subseg_set (SEG_DATA, 0); /* .data 0 */
+ data0_frchainP = frchain_now;
- subseg_new (SEG_BSS, 0);
- bss0_frchainP = frchain_now;
+ subseg_set (SEG_BSS, 0);
+ bss0_frchainP = frchain_now;
+
+#endif /* ! MANY_SEGMENTS */
+#endif /* ! BFD_ASSEMBLER */
-#endif
-
}
\f
/*
*
* Change the subsegment we are in, BUT DO NOT MAKE A NEW FRAG for the
* subsegment. If we are already in the correct subsegment, change nothing.
- * This is used eg as a worker for subseg_new [which does make a new frag_now]
+ * This is used eg as a worker for subseg_set [which does make a new frag_now]
* and for changing segments after we have read the source. We construct eg
* fixSs even after the source file is read, so we do have to keep the
* segment context correct.
*/
void
- subseg_change (seg, subseg)
-register segT seg;
-register int subseg;
+subseg_change (seg, subseg)
+ register segT seg;
+ register int subseg;
{
- now_seg = seg;
- now_subseg = subseg;
+ now_seg = seg;
+ now_subseg = subseg;
+
+#ifdef BFD_ASSEMBLER
+ {
+ segment_info_type *seginfo;
+ seginfo = (segment_info_type *) bfd_get_section_userdata (stdoutput, seg);
+ if (! seginfo)
+ {
+ seginfo = (segment_info_type *) xmalloc (sizeof (*seginfo));
+ if (! seginfo)
+ abort ();
+ seginfo->fix_root = 0;
+ seginfo->fix_tail = 0;
+ seginfo->bfd_section = seg;
+ seginfo->sym = 0;
+ bfd_set_section_userdata (stdoutput, seg, (char *) seginfo);
+ }
+ }
+#else
#ifdef MANY_SEGMENTS
- seg_fix_rootP = & segment_info[seg].fix_root;
- seg_fix_tailP = & segment_info[seg].fix_tail;
+ seg_fix_rootP = &segment_info[seg].fix_root;
+ seg_fix_tailP = &segment_info[seg].fix_tail;
#else
- if (seg == SEG_DATA)
- {
- seg_fix_rootP = & data_fix_root;
- seg_fix_tailP = & data_fix_tail;
- }
- else if (seg == SEG_TEXT)
- {
- seg_fix_rootP = & text_fix_root;
- seg_fix_tailP = & text_fix_tail;
- }
- else {
- know (seg == SEG_BSS);
- seg_fix_rootP = & bss_fix_root;
- seg_fix_tailP = & bss_fix_tail;
- }
+ if (seg == SEG_DATA)
+ {
+ seg_fix_rootP = &data_fix_root;
+ seg_fix_tailP = &data_fix_tail;
+ }
+ else if (seg == SEG_TEXT)
+ {
+ seg_fix_rootP = &text_fix_root;
+ seg_fix_tailP = &text_fix_tail;
+ }
+ else
+ {
+ know (seg == SEG_BSS);
+ seg_fix_rootP = &bss_fix_root;
+ seg_fix_tailP = &bss_fix_tail;
+ }
+
+#endif
#endif
}
\f
+static void
+subseg_set_rest (seg, subseg)
+ segT seg;
+ subsegT subseg;
+{
+ long tmp; /* JF for obstack alignment hacking */
+ register frchainS *frcP; /* crawl frchain chain */
+ register frchainS **lastPP; /* address of last pointer */
+ frchainS *newP; /* address of new frchain */
+ register fragS *former_last_fragP;
+ register fragS *new_fragP;
+
+ if (frag_now) /* If not bootstrapping. */
+ {
+ frag_now->fr_fix = (char*) obstack_next_free (&frags) - frag_now->fr_literal;
+ frag_wane (frag_now); /* Close off any frag in old subseg. */
+ }
+ /*
+ * It would be nice to keep an obstack for each subsegment, if we swap
+ * subsegments a lot. Hence we would have much fewer frag_wanes().
+ */
+ {
+ obstack_finish (&frags);
+ /*
+ * If we don't do the above, the next object we put on obstack frags
+ * will appear to start at the fr_literal of the current frag.
+ * Also, above ensures that the next object will begin on a
+ * address that is aligned correctly for the engine that runs
+ * this program.
+ */
+ }
+ subseg_change (seg, (int) subseg);
+ /*
+ * Attempt to find or make a frchain for that sub seg.
+ * Crawl along chain of frchainSs, begins @ frchain_root.
+ * If we need to make a frchainS, link it into correct
+ * position of chain rooted in frchain_root.
+ */
+ for (frcP = *(lastPP = &frchain_root);
+ frcP && (int) (frcP->frch_seg) <= (int) seg;
+ frcP = *(lastPP = &frcP->frch_next))
+ {
+ if ((int) (frcP->frch_seg) == (int) seg
+ && frcP->frch_subseg >= subseg)
+ {
+ break;
+ }
+ }
+ /*
+ * frcP: Address of the 1st frchainS in correct segment with
+ * frch_subseg >= subseg.
+ * We want to either use this frchainS, or we want
+ * to insert a new frchainS just before it.
+ *
+ * If frcP==NULL, then we are at the end of the chain
+ * of frchainS-s. A NULL frcP means we fell off the end
+ * of the chain looking for a
+ * frch_subseg >= subseg, so we
+ * must make a new frchainS.
+ *
+ * If we ever maintain a pointer to
+ * the last frchainS in the chain, we change that pointer
+ * ONLY when frcP==NULL.
+ *
+ * lastPP: Address of the pointer with value frcP;
+ * Never NULL.
+ * May point to frchain_root.
+ *
+ */
+ if (!frcP
+ || ((int) (frcP->frch_seg) > (int) seg
+ || frcP->frch_subseg > subseg)) /* Kinky logic only works with 2 segments. */
+ {
+ /*
+ * This should be the only code that creates a frchainS.
+ */
+ newP = (frchainS *) obstack_alloc (&frags, sizeof (frchainS));
+ memset (newP, sizeof (frchainS), 0);
+ /* This begines on a good boundary because a obstack_done()
+ preceeded it. It implies an obstack_done(), so we expect
+ the next object allocated to begin on a correct boundary. */
+ *lastPP = newP;
+ newP->frch_next = frcP; /* perhaps NULL */
+ (frcP = newP)->frch_subseg = subseg;
+ newP->frch_seg = seg;
+ newP->frch_last = NULL;
+ }
+ /*
+ * Here with frcP ->ing to the frchainS for subseg.
+ */
+ frchain_now = frcP;
+ /*
+ * Make a fresh frag for the subsegment.
+ */
+ /* We expect this to happen on a correct boundary since it was
+ proceeded by a obstack_done(). */
+ tmp = obstack_alignment_mask (&frags); /* JF disable alignment */
+ obstack_alignment_mask (&frags) = 0;
+ frag_now = (fragS *) obstack_alloc (&frags, SIZEOF_STRUCT_FRAG);
+ memset (frag_now, 0, SIZEOF_STRUCT_FRAG);
+ obstack_alignment_mask (&frags) = tmp;
+ /* But we want any more chars to come immediately after the
+ structure we just made. */
+ new_fragP = frag_now;
+ new_fragP->fr_next = NULL;
+ /*
+ * Append new frag to current frchain.
+ */
+ former_last_fragP = frcP->frch_last;
+ if (former_last_fragP)
+ {
+ know (former_last_fragP->fr_next == NULL);
+ know (frchain_now->frch_root);
+ former_last_fragP->fr_next = new_fragP;
+ }
+ else
+ {
+ frcP->frch_root = new_fragP;
+ }
+ frcP->frch_last = new_fragP;
+}
+
/*
- * subseg_new()
+ * subseg_set(segT, subsegT)
*
* If you attempt to change to the current subsegment, nothing happens.
*
* Frchain_root updated if needed.
*/
-void
- subseg_new (seg, subseg) /* begin assembly for a new sub-segment */
-register segT seg; /* SEG_DATA or SEG_TEXT */
-register subsegT subseg;
+#ifndef BFD_ASSEMBLER
+
+segT
+subseg_new (segname, subseg)
+ const char *segname;
+ subsegT subseg;
{
- long tmp; /* JF for obstack alignment hacking */
-#ifndef MANY_SEGMENTS
- know(seg == SEG_DATA || seg == SEG_TEXT || seg == SEG_BSS);
-#endif
-#ifdef OBJ_AOUT
-/* If -R specifed, always put stuff into the data section */
- if (flagseen['R'])
+ int i;
+
+ for (i = 0; i < (int) SEG_MAXIMUM_ORDINAL; i++)
+ {
+ const char *s;
+
+ s = segment_name ((segT) i);
+ if (strcmp (segname, s) == 0
+ || (segname[0] == '.'
+ && strcmp (segname + 1, s) == 0))
{
- if (seg == SEG_DATA)
- {
- subseg += 1000;
- seg = SEG_TEXT;
- }
+ subseg_set ((segT) i, subseg);
+ return (segT) i;
+ }
+#ifdef obj_segment_name
+ s = obj_segment_name ((segT) i);
+ if (strcmp (segname, s) == 0
+ || (segname[0] == '.'
+ && strcmp (segname + 1, s) == 0))
+ {
+ subseg_set ((segT) i, subseg);
+ return (segT) i;
}
#endif
- if (seg != now_seg || subseg != now_subseg)
- { /* we just changed sub-segments */
- register frchainS * frcP; /* crawl frchain chain */
- register frchainS** lastPP; /* address of last pointer */
- frchainS * newP; /* address of new frchain */
- register fragS * former_last_fragP;
- register fragS * new_fragP;
-
- if (frag_now) /* If not bootstrapping. */
- {
- frag_now -> fr_fix = obstack_next_free(& frags) - frag_now -> fr_literal;
- frag_wane(frag_now); /* Close off any frag in old subseg. */
- }
- /*
- * It would be nice to keep an obstack for each subsegment, if we swap
- * subsegments a lot. Hence we would have much fewer frag_wanes().
- */
- {
-
- obstack_finish( &frags);
- /*
- * If we don't do the above, the next object we put on obstack frags
- * will appear to start at the fr_literal of the current frag.
- * Also, above ensures that the next object will begin on a
- * address that is aligned correctly for the engine that runs
- * this program.
- */
- }
- subseg_change (seg, (int)subseg);
- /*
- * Attempt to find or make a frchain for that sub seg.
- * Crawl along chain of frchainSs, begins @ frchain_root.
- * If we need to make a frchainS, link it into correct
- * position of chain rooted in frchain_root.
- */
- for (frcP = * (lastPP = & frchain_root);
- frcP
- && (int)(frcP -> frch_seg) <= (int)seg;
- frcP = * ( lastPP = & frcP -> frch_next)
- )
- {
- if ( (int)(frcP -> frch_seg) == (int)seg
- && frcP -> frch_subseg >= subseg)
- {
- break;
- }
- }
- /*
- * frcP: Address of the 1st frchainS in correct segment with
- * frch_subseg >= subseg.
- * We want to either use this frchainS, or we want
- * to insert a new frchainS just before it.
- *
- * If frcP==NULL, then we are at the end of the chain
- * of frchainS-s. A NULL frcP means we fell off the end
- * of the chain looking for a
- * frch_subseg >= subseg, so we
- * must make a new frchainS.
- *
- * If we ever maintain a pointer to
- * the last frchainS in the chain, we change that pointer
- * ONLY when frcP==NULL.
- *
- * lastPP: Address of the pointer with value frcP;
- * Never NULL.
- * May point to frchain_root.
- *
- */
- if ( ! frcP
- || ( (int)(frcP -> frch_seg) > (int)seg
- || frcP->frch_subseg > subseg)) /* Kinky logic only works with 2 segments. */
- {
- /*
- * This should be the only code that creates a frchainS.
- */
- newP=(frchainS *)obstack_alloc(&frags,sizeof(frchainS));
- memset(newP, sizeof(frchainS), 0);
- /* This begines on a good boundary */
- /* because a obstack_done() preceeded it. */
- /* It implies an obstack_done(), so we */
- /* expect the next object allocated to */
- /* begin on a correct boundary. */
- *lastPP = newP;
- newP -> frch_next = frcP; /* perhaps NULL */
- (frcP = newP) -> frch_subseg = subseg;
- newP -> frch_seg = seg;
- newP -> frch_last = NULL;
- }
- /*
- * Here with frcP ->ing to the frchainS for subseg.
- */
- frchain_now = frcP;
- /*
- * Make a fresh frag for the subsegment.
- */
- /* We expect this to happen on a correct */
- /* boundary since it was proceeded by a */
- /* obstack_done(). */
- tmp=obstack_alignment_mask(&frags); /* JF disable alignment */
- obstack_alignment_mask(&frags)=0;
- frag_now=(fragS *)obstack_alloc(&frags,SIZEOF_STRUCT_FRAG);
- obstack_alignment_mask(&frags)=tmp;
- /* know( frags . obstack_c_next_free == frag_now -> fr_literal ); */
- /* But we want any more chars to come */
- /* immediately after the structure we just made. */
- new_fragP = frag_now;
- new_fragP -> fr_next = NULL;
- /*
- * Append new frag to current frchain.
- */
- former_last_fragP = frcP -> frch_last;
- if (former_last_fragP)
- {
- know( former_last_fragP -> fr_next == NULL );
- know( frchain_now -> frch_root );
- former_last_fragP -> fr_next = new_fragP;
- }
- else
- {
- frcP -> frch_root = new_fragP;
- }
- frcP -> frch_last = new_fragP;
- } /* if (changing subsegments) */
-} /* subseg_new() */
+ }
-/*
- * Local Variables:
- * comment-column: 0
- * fill-column: 131
- * End:
- */
+#ifdef obj_add_segment
+ {
+ segT new_seg;
+ new_seg = obj_add_segment (segname);
+ subseg_set (new_seg, subseg);
+ return new_seg;
+ }
+#else
+ as_bad ("Attempt to switch to nonexistent segment \"%s\"", segname);
+ return now_seg;
+#endif
+}
+
+void
+subseg_set (seg, subseg) /* begin assembly for a new sub-segment */
+ register segT seg; /* SEG_DATA or SEG_TEXT */
+ register subsegT subseg;
+{
+#ifndef MANY_SEGMENTS
+ know (seg == SEG_DATA || seg == SEG_TEXT || seg == SEG_BSS);
+#endif
+
+ if (seg != now_seg || subseg != now_subseg)
+ { /* we just changed sub-segments */
+ subseg_set_rest (seg, subseg);
+ }
+}
+
+#else /* BFD_ASSEMBLER */
+
+segT
+subseg_new (segname, subseg)
+ const char *segname;
+ subsegT subseg;
+{
+ segT secptr;
+ segment_info_type *seginfo;
+ const char *now_seg_name = (now_seg
+ ? bfd_get_section_name (stdoutput, now_seg)
+ : 0);
+
+ if (now_seg_name
+ && (now_seg_name == segname
+ || !strcmp (now_seg_name, segname))
+ && subseg == now_subseg)
+ return now_seg;
+
+ secptr = bfd_make_section_old_way (stdoutput, segname);
+ seginfo = seg_info (secptr);
+ if (! seginfo)
+ {
+ secptr->output_section = secptr;
+ seginfo = (segment_info_type *) xmalloc (sizeof (*seginfo));
+ seginfo->fix_root = 0;
+ seginfo->fix_tail = 0;
+ seginfo->bfd_section = secptr;
+ bfd_set_section_userdata (stdoutput, secptr, (char *) seginfo);
+ subseg_set_rest (secptr, subseg);
+ seginfo->frchainP = frchain_now;
+ seginfo->lineno_list_head = seginfo->lineno_list_tail = 0;
+ seginfo->sym = 0;
+ seginfo->dot = 0;
+ seginfo->hadone = 0;
+ seginfo->user_stuff = 0;
+ }
+ else
+ subseg_set_rest (secptr, subseg);
+ return secptr;
+}
+
+void
+subseg_set (secptr, subseg)
+ segT secptr;
+ subsegT subseg;
+{
+ if (! (secptr == now_seg && subseg == now_subseg))
+ subseg_set_rest (secptr, subseg);
+}
+
+#endif /* BFD_ASSEMBLER */
/* end of subsegs.c */
*/
symbolS *
-symbol_new (name, segment, value, frag)
+symbol_new (name, segment, valu, frag)
CONST char *name; /* It is copied, the caller can destroy/modify */
segT segment; /* Segment identifier (SEG_<something>) */
- valueT value; /* Symbol value */
+ valueT valu; /* Symbol value */
fragS *frag; /* Associated fragment */
{
unsigned int name_length;
S_SET_NAME (symbolP, preserved_copy_of_name);
S_SET_SEGMENT (symbolP, segment);
- S_SET_VALUE (symbolP, value);
+ S_SET_VALUE (symbolP, valu);
symbol_clear_list_pointers(symbolP);
symbolP->sy_frag = frag;
symbol_table_insert (symbolP)
symbolS *symbolP;
{
- register char *error_string;
+ register const char *error_string;
know (symbolP);
know (S_GET_NAME (symbolP));
- if (*(error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (char *) symbolP)))
+ if (*(error_string = hash_jam (sy_hash, S_GET_NAME (symbolP), (PTR) symbolP)))
{
as_fatal ("Inserting \"%s\" into symbol table failed: %s",
S_GET_NAME (symbolP), error_string);
know (symbolP->sy_next->sy_previous == symbolP);
#else
/* Walk the list anyways, to make sure pointers are still good. */
- *symbolP;
+ ;
#endif /* SYMBOLS_NEED_BACKPOINTERS */
}
static long *dollar_label_instances;
static char *dollar_label_defines;
static long dollar_label_count;
-static long dollar_label_max;
+static unsigned long dollar_label_max;
int
dollar_label_defined (label)
void
dollar_label_clear ()
{
- memset (dollar_label_defines, '\0', dollar_label_count);
+ memset (dollar_label_defines, '\0', (unsigned int) dollar_label_count);
}
#define DOLLAR_LABEL_BUMP_BY 10
void append PARAMS ((char **charPP, char *fromP, unsigned long length));
void record_alignment PARAMS ((segT seg, int align));
void write_object_file PARAMS ((void));
+void relax_segment PARAMS ((struct frag * seg_frag_root, segT seg_type));
#ifdef BFD_ASSEMBLER
fixS *fix_new PARAMS ((fragS * frag, int where, int size,
- symbolS * add_symbol, symbolS * sub_symbol,
- offsetT offset, int pcrel,
+ symbolS * add_symbol, offsetT offset, int pcrel,
bfd_reloc_code_real_type r_type));
+fixS *fix_new_exp PARAMS ((fragS * frag, int where, int size,
+ expressionS *exp, int pcrel,
+ bfd_reloc_code_real_type r_type));
#else
fixS *fix_new PARAMS ((fragS * frag, int where, int size,
- symbolS * add_symbol, symbolS * sub_symbol,
- long offset, int pcrel, int r_type));
+ symbolS * add_symbol, offsetT offset, int pcrel,
+ int r_type));
+fixS *fix_new_exp PARAMS ((fragS * frag, int where, int size,
+ expressionS *exp, int pcrel, int r_type));
#endif
/* end of write.h */