GCC Wikia
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

  • gcc-4.1.0/gcc/toplev.cにて定義
  • コマンドライン引数を解釈し,フロントエンドの環境を初期化する.

引数[]

  • char *argv0 : main の引数であるargv[0]

実装[]

1423 /* Initialization of the front end environment, before command line
1424    options are parsed.  Signal handlers, internationalization etc.
1425    ARGV0 is main's argv[0].  */
1426 static void
1427 general_init (const char *argv0)
1428 {
1429   const char *p;
1430 

  • ディレクトリの部分を削除するために、引数の後ろの文字から前の方へ探索する

1431   p = argv0 + strlen (argv0);
1432   while (p != argv0 && !IS_DIR_SEPARATOR (p[-1]))
1433     --p;
1434   progname = p;
1435 
1436   xmalloc_set_program_name (progname);
1437 
1438   hex_init ();
1439 
1440   /* Unlock the stdio streams.  */
1441   unlock_std_streams ();
1442 
1443   gcc_init_libintl ();
1444 
1445   /* Initialize the diagnostics reporting machinery, so option parsing
1446      can give warnings and errors.  */
1447   diagnostic_initialize (global_dc);
1448   /* Set a default printer.  Language specific initializations will
1449      override it later.  */
1450   pp_format_decoder (global_dc->printer) = &default_tree_printer;
1451 
1452   /* Trap fatal signals, e.g. SIGSEGV, and convert them to ICE messages.  */
1453 #ifdef SIGSEGV
1454   signal (SIGSEGV, crash_signal);
1455 #endif
1456 #ifdef SIGILL
1457   signal (SIGILL, crash_signal);
1458 #endif
1459 #ifdef SIGBUS
1460   signal (SIGBUS, crash_signal);
1461 #endif
1462 #ifdef SIGABRT
1463   signal (SIGABRT, crash_signal);
1464 #endif
1465 #if defined SIGIOT && (!defined SIGABRT || SIGABRT != SIGIOT)
1466   signal (SIGIOT, crash_signal);
1467 #endif
1468 #ifdef SIGFPE
1469   signal (SIGFPE, crash_signal);
1470 #endif
1471 
1472   /* Other host-specific signal setup.  */
1473   (*host_hooks.extra_signals)();
1474 
1475   /* Initialize the garbage-collector, string pools and tree type hash
1476      table.  */
1477   init_ggc ();
1478   init_stringpool ();
1479   linemap_init (&line_table);
1480   init_ttree ();
1481 
1482   /* Initialize register usage now so switches may override.  */
1483   init_reg_sets ();
1484 
1485   /* Register the language-independent parameters.  */
1486   add_params (lang_independent_params, LAST_PARAM);
1487 
1488   /* This must be done after add_params but before argument processing.  */
1489   init_ggc_heuristics();
1490   init_optimization_passes ();
1491 }



リンク元

Advertisement