#include "obstack.h"
#include "subsegs.h"
-#ifdef BFD_ASSEMBLER
-
-static symbolS *tag_find_or_make PARAMS ((char *name));
-static symbolS *tag_find PARAMS ((char *name));
-static void tag_init PARAMS ((void));
-static void tag_insert PARAMS ((const char *name, symbolS * symbolP));
const char *s_get_name PARAMS ((symbolS * s));
-
-static void obj_coff_def PARAMS ((int));
-static void obj_coff_dim 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));
-
-static void SA_SET_SYM_TAGNDX PARAMS ((symbolS *, symbolS *));
-
-static struct hash_control *tag_hash;
static symbolS *def_symbol_in_progress;
-const pseudo_typeS obj_pseudo_table[] =
-{
- {"def", obj_coff_def, 0},
- {"dim", obj_coff_dim, 0},
- {"endef", obj_coff_endef, 0},
- {"line", obj_coff_line, 0},
- {"ln", obj_coff_ln, 0},
- {"appline", obj_coff_ln, 1},
- {"scl", obj_coff_scl, 0},
- {"size", obj_coff_size, 0},
- {"tag", obj_coff_tag, 0},
- {"type", obj_coff_type, 0},
- {"val", obj_coff_val, 0},
- { "section", obj_coff_section, 0 },
- {"ident", s_ignore, 0}, /* we don't yet handle this. */
- {"optim", s_ignore, 0}, /* For sun386i cc (?) */
- /* other stuff */
- {"ABORT", s_abort, 0},
-
- {NULL} /* end sentinel */
-}; /* obj_pseudo_table */
\f
/* stack stuff */
typedef struct
return st;
}
+#if 0
+/* Not currently used. */
static void
stack_delete (st)
stack *st;
free (st->data);
free (st);
}
+#endif
static char *
stack_push (st, element)
* Maintain a list of the tagnames of the structres.
*/
+static struct hash_control *tag_hash;
+
static void
tag_init ()
{
}
}
+static symbolS *
+tag_find (name)
+ char *name;
+{
+#ifdef STRIP_UNDERSCORE
+ if (*name == '_')
+ name++;
+#endif /* STRIP_UNDERSCORE */
+ return (symbolS *) hash_find (tag_hash, name);
+}
+
static symbolS *
tag_find_or_make (name)
char *name;
0, &zero_address_frag);
tag_insert (S_GET_NAME (symbolP), symbolP);
+#ifdef BFD_ASSEMBLER
symbol_table_insert (symbolP);
+#endif
} /* not found */
return symbolP;
}
-static symbolS *
-tag_find (name)
- char *name;
-{
-#ifdef STRIP_UNDERSCORE
- if (*name == '_')
- name++;
-#endif /* STRIP_UNDERSCORE */
- return (symbolS *) hash_find (tag_hash, name);
-}
-\f
+
+
+#ifdef BFD_ASSEMBLER
+
+static void SA_SET_SYM_TAGNDX PARAMS ((symbolS *, symbolS *));
+
struct line_no {
struct line_no *next;
fragS *frag;
}
else if (S_GET_STORAGE_CLASS (symp) == C_NULL)
{
- if (S_GET_SEGMENT (symp) == text_section)
+ if (S_GET_SEGMENT (symp) == text_section
+ && symp != seg_info (text_section)->sym)
S_SET_STORAGE_CLASS (symp, C_LABEL);
else
S_SET_STORAGE_CLASS (symp, C_STAT);
#define NOP_OPCODE 0x00
#endif
+/* The zeroes if symbol name is longer than 8 chars */
+#define S_SET_ZEROES(s,v) ((s)->sy_symbol.ost_entry.n_zeroes = (v))
+
#define MIN(a,b) ((a) < (b)? (a) : (b))
/* This vector is used to turn an internal segment into a section #
suitable for insertion into a coff symbol table
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;
+static symbolS *previous_file_symbol;
void c_symbol_merge ();
static int line_base;
unsigned long *));
-static symbolS *tag_find_or_make PARAMS ((char *name));
-static symbolS *tag_find PARAMS ((char *name));
-static void tag_init PARAMS ((void));
-static void tag_insert PARAMS ((char *name, symbolS * symbolP));
-char *s_get_name PARAMS ((symbolS * s));
-
static int c_line_new PARAMS ((symbolS * symbol, long paddr,
- unsigned short line_number,
+ int line_number,
fragS * frag));
static void adjust_stab_section PARAMS ((bfd *abfd, segT seg));
-static struct hash_control *tag_hash;
-
-static symbolS *def_symbol_in_progress = NULL;
-
-static void obj_coff_def PARAMS ((int));
-static void obj_coff_dim 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));
static void obj_coff_lcomm PARAMS ((int));
static void obj_coff_text PARAMS ((int));
static void obj_coff_data PARAMS ((int));
static void obj_coff_ident PARAMS ((int));
void obj_coff_section PARAMS ((int));
-const pseudo_typeS obj_pseudo_table[] =
-{
- {"def", obj_coff_def, 0},
- {"dim", obj_coff_dim, 0},
- {"endef", obj_coff_endef, 0},
- {"line", obj_coff_line, 0},
- {"ln", obj_coff_ln, 0},
- {"appline", obj_coff_ln, 1},
- {"scl", obj_coff_scl, 0},
- {"size", obj_coff_size, 0},
- {"tag", obj_coff_tag, 0},
- {"type", obj_coff_type, 0},
- {"val", obj_coff_val, 0},
- {"section", obj_coff_section, 0},
- {"use", obj_coff_section, 0},
- {"sect", obj_coff_section, 0},
- {"text", obj_coff_text, 0},
- {"data", obj_coff_data, 0},
- {"bss", obj_coff_bss, 0},
- {"ident", obj_coff_ident, 0},
- {"ABORT", s_abort, 0},
- {"lcomm", obj_coff_lcomm, 0},
-#ifdef TC_M88K
- /* The m88k uses sdef instead of def. */
- {"sdef", obj_coff_def, 0},
-#endif
- {NULL} /* end sentinel */
-}; /* obj_pseudo_table */
-\f
-/* stack stuff */
-typedef struct
- {
- unsigned long chunk_size;
- unsigned long element_size;
- unsigned long size;
- char *data;
- unsigned long pointer;
- }
-stack;
-
-static stack *
-stack_init (chunk_size, element_size)
- unsigned long chunk_size;
- unsigned long element_size;
-{
- stack *st;
-
- st = (stack *) malloc (sizeof (stack));
- if (!st)
- return 0;
- st->data = malloc (chunk_size);
- if (!st->data)
- {
- free (st);
- return 0;
- }
- st->pointer = 0;
- st->size = chunk_size;
- st->chunk_size = chunk_size;
- st->element_size = element_size;
- return st;
-}
-
-static void
-stack_delete (st)
- stack *st;
-{
- free (st->data);
- free (st);
-}
-
-static char *
-stack_push (st, element)
- stack *st;
- char *element;
-{
- if (st->pointer + st->element_size >= st->size)
- {
- st->size += st->chunk_size;
- if ((st->data = xrealloc (st->data, st->size)) == (char *) 0)
- return (char *) 0;
- }
- memcpy (st->data + st->pointer, element, st->element_size);
- st->pointer += st->element_size;
- return st->data + st->pointer;
-}
-
-static char *
-stack_pop (st)
- stack *st;
-{
- if (st->pointer < st->element_size)
- {
- st->pointer = 0;
- return (char *) 0;
- }
- st->pointer -= st->element_size;
- return st->data + st->pointer;
-}
-\f
-/*
- * Maintain a list of the tagnames of the structres.
- */
-
-static void
-tag_init ()
-{
- tag_hash = hash_new ();
-}
-
-static void
-tag_insert (name, symbolP)
- char *name;
- symbolS *symbolP;
-{
- const 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);
- }
-}
-
-static symbolS *
-tag_find_or_make (name)
- char *name;
-{
- symbolS *symbolP;
-
- if ((symbolP = tag_find (name)) == NULL)
- {
- symbolP = symbol_new (name, undefined_section,
- 0, &zero_address_frag);
-
- tag_insert (S_GET_NAME (symbolP), symbolP);
- } /* not found */
-
- return symbolP;
-}
-
-static symbolS *
-tag_find (name)
- char *name;
-{
-#ifdef STRIP_UNDERSCORE
- if (*name == '_')
- name++;
-#endif /* STRIP_UNDERSCORE */
- return (symbolS *) hash_find (tag_hash, name);
-}
-\f
/* Section stuff
We allow more than just the standard 3 sections, infact, we allow
int i;
} seg_info_type;
-seg_info_type seg_info_off_by_4[N_SEG] =
+static const seg_info_type seg_info_off_by_4[N_SEG] =
{
{SEG_PTV, },
{SEG_NTV, },
#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)])
-
static relax_addressT
relax_align (address, alignment)
mask = ~((~0) << alignment);
new_address = (address + mask) & (~mask);
return (new_address - address);
-} /* relax_align() */
+}
segT
size = frag->fr_address;
if (frag->fr_address != size)
{
- printf ("Out of step\n");
+ fprintf (stderr, "Out of step\n");
size = frag->fr_address;
}
externals onto another chain */
/* The chain of externals */
-symbolS *symbol_externP = NULL;
-symbolS *symbol_extern_lastP = NULL;
+symbolS *symbol_externP;
+symbolS *symbol_extern_lastP;
stack *block_stack;
-symbolS *last_functionP = NULL;
+symbolS *last_functionP;
symbolS *last_tagP;
static unsigned int
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 */
+ /* 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_set (frchain_ptr->frch_seg, frchain_ptr->frch_subseg);
#ifndef SUB_SEGMENT_ALIGN
size = size_section (abfd, (unsigned int) i);
addr += size;
+ /* I think the section alignment is only used on the i960; the
+ i960 needs it, and it should do no harm on other targets. */
+ segment_info[i].scnhdr.s_align = section_alignment[i];
+
if (i == SEG_E0)
H_SET_TEXT_SIZE (&headers, size);
else if (i == SEG_E1)
#else
H_SET_TIME_STAMP (&headers, 0);
#endif
+#ifdef TC_COFF_SET_MACHINE
+ TC_COFF_SET_MACHINE (&headers);
+#endif
#ifdef KEEP_RELOC_INFO
H_SET_FLAGS (&headers, ((H_GET_LINENO_SIZE(&headers) ? 0 : F_LNNO) |
c_line_new (symbol, paddr, line_number, frag)
symbolS * symbol;
long paddr;
- unsigned short line_number;
+ int line_number;
fragS * frag;
{
struct lineno_list *new_line =
size = fixP->fx_size;
add_symbolP = fixP->fx_addsy;
#ifdef TC_I960
- if (fixP->fx_tcbit && TC_S_IS_CALLNAME (add_symbolP))
+ if (fixP->fx_tcbit && SF_GET_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)))
+ if (!SF_GET_BALNAME (tc_get_bal_of_call (add_symbolP)))
{
- as_bad ("No 'bal' entry point for leafproc %s",
- S_GET_NAME (add_symbolP));
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ "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);
/* Its just -sym */
if (S_GET_SEGMENT (sub_symbolP) != absolute_section)
{
- as_bad ("Negative of non-absolute symbol %s", S_GET_NAME (sub_symbolP));
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ "Negative of non-absolute symbol %s",
+ S_GET_NAME (sub_symbolP));
} /* not absolute */
add_number -= S_GET_VALUE (sub_symbolP);
as the target of a call instruction. */
if (fixP->fx_tcbit)
{
- as_bad ("callj to difference of 2 symbols");
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ "callj to difference of 2 symbols");
}
#endif /* TC_I960 */
add_number += S_GET_VALUE (add_symbolP) -
#endif
else
{
- 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),
- (long) (fragP->fr_address + where));
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ "Can't emit reloc {- %s-seg symbol \"%s\"} @ file address %ld.",
+ segment_name (S_GET_SEGMENT (sub_symbolP)),
+ S_GET_NAME (sub_symbolP),
+ (long) (fragP->fr_address + where));
} /* if absolute */
}
} /* if sub_symbolP */
* for local branches: flag as error, don't generate
* relocation.
*/
- as_bad ("can't use COBR format with external label");
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ "can't use COBR format with external label");
fixP->fx_addsy = NULL;
fixP->fx_done = 1;
continue;
(size == 2 &&
(add_number & ~0xFFFF) && ((add_number & ~0xFFFF) != (-1 & ~0xFFFF))))
{
- 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));
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ "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 (!flag_signed_overflow_ok
&& size == 2
&& add_number > 0x7fff)
- as_bad ("Signed .word overflow; switch may be too large; %ld at 0x%lx",
- (long) add_number,
- (unsigned long) (fragP->fr_address + where));
+ as_bad_where (fixP->fx_file, fixP->fx_line,
+ "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
bfd_h_put_32 (abfd, (bfd_vma) strsz, (bfd_byte *) p + 8);
}
-
#endif /* not BFD_ASSEMBLER */
+
+const pseudo_typeS obj_pseudo_table[] =
+{
+ {"def", obj_coff_def, 0},
+ {"dim", obj_coff_dim, 0},
+ {"endef", obj_coff_endef, 0},
+ {"line", obj_coff_line, 0},
+ {"ln", obj_coff_ln, 0},
+ {"appline", obj_coff_ln, 1},
+ {"scl", obj_coff_scl, 0},
+ {"size", obj_coff_size, 0},
+ {"tag", obj_coff_tag, 0},
+ {"type", obj_coff_type, 0},
+ {"val", obj_coff_val, 0},
+ {"section", obj_coff_section, 0},
+#ifndef BFD_ASSEMBLER
+ {"use", obj_coff_section, 0},
+ {"sect", obj_coff_section, 0},
+ {"text", obj_coff_text, 0},
+ {"data", obj_coff_data, 0},
+ {"bss", obj_coff_bss, 0},
+ {"lcomm", obj_coff_lcomm, 0},
+ {"ident", obj_coff_ident, 0},
+#else
+ {"optim", s_ignore, 0}, /* For sun386i cc (?) */
+ {"ident", s_ignore, 0}, /* we don't yet handle this. */
+#endif
+ {"ABORT", s_abort, 0},
+#ifdef TC_M88K
+ /* The m88k uses sdef instead of def. */
+ {"sdef", obj_coff_def, 0},
+#endif
+ {NULL} /* end sentinel */
+}; /* obj_pseudo_table */