From: Ken Raeburn Date: Tue, 20 Dec 1994 22:42:03 +0000 (+0000) Subject: * frags.c (frag_init): Call obstack_begin on `frags'. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=87e48495014d9a1d075e7c99aeb9cb29daccc796;p=binutils-gdb.git * 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. --- diff --git a/gas/ChangeLog b/gas/ChangeLog index 4248ae12b95..948fe61043a 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,5 +1,31 @@ Tue Dec 20 14:56:31 1994 Ken Raeburn + * 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. diff --git a/gas/as.c b/gas/as.c index 1d17186e9c3..182f78c7d40 100644 --- a/gas/as.c +++ b/gas/as.c @@ -41,20 +41,6 @@ #include "subsegs.h" #include "output-file.h" -#include - -#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 */ @@ -373,20 +359,11 @@ main (argc, argv) 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 @@ -397,13 +374,17 @@ main (argc, argv) 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); @@ -413,6 +394,8 @@ main (argc, argv) tc_init_after_args (); #endif + PROGRESS (1); + perform_an_assembly_pass (argc, argv); /* Assemble it. */ #ifdef TC_I960 brtab_emit (); @@ -452,6 +435,8 @@ main (argc, argv) md_end (); #endif + END_PROGRESS (myname); + if (flag_print_statistics) { extern char **environ; @@ -563,6 +548,7 @@ perform_an_assembly_pass (argc, argv) { if (*argv) { /* Is it a file-name argument? */ + PROGRESS (1); saw_a_file++; /* argv->"" if stdin desired, else->filename */ read_a_source_file (*argv); @@ -572,22 +558,5 @@ perform_an_assembly_pass (argc, argv) if (!saw_a_file) read_a_source_file (""); } /* perform_an_assembly_pass() */ - -#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 */ diff --git a/gas/as.h b/gas/as.h index 5c2248880ec..0ed73b7eb1c 100644 --- a/gas/as.h +++ b/gas/as.h @@ -37,11 +37,16 @@ #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 @@ -114,11 +119,8 @@ extern char *strdup (/* const char * */); #include #endif -#ifdef WANT_FOPEN_BIN -#include "fopen-bin.h" -#else -#include "fopen-same.h" -#endif +/* Define the standard progress macros. */ +#include /* This doesn't get taken care of anywhere. */ #if !defined (__GNUC__) && !defined (inline) @@ -126,17 +128,20 @@ extern char *strdup (/* const char * */); #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 @@ -398,6 +403,13 @@ struct frag 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 @@ -421,7 +433,7 @@ typedef struct frag fragS; 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; @@ -488,8 +500,20 @@ struct lineno_struct 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, ...) \ @@ -498,11 +522,12 @@ typedef struct lineno_struct lineno; 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 diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c index b263fe3394f..3b62c52fb0b 100644 --- a/gas/config/obj-coff.c +++ b/gas/config/obj-coff.c @@ -1912,8 +1912,7 @@ obj_coff_ln (appline) } /* 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; diff --git a/gas/config/obj-vms.c b/gas/config/obj-vms.c index 3a292594279..48e8a97e73f 100644 --- a/gas/config/obj-vms.c +++ b/gas/config/obj-vms.c @@ -355,8 +355,8 @@ vms_resolve_symbol_redef (sym) * 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)); @@ -373,7 +373,7 @@ vms_resolve_symbol_redef (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; diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index ca7024bd5f0..f377859aa12 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -6861,7 +6861,7 @@ s_loc (x) 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); diff --git a/gas/subsegs.h b/gas/subsegs.h index 0b65c0f9d53..2d3a100cb5d 100644 --- a/gas/subsegs.h +++ b/gas/subsegs.h @@ -1,6 +1,6 @@ /* 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. @@ -44,6 +44,11 @@ struct frchain /* control building of a frag chain */ 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; @@ -69,8 +74,12 @@ typedef struct 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 @@ -104,8 +113,7 @@ typedef struct #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 */ diff --git a/gas/symbols.c b/gas/symbols.c index a3e3eb5e69b..c46876f6647 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -117,7 +117,7 @@ symbol_create (name, segment, valu, frag) #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); @@ -220,7 +220,7 @@ colon (sym_name) /* just seen "x:" - rattle symbols & frags */ #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); @@ -297,7 +297,7 @@ colon (sym_name) /* just seen "x:" - rattle symbols & frags */ { /* 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 */ @@ -305,9 +305,7 @@ colon (sym_name) /* just seen "x:" - rattle symbols & frags */ } 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); @@ -621,8 +619,12 @@ resolve_symbol_value (symp) 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); @@ -1364,6 +1366,14 @@ print_symbol_value_1 (file, sym) 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) {