source cleanups; fix finding scripts
authorDavid MacKenzie <djm@cygnus>
Thu, 15 Jul 1993 21:43:28 +0000 (21:43 +0000)
committerDavid MacKenzie <djm@cygnus>
Thu, 15 Jul 1993 21:43:28 +0000 (21:43 +0000)
ld/ChangeLog
ld/ldfile.c
ld/ldgram.y
ld/ldmain.c
ld/ldsym.c

index f9bbed6..9ca7867 100644 (file)
@@ -1,3 +1,24 @@
+Thu Jul 15 12:44:35 1993  David J. Mackenzie  (djm@thepub.cygnus.com)
+
+       * ldfile.c (ldfile_open_file): In error message, use the name the
+       user gave (e.g., "-lc"), rather than the base file name.
+
+       * ldexp.c (exp_fold_tree): Don't assign an int to an enum.
+
+       * ldmain.[ch]: Remove initial Q_ from function names.
+       * ldexp.c, ldindr.c, ldlang.c: Change callers.
+
+       * ldfile.c, ldmain.c, ldgram.y: Rename option_v to trace_file_tries.
+
+       * ldlang.c (lang_process): Move loading of default script from
+       here to main.  Add a "/" to start of script name to prevent
+       finding it in "." first.
+
+       * ldmain.c (set_scripts_dir): Don't look in "." first.
+
+       * ldgram.y, ldlang.c, ldsym.c: Remove traces of unused var
+       option_longmap. 
+
 Thu Jul 15 10:55:59 1993  Ian Lance Taylor  (ian@cygnus.com)
 
        * Makefile.in (em_m88kbcs.c): Correct dependency.
index 138ee1c..f68ed7d 100644 (file)
@@ -40,7 +40,7 @@ enum bfd_architecture ldfile_output_architecture;
 /* IMPORT */
 
 extern boolean had_script;
-extern boolean option_v;
+extern boolean trace_file_tries;
 
 
 #ifdef VMS
@@ -92,7 +92,7 @@ char *attempt;
 lang_input_statement_type  *entry;
 {
   entry->the_bfd = bfd_openr(attempt, entry->target);
-  if (option_v == true ) {
+  if (trace_file_tries == true ) {
     info("attempt to open %s %s\n", attempt,
                (entry->the_bfd == (bfd *)NULL) ? "failed" : "succeeded" );
   }
@@ -174,14 +174,13 @@ lang_input_statement_type *entry;
 
       }
 
-
     }
   else {
     entry->the_bfd = cached_bfd_openr (entry->filename, entry);
-
   }
-  if (!entry->the_bfd)  einfo("%F%P: Can't open %s, %E\n", entry->filename);
 
+  if (!entry->the_bfd)
+    einfo("%F%P: cannot open %s: %E\n", entry->local_sym_name);
 }
 
 
@@ -196,7 +195,7 @@ char *exten;
   char buff[1000];
 
   result = fopen(name, "r");
