From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id E8446385B539; Mon, 13 Feb 2023 10:36:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E8446385B539 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Split off gas init to functions X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: f9767e607d7fc0063556b5f2650dd7162d5af91a X-Git-Newrev: 103357fb75c93ba8195166f65719b03aecce497e Message-Id: <20230213103625.E8446385B539@sourceware.org> Date: Mon, 13 Feb 2023 10:36:25 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Feb 2023 10:36:26 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D103357fb75c9= 3ba8195166f65719b03aecce497e commit 103357fb75c93ba8195166f65719b03aecce497e Author: Alan Modra Date: Mon Feb 13 20:24:52 2023 +1030 Split off gas init to functions =20 With some slight reordering. =20 * as.c (gas_early_init, gas_late_init): New functions, split.. (main): ..from here. Diff: --- gas/as.c | 159 ++++++++++++++++++++++++++++++++++-------------------------= ---- 1 file changed, 87 insertions(+), 72 deletions(-) diff --git a/gas/as.c b/gas/as.c index f548294c3dc..0995292d1c8 100644 --- a/gas/as.c +++ b/gas/as.c @@ -1267,14 +1267,11 @@ free_notes (void) _obstack_free (¬es, NULL); } =20 -int -main (int argc, char ** argv) -{ - char ** argv_orig =3D argv; - struct stat sob; - - int macro_strip_at; +/* Early initialisation, before gas prints messages. */ =20 +static void +gas_early_init (int *argcp, char ***argvp) +{ start_time =3D get_run_time (); signal_init (); =20 @@ -1288,17 +1285,6 @@ main (int argc, char ** argv) if (debug_memory) chunksize =3D 64; =20 -#ifdef HOST_SPECIAL_INIT - HOST_SPECIAL_INIT (argc, argv); -#endif - - myname =3D argv[0]; - xmalloc_set_program_name (myname); - - expandargv (&argc, &argv); - - START_PROGRESS (myname, 0); - #ifndef OBJ_DEFAULT_OUTPUT_FILE_NAME #define OBJ_DEFAULT_OUTPUT_FILE_NAME "a.out" #endif @@ -1308,18 +1294,95 @@ main (int argc, char ** argv) hex_init (); if (bfd_init () !=3D BFD_INIT_MAGIC) as_fatal (_("libbfd ABI mismatch")); + + obstack_begin (¬es, chunksize); + xatexit (free_notes); + + myname =3D **argvp; + xmalloc_set_program_name (myname); bfd_set_error_program_name (myname); + START_PROGRESS (myname, 0); + + expandargv (argcp, argvp); + +#ifdef HOST_SPECIAL_INIT + HOST_SPECIAL_INIT (*argcp, *argvp); +#endif =20 #ifdef USE_EMULATIONS - select_emulation_mode (argc, argv); + select_emulation_mode (*argcp, *argvp); #endif +} =20 - obstack_begin (¬es, chunksize); - xatexit (free_notes); +/* Init things that might depend on program args. */ + +static void +gas_late_init (void) +{ + symbol_begin (); + frag_init (); + subsegs_begin (); + read_begin (); + input_scrub_begin (); + expr_begin (); + + int macro_strip_at =3D 0; +#ifdef TC_I960 + macro_strip_at =3D flag_mri; +#endif + macro_init (flag_macro_alternate, flag_mri, macro_strip_at, macro_expr); =20 + dwarf2_init (); + + /* Somewhat arbitrary division into initialisation above that + doesn't need stdoutput open (even though it is open), and below + where things might be put on stdoutput memory, eg. symbols. */ PROGRESS (1); - /* Call parse_args before any of the init/begin functions - so that switches like --hash-size can be honored. */ + + dot_symbol_init (); + +#ifdef tc_init_after_args + tc_init_after_args (); +#endif + + itbl_init (); + + local_symbol_make (".gasversion.", absolute_section, + &predefined_address_frag, BFD_VERSION / 10000UL); + + /* Now that we have fully initialized, and have created the output + file, define any symbols requested by --defsym command line + arguments. */ + while (defsyms !=3D NULL) + { + symbolS *sym; + struct defsym_list *next; + + sym =3D symbol_new (defsyms->name, absolute_section, + &zero_address_frag, defsyms->value); + /* Make symbols defined on the command line volatile, so that they + can be redefined inside a source file. This makes this assembler's + behaviour compatible with earlier versions, but it may not be + completely intuitive. */ + S_SET_VOLATILE (sym); + symbol_table_insert (sym); + next =3D defsyms->next; + free (defsyms); + defsyms =3D next; + } +} + +int +main (int argc, char ** argv) +{ + char ** argv_orig =3D argv; + struct stat sob; + + gas_early_init (&argc, &argv); + PROGRESS (1); + + /* Call parse_args before gas_late_init so that switches like + --hash-size can be honored. */ parse_args (&argc, &argv); =20 if (argc > 1 && stat (out_file_name, &sob) =3D=3D 0) @@ -1361,64 +1424,16 @@ main (int argc, char ** argv) } } =20 - symbol_begin (); - frag_init (); - subsegs_begin (); - read_begin (); - input_scrub_begin (); - expr_begin (); - /* It has to be called after dump_statistics (). */ xatexit (output_file_close); =20 if (flag_print_statistics) xatexit (dump_statistics); =20 - macro_strip_at =3D 0; -#ifdef TC_I960 - macro_strip_at =3D flag_mri; -#endif - - macro_init (flag_macro_alternate, flag_mri, macro_strip_at, macro_expr); - - PROGRESS (1); - output_file_create (out_file_name); gas_assert (stdoutput !=3D 0); =20 - dot_symbol_init (); - -#ifdef tc_init_after_args - tc_init_after_args (); -#endif - - itbl_init (); - - dwarf2_init (); - - local_symbol_make (".gasversion.", absolute_section, - &predefined_address_frag, BFD_VERSION / 10000UL); - - /* Now that we have fully initialized, and have created the output - file, define any symbols requested by --defsym command line - arguments. */ - while (defsyms !=3D NULL) - { - symbolS *sym; - struct defsym_list *next; - - sym =3D symbol_new (defsyms->name, absolute_section, - &zero_address_frag, defsyms->value); - /* Make symbols defined on the command line volatile, so that they - can be redefined inside a source file. This makes this assembler's - behaviour compatible with earlier versions, but it may not be - completely intuitive. */ - S_SET_VOLATILE (sym); - symbol_table_insert (sym); - next =3D defsyms->next; - free (defsyms); - defsyms =3D next; - } + gas_late_init (); =20 PROGRESS (1);