* subsegs.c (subsegs_begin): Don't do it here.
* as.c (main): Call frag_init before subsegs_begin.
* frags.c (frag_append_1_char): New function.
* frags.h (frag_append_1_char): Declare it.
(FRAG_APPEND_1_CHAR): Call it. Old definition is commented out for now.
* as.h (struct frag): Added (but commented out) new fields for tracking current
alignment.
(frag_now_fix): Changed macro to function declaration.
* frags.c (frag_now_fix): Define function here.
(frag_new): Use it instead of accessing `frags' directly.
* frags.h (frags): Change comment to indicate it shouldn't be accessed directly.
* subsegs.h (struct frchain): New field frch_obstack, intended to eventually
replace global `frags' obstack.
* subsegs.c (subseg_set_rest): Use frag_now_fix instead of accessing `frags'
directly. Initialize fields of new frchainS explicitly instead of with memset.
* config/obj-coff.c (obj_coff_ln) [!BFD_ASSEMBLER]: Use frag_now_fix.
* config/tc-mips.c (s_loc), config/obj-vms.c (vms_resolve_symbol_redef),
symbols.c (colon): Likewise.
Tue Dec 20 14:56:31 1994 Ken Raeburn <raeburn@cujo.cygnus.com>
+ * frags.c (frag_init): Call obstack_begin on `frags'.
+ * subsegs.c (subsegs_begin): Don't do it here.
+ * as.c (main): Call frag_init before subsegs_begin.
+
+ * frags.c (frag_append_1_char): New function.
+ * frags.h (frag_append_1_char): Declare it.
+ (FRAG_APPEND_1_CHAR): Call it. Old definition is commented out
+ for now.
+
+ * as.h (struct frag): Added (but commented out) new fields for
+ tracking current alignment.
+ (frag_now_fix): Changed macro to function declaration.
+ * frags.c (frag_now_fix): Define function here.
+ (frag_new): Use it instead of accessing `frags' directly.
+ * frags.h (frags): Change comment to indicate it shouldn't be
+ accessed directly.
+ * subsegs.h (struct frchain): New field frch_obstack, intended to
+ eventually replace global `frags' obstack.
+ * subsegs.c (subseg_set_rest): Use frag_now_fix instead of
+ accessing `frags' directly. Initialize fields of new frchainS
+ explicitly instead of with memset.
+ * config/obj-coff.c (obj_coff_ln) [!BFD_ASSEMBLER]: Use
+ frag_now_fix.
+ * config/tc-mips.c (s_loc), config/obj-vms.c
+ (vms_resolve_symbol_redef), symbols.c (colon): Likewise.
+
* config/tc-m68k.c (md_apply_fix_2): Use offsetT and addressT
instead of long and unsigned long.
(md_apply_fix): Cast value before passing it.
#include "subsegs.h"
#include "output-file.h"
-#include <signal.h>
-
-#ifndef SIGTY
-#ifdef __STDC__
-#define SIGTY void
-#else
-#define SIGTY int
-#endif /* __STDC__ */
-#endif /* SIGTY */
-
-#if 0
-/* Not currently used. */
-static SIGTY got_sig PARAMS ((int sig));
-#endif
static void perform_an_assembly_pass PARAMS ((int argc, char **argv));
int listing; /* true if a listing is wanted */
HOST_SPECIAL_INIT (argc, argv);
#endif
-#if 0 /* do we need any of this?? */
- {
- static const int sig[] = {SIGHUP, SIGINT, SIGPIPE, SIGTERM, 0};
- int a;
-
- for (a = 0; sig[a] != 0; a++)
- if (signal (sig[a], SIG_IGN) != SIG_IGN)
- signal (sig[a], got_sig);
- }
-#endif
-
myname = argv[0];
xmalloc_set_program_name (myname);
+ START_PROGRESS (myname, 0);
+
#ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME
#define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out"
#endif
bfd_init ();
#endif
+ PROGRESS (1);
symbol_begin ();
+ frag_init ();
subsegs_begin ();
read_begin ();
input_scrub_begin ();
- frag_init ();
+ PROGRESS (1);
parse_args (&argc, &argv);
+ PROGRESS (1);
+
#ifdef BFD_ASSEMBLER
output_file_create (out_file_name);
assert (stdoutput != 0);
tc_init_after_args ();
#endif
+ PROGRESS (1);
+
perform_an_assembly_pass (argc, argv); /* Assemble it. */
#ifdef TC_I960
brtab_emit ();
md_end ();
#endif
+ END_PROGRESS (myname);
+
if (flag_print_statistics)
{
extern char **environ;
{
if (*argv)
{ /* Is it a file-name argument? */
+ PROGRESS (1);
saw_a_file++;
/* argv->"" if stdin desired, else->filename */
read_a_source_file (*argv);
if (!saw_a_file)
read_a_source_file ("");
} /* perform_an_assembly_pass() */
-\f
-#if 0
-/* This is not currently used. */
-static SIGTY
-got_sig (sig)
- int sig;
-{
- static here_before = 0;
-
- as_bad ("Interrupted by signal %d", sig);
- if (here_before++)
- exit (EXIT_FAILURE);
-#if 0 /* If SIGTY is void, this produces warnings. */
- return ((SIGTY) 0);
-#endif
-}
-#endif
/* end of as.c */
#include "config.h"
-/* This is the code recommended in the autoconf documentation --
+/* This is the code recommended in the autoconf documentation, almost
verbatim. If it doesn't work for you, let me know, and notify
djm@gnu.ai.mit.edu as well. */
+/* Added #undef for DJ Delorie. The right fix is to ensure that as.h
+ is included first, before even any system header files, in all files
+ that use it. KR 1994.11.03 */
+
/* AIX requires this to be the first thing in the file. */
#ifdef __GNUC__
+# undef alloca
# define alloca __builtin_alloca
#else
# if HAVE_ALLOCA_H
#include <bfd.h>
#endif
-#ifdef WANT_FOPEN_BIN
-#include "fopen-bin.h"
-#else
-#include "fopen-same.h"
-#endif
+/* Define the standard progress macros. */
+#include <progress.h>
/* This doesn't get taken care of anywhere. */
#if !defined (__GNUC__) && !defined (inline)
#endif
/* Other stuff from config.h. */
-#ifdef NEED_MALLOC_DECLARATION
+#ifdef NEED_DECLARATION_MALLOC
extern PTR malloc ();
extern PTR realloc ();
#endif
-#ifdef NEED_FREE_DECLARATION
+#ifdef NEED_DECLARATION_FREE
extern void free ();
#endif
+#ifdef NEED_DECLARATION_ERRNO
+extern int errno;
+#endif
/* This is needed for VMS. */
-#if ! defined (HAVE_UNLINK) && defined (HAVE_DELETE)
-#define unlink delete
+#if ! defined (HAVE_UNLINK) && defined (HAVE_REMOVE)
+#define unlink remove
#endif
#ifdef BFD_ASSEMBLER
relax_stateT fr_type;
relax_substateT fr_subtype;
+#if 0 /* not yet */
+ /* Track the alignment and offset of the current frag. With this,
+ sometimes we can avoid creating new frags for .align directives. */
+ unsigned short align_mask;
+ unsigned short align_offset;
+#endif
+
/* These are needed only on the NS32K machines. But since we don't
include targ-cpu.h until after this structure has been defined,
we can't really conditionalize it. This code should be
included in frchain_now. The fr_fix field is bogus; instead, use:
obstack_next_free(&frags)-frag_now->fr_literal. */
COMMON fragS *frag_now;
-#define frag_now_fix() ((char*)obstack_next_free (&frags) - frag_now->fr_literal)
+extern int frag_now_fix ();
/* For foreign-segment symbol fixups. */
COMMON fragS zero_address_frag;
typedef struct lineno_struct lineno;
#endif
-#if defined (__STDC__) && !defined(NO_STDARG)
+/* Prefer varargs for non-ANSI compiler, since some will barf if the
+ ellipsis definition is used with a no-arguments declaration. */
+#if defined (HAVE_VARARGS_H) && !defined (__STDC__)
+#undef HAVE_STDARG_H
+#endif
+
+#if defined (HAVE_STDARG_H)
+#define USE_STDARG
+#endif
+#if !defined (USE_STDARG) && defined (HAVE_VARARGS_H)
+#define USE_VARARGS
+#endif
+#ifdef USE_STDARG
#if __GNUC__ >= 2
/* for use with -Wformat */
#define PRINTF_LIKE(FCN) void FCN (const char *format, ...) \
const char *format, ...) \
__attribute__ ((format (printf, 3, 4)))
#else /* ANSI C with stdarg, but not GNU C */
-#define PRINTF_LIKE(FCN) void FCN (const char *format, ...)
-#define PRINTF_WHERE_LIKE(FCN) void FCN (char *file, unsigned int line, \
- const char *format, ...)
+#define PRINTF_LIKE(FCN) void FCN PARAMS ((const char *format, ...))
+#define PRINTF_WHERE_LIKE(FCN) void FCN PARAMS ((char *file, \
+ unsigned int line, \
+ const char *format, ...))
#endif
-#else /* not ANSI C, or not stdarg */
+#else /* not using stdarg */
#define PRINTF_LIKE(FCN) void FCN ()
#define PRINTF_WHERE_LIKE(FCN) void FCN ()
#endif
} /* wrong context */
l = get_absolute_expression ();
- c_line_new (0, obstack_next_free (&frags) - frag_now->fr_literal, l,
- frag_now);
+ c_line_new (0, frag_now_fix (), l, frag_now);
#ifndef NO_LISTING
{
extern int listing;
* If the new symbol is .comm AND it has a size of zero,
* we ignore it (i.e. the old symbol overrides it)
*/
- if ((SEGMENT_TO_SYMBOL_TYPE ((int) now_seg) == (N_UNDF | N_EXT)) &&
- ((obstack_next_free (&frags) - frag_now->fr_literal) == 0))
+ if (SEGMENT_TO_SYMBOL_TYPE ((int) now_seg) == (N_UNDF | N_EXT)
+ && frag_now_fix () == 0)
{
as_warn ("compiler emitted zero-size common symbol `%s' already defined",
S_GET_NAME (sym));
S_GET_NAME (sym));
sym->sy_frag = frag_now;
S_SET_OTHER(sym, const_flag);
- S_SET_VALUE(sym, obstack_next_free(& frags) - frag_now->fr_literal);
+ S_SET_VALUE(sym, frag_now_fix ());
/* Keep N_EXT bit. */
sym->sy_symbol.n_type |= SEGMENT_TO_SYMBOL_TYPE((int) now_seg);
return 1;
assert (now_seg == text_section);
lineno = get_number ();
- addroff = obstack_next_free (&frags) - frag_now->fr_literal;
+ addroff = frag_now_fix ();
symbolP = symbol_new ("", N_SLINE, addroff, frag_now);
S_SET_TYPE (symbolP, N_SLINE);
/* subsegs.h -> subsegs.c
- Copyright (C) 1987, 1992 Free Software Foundation, Inc.
+ Copyright (C) 1987, 1992, 1993, 1994 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
struct frchain *frch_next; /* next in chain of struct frchain-s */
segT frch_seg; /* SEG_TEXT or SEG_DATA. */
subsegT frch_subseg; /* subsegment number of this chain */
+#ifdef BFD_ASSEMBLER
+ fixS *fix_root; /* Root of fixups for this subsegment. */
+ fixS *fix_tail; /* Last fixup for this subsegment. */
+#endif
+ struct obstack frch_obstack; /* for objects in this frag chain */
};
typedef struct frchain frchainS;
int bss : 1;
int user_stuff;
+
+ /* Fixups for this segment. If BFD_ASSEMBLER, this is only valid
+ after the frchains are run together. */
fixS *fix_root;
fixS *fix_tail;
+
#if defined (MANY_SEGMENTS) && !defined (BFD_ASSEMBLER)
struct internal_scnhdr scnhdr;
#endif
#ifdef BFD_ASSEMBLER
-#define seg_info(SEC) \
- ((segment_info_type *) bfd_get_section_userdata (stdoutput, (SEC)))
+extern segment_info_type *seg_info PARAMS ((segT));
extern symbolS *section_symbol PARAMS ((segT));
#else /* ! BFD_ASSEMBLER */
#ifdef BFD_ASSEMBLER
symbolP->bsym = bfd_make_empty_symbol (stdoutput);
assert (symbolP->bsym != 0);
- symbolP->bsym->udata = (PTR) symbolP;
+ symbolP->bsym->udata.p = (PTR) symbolP;
#endif
S_SET_NAME (symbolP, preserved_copy_of_name);
#ifdef OBJ_VMS
S_GET_OTHER(symbolP) = const_flag;
#endif
- S_SET_VALUE (symbolP, (valueT) ((char*)obstack_next_free (&frags) - frag_now->fr_literal));
+ S_SET_VALUE (symbolP, (valueT) frag_now_fix ());
S_SET_SEGMENT (symbolP, now_seg);
#ifdef N_UNDF
know (N_UNDF == 0);
{
/* Don't blow up if the definition is the same */
if (!(frag_now == symbolP->sy_frag
- && S_GET_VALUE (symbolP) == (char*)obstack_next_free (&frags) - frag_now->fr_literal
+ && S_GET_VALUE (symbolP) == frag_now_fix ()
&& S_GET_SEGMENT (symbolP) == now_seg))
as_fatal ("Symbol %s already defined.", sym_name);
} /* if this symbol is not yet defined */
}
else
{
- symbolP = symbol_new (sym_name,
- now_seg,
- (valueT) ((char*)obstack_next_free (&frags) - frag_now->fr_literal),
+ symbolP = symbol_new (sym_name, now_seg, (valueT) frag_now_fix (),
frag_now);
#ifdef OBJ_VMS
S_SET_OTHER (symbolP, const_flag);
case O_symbol:
resolve_symbol_value (symp->sy_value.X_add_symbol);
+#if 0 /* I thought this was needed for some of the i386-svr4 PIC
+ support, but it appears I was wrong, and it breaks rs6000
+ support. */
if (S_GET_SEGMENT (symp->sy_value.X_add_symbol) != undefined_section
&& S_GET_SEGMENT (symp->sy_value.X_add_symbol) != expr_section)
+#endif
{
if (symp->sy_value.X_add_number == 0)
copy_symbol_attributes (symp, symp->sy_value.X_add_symbol);
fprintf (file, " used-in-reloc");
if (sym->sy_used)
fprintf (file, " used");
+ if (S_IS_LOCAL (sym))
+ fprintf (file, " local");
+ if (S_IS_EXTERN (sym))
+ fprintf (file, " extern");
+ if (S_IS_DEBUG (sym))
+ fprintf (file, " debug");
+ if (S_IS_DEFINED (sym))
+ fprintf (file, " defined");
fprintf (file, " %s", segment_name (S_GET_SEGMENT (sym)));
if (sym->sy_resolved)
{