-  if (option_v == true) {
+  if (trace_file_tries == true) {
     if (result == (FILE *)NULL) {
       info("can't find ");
     }
@@ -209,7 +208,7 @@ char *exten;
   if (*exten) {
     sprintf(buff, "%s%s", name, exten);
     result = fopen(buff, "r");
-    if (option_v == true) {
+    if (trace_file_tries == true) {
       if (result == (FILE *)NULL) {
        info("can't find ");
       }
@@ -254,7 +253,7 @@ char *name;
   ldlex_input_stack = find_a_name(name, "");
 
   if (ldlex_input_stack == (FILE *)NULL) {
-    einfo("%P%F cannot open load script file %s, %E\n",name);
+    einfo("%P%F: cannot open load script file %s: %E\n",name);
   }
   lex_push_file(ldlex_input_stack, name);
   
index a81045b..5104554 100644 (file)
@@ -38,11 +38,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 #define YYDEBUG 1
 
-boolean option_v;
 extern unsigned int lineno;
+extern boolean trace_file_tries;
 extern boolean trace_files;
 extern boolean write_map;
-extern boolean option_longmap;
 extern int g_switch_value;
 boolean hex_mode;
 static int typebits;
@@ -192,7 +191,7 @@ command_line_option:
        |       OPTION_V
                        {       
                        ldversion(1);
-                       option_v = true;
+                       trace_file_tries = true;
                        }
        |       OPTION_version
                        {       
index 9762983..cb2eada 100644 (file)
@@ -49,7 +49,9 @@ static void set_scripts_dir ();
 
 /* IMPORTS */
 extern boolean lang_has_input_file;
-extern boolean trace_files;
+extern boolean force_make_executable;
+extern boolean relaxing;
+extern boolean had_script;
 
 /* EXPORTS */
 
@@ -62,8 +64,6 @@ char *program_name;
 /* The file that we're creating */
 bfd *output_bfd = 0;
 
-extern boolean option_v;
-
 /* set if -y on the command line */
 int had_y;
 
@@ -93,28 +93,20 @@ unsigned int commons_pending;
 
 unsigned int undefined_global_sym_count;
 
-/* Count the number of warning symbols encountered. */
-int warning_count;
-
-/* have we had a load script ? */
-extern boolean had_script;
-
 /* Nonzero means print names of input files as processed.  */
 boolean trace_files;
 
+/* Nonzero means same, but note open failures, too.  */
+boolean trace_file_tries;
+
 /* 1 => write load map.  */
 boolean write_map;
 
 #ifdef GNU960
 /* Indicates whether output file will be b.out (default) or coff */
 enum target_flavour output_flavor = BFD_BOUT_FORMAT;
-
 #endif
 
-/* Force the make_executable to be output, even if there are non-fatal
-   errors */
-boolean force_make_executable;
-
 /* A count of the total number of local symbols ever seen - by adding
  the symbol_count field of each newly read afile.*/
 
@@ -143,7 +135,7 @@ main (argc, argv)
   /* Initialize the data about options.  */
 
 
-  trace_files = false;
+  trace_files = trace_file_tries = false;
   write_map = false;
   config.relocateable_output = false;
   command_line.force_common_definition = false;
@@ -160,7 +152,6 @@ main (argc, argv)
 
   /* Initialize the cumulative counts of symbols.  */
   undefined_global_sym_count = 0;
-  warning_count = 0;
   multiple_def_count = 0;
   commons_pending = 0;
 
@@ -176,21 +167,35 @@ main (argc, argv)
   lang_has_input_file = false;
   parse_args (argc, argv);
 
+  if (had_script == false)
+    {
+      /* Read the emulation's appropriate default script.  */
+      char *scriptname = ldemul_get_script ();
+      /* sizeof counts the terminating NUL.  */
+      size_t size = strlen (scriptname) + sizeof ("-T /ldscripts/");
+      char *buf = (char *) ldmalloc(size);
+      /* The initial slash prevents finding the script in `.' first.  */
+      sprintf (buf, "-T /ldscripts/%s", scriptname);
+      parse_line (buf, 0);
+      free (buf);
+    }
+
   if (config.relocateable_output && command_line.relax)
     {
       einfo ("%P%F: -relax and -r may not be used together\n");
     }
   lang_final ();
 
-  if (trace_files)
-    {
-      info ("%P: mode %s\n", emulation);
-    }
   if (lang_has_input_file == false)
     {
       einfo ("%P%F: No input files\n");
     }
 
+  if (trace_files)
+    {
+      info ("%P: mode %s\n", emulation);
+    }
+
   ldemul_after_parse ();
 
 
@@ -205,7 +210,7 @@ main (argc, argv)
          config.map_file = fopen (config.map_filename, FOPEN_WT);
          if (config.map_file == (FILE *) NULL)
            {
-             einfo ("%P%F: can't open map file %s, %E\n",
+             einfo ("%P%F: cannot open map file %s: %E\n",
                     config.map_filename);
            }
        }
@@ -348,10 +353,9 @@ check_for_scripts_dir (dir)
    Libraries will be searched for here too, but that's ok.
    We look for the "ldscripts" directory in:
 
-   the curent dir
    SCRIPTDIR (passed from Makefile)
-   the dir where this program is
-   the dir where this program is/../lib  */
+   the dir where this program is (for using it from the build tree)
+   the dir where this program is/../lib (for installing the tool suite elsewhere) */
 
 static void
 set_scripts_dir ()
@@ -359,22 +363,27 @@ set_scripts_dir ()
   char *end, *dir;
   size_t dirlen;
 
-  if (check_for_scripts_dir ("."))
-    return;                    /* Newest version, most likely.  */
-
   if (check_for_scripts_dir (SCRIPTDIR))
     return;                    /* We've been installed normally.  */
 
   /* Look for "ldscripts" in the dir where our binary is.  */
   end = strrchr (program_name, '/');
-  if (!end)
-    return;
+  if (end)
+    {
+      dirlen = end - program_name;
+      /* Make a copy of program_name in dir.
+        Leave room for later "/../lib".  */
+      dir = (char *) ldmalloc (dirlen + 8);
+      strncpy (dir, program_name, dirlen);
+      dir[dirlen] = '\0';
+    }
+  else
+    {
+      dirlen = 1;
+      dir = (char *) ldmalloc (dirlen + 8);
+      strcpy (dir, ".");
+    }
 
-  /* Make a copy of program_name in dir.  */
-  dirlen = end - program_name;
-  dir = (char *) ldmalloc (dirlen + 8);        /* Leave room for later "/../lib".  */
-  strncpy (dir, program_name, dirlen);
-  dir[dirlen] = '\0';
   if (check_for_scripts_dir (dir))
     return;                    /* Don't free dir.  */
 
@@ -387,7 +396,7 @@ set_scripts_dir ()
 }
 
 void
-Q_read_entry_symbols (desc, entry)
+read_entry_symbols (desc, entry)
      bfd *desc;
      struct lang_input_statement_struct *entry;
 {
@@ -440,10 +449,8 @@ Whilst all this is going on we keep a count of the number of multiple
 definitions seen, undefined global symbols and pending commons.
 */
 
-extern boolean relaxing;
-
 void
-Q_enter_global_ref (nlist_p, name)
+enter_global_ref (nlist_p, name)
      asymbol ** nlist_p;       /* pointer into symbol table from incoming bfd */
      CONST char *name; /* name of symbol in linker table */
 {
@@ -602,7 +609,7 @@ Q_enter_global_ref (nlist_p, name)
 }
 
 static void
-Q_enter_file_symbols (entry)
+enter_file_symbols (entry)
      lang_input_statement_type *entry;
 {
   asymbol **q;
@@ -613,7 +620,7 @@ Q_enter_file_symbols (entry)
   ldlang_add_file (entry);
 
 
-  if (trace_files || option_v)
+  if (trace_files || trace_file_tries)
     {
       info ("%I\n", entry);
     }
@@ -669,7 +676,7 @@ Q_enter_file_symbols (entry)
                       || bfd_is_com_section (p->section)
                       || (p->flags & BSF_CONSTRUCTOR))
                {
-                 Q_enter_global_ref (q, p->name);
+                 enter_global_ref (q, p->name);
                }
 
            }
@@ -746,13 +753,13 @@ ldmain_open_file_read_symbol (entry)
          entry->the_bfd->usrdata = (PTR) entry;
 
 
-         Q_read_entry_symbols (entry->the_bfd, entry);
+         read_entry_symbols (entry->the_bfd, entry);
 
          /* look through the sections in the file and see if any of them
             are constructors */
          ldlang_check_for_constructors (entry);
 
-         Q_enter_file_symbols (entry);
+         enter_file_symbols (entry);
        }
 #ifdef GNU960
       else if (gnu960_check_format (entry->the_bfd, bfd_archive))
@@ -920,7 +927,7 @@ symdef_library (entry)
                          if (archive_member_lang_input_statement_struct->loaded == false)
                            {
 
-                             Q_read_entry_symbols (archive_member_bfd, archive_member_lang_input_statement_struct);
+                             read_entry_symbols (archive_member_bfd, archive_member_lang_input_statement_struct);
                              /* Now scan the symbol table and decide whether to load.  */
 
 
@@ -933,7 +940,7 @@ symdef_library (entry)
 
                                  not_finished = true;
 
-                                 Q_enter_file_symbols (archive_member_lang_input_statement_struct);
+                                 enter_file_symbols (archive_member_lang_input_statement_struct);
 
                                  if (prev)
                                    prev->chain = archive_member_lang_input_statement_struct;
@@ -1008,11 +1015,11 @@ linear_library (entry)
                    return;
                  if (subentry->loaded == false)
                    {
-                     Q_read_entry_symbols (archive, subentry);
+                     read_entry_symbols (archive, subentry);
 
                      if (subfile_wanted_p (subentry) == true)
                        {
-                         Q_enter_file_symbols (subentry);
+                         enter_file_symbols (subentry);
 
                          if (prev)
                            prev->chain = subentry;
index 79089ee..6cf7764 100644 (file)
@@ -82,8 +82,6 @@ unsigned int global_symbol_count;
 
 /* IMPORTS */
 
-extern boolean option_longmap;
-
 /* LOCALS */
 #define        TABSIZE 1009
 static ldsym_type *global_symbol_hash_table[TABSIZE];
@@ -324,7 +322,7 @@ print_file_stuff (f)
   else
     {
       asection *s;
-      if (true || option_longmap)
+      if (true)
        {
          for (s = f->the_bfd->sections;
               s != (asection *) NULL;
@@ -426,10 +424,6 @@ ldsym_print_symbol_table ()
 
       }
   }
-  if (option_longmap)
-    {
-      lang_for_each_file (list_file_locals);
-    }
 }
 
 extern lang_output_section_statement_type *create_object_symbols;