* Makefile.in: Add dependency for $(EMULATION_OFILES).
[deliverable/binutils-gdb.git] / ld / ldlang.c
index 95580ebab5c6262967b9d947bc1a076aadf5e3eb..a37f3916cf4ff1847bf9ff39ec5ca687c09ff504 100644 (file)
@@ -1,5 +1,5 @@
 /* Linker command language support.
-   Copyright 1991, 1992 Free Software Foundation, Inc.
+   Copyright 1991, 1992, 1993 Free Software Foundation, Inc.
 
 This file is part of GLD, the Gnu Linker.
 
@@ -32,10 +32,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "ldmisc.h"
 #include "ldindr.h"
 #include "ldctor.h"
+
 /* FORWARDS */
 static void print_statements PARAMS ((void));
 static void print_statement PARAMS ((lang_statement_union_type *,
                                      lang_output_section_statement_type *));
+static lang_statement_union_type *new_statement PARAMS ((enum statement_enum,
+                                                        size_t,
+                                                        lang_statement_list_type*));
+
 
 /* LOCALS */
 static struct obstack stat_obstack;
@@ -69,7 +74,6 @@ boolean relaxing;
 lang_output_section_statement_type *abs_output_section;
 lang_statement_list_type *stat_ptr = &statement_list;
 lang_input_statement_type *script_file = 0;
-boolean option_longmap = false;
 lang_statement_list_type file_chain =
 {0};
 CONST char *entry_symbol = 0;
@@ -82,7 +86,6 @@ boolean lang_float_flag = false;
 /* IMPORTS */
 extern char *default_target;
 
-extern unsigned int undefined_global_sym_count;
 extern char *current_file;
 extern bfd *output_bfd;
 extern enum bfd_architecture ldfile_output_architecture;
@@ -92,7 +95,6 @@ extern ldsym_type *symbol_head;
 extern unsigned int commons_pending;
 extern args_type command_line;
 extern ld_config_type config;
-extern boolean had_script;
 extern boolean write_map;
 extern int g_switch_value;
 
@@ -220,7 +222,7 @@ static
 lang_statement_union_type *
 new_statement (type, size, list)
      enum statement_enum type;
-     bfd_size_type size;
+     size_t size;
      lang_statement_list_type * list;
 {
   lang_statement_union_type *new = (lang_statement_union_type *)
@@ -322,6 +324,13 @@ lang_add_input_file (name, file_type, target)
 {
   /* Look it up or build a new one */
   lang_has_input_file = true;
+
+  if (name) {
+    if ((*(name+strlen(name)-1) == '.') && (*(name+strlen(name)) == 'a')) {
+      file_type=lang_input_file_is_l_enum;
+    }
+  }
+
 #if 0
   lang_input_statement_type *p;
 
@@ -347,10 +356,10 @@ lang_add_keepsyms_file (filename)
 {
   extern strip_symbols_type strip_symbols;
   if (keepsyms_file != 0)
-    info ("%X%P error: duplicated keep-symbols-file value\n");
+    info_msg ("%X%P: error: duplicated keep-symbols-file value\n");
   keepsyms_file = filename;
   if (strip_symbols != STRIP_NONE)
-    info ("%P `-keep-only-symbols-file' overrides `-s' and `-S'\n");
+    info_msg ("%P: `-keep-only-symbols-file' overrides `-s' and `-S'\n");
   strip_symbols = STRIP_SOME;
 }
 
@@ -565,7 +574,7 @@ init_os (s)
     s->bfd_section = bfd_make_section (output_bfd, s->name);
   if (s->bfd_section == (asection *) NULL)
     {
-      einfo ("%P%F output format %s cannot represent section called %s\n",
+      einfo ("%P%F: output format %s cannot represent section called %s\n",
             output_bfd->xvec->name, s->name);
     }
   s->bfd_section->output_section = s->bfd_section;
@@ -797,17 +806,20 @@ open_output (name)
     {
       if (bfd_error == invalid_target)
        {
-         einfo ("%P%F target %s not found\n", output_target);
+         einfo ("%P%F: target %s not found\n", output_target);
        }
-      einfo ("%P%F problem opening output file %s, %E\n", name);
+      einfo ("%P%F: cannot open output file %s: %E\n", name);
     }
 
   /*  output->flags |= D_PAGED;*/
 
-  bfd_set_format (output, bfd_object);
-  bfd_set_arch_mach (output,
-                    ldfile_output_architecture,
-                    ldfile_output_machine);
+  if (! bfd_set_format (output, bfd_object))
+    einfo ("%P%F:%s: can not make object file: %E\n", name);
+  if (! bfd_set_arch_mach (output,
+                          ldfile_output_architecture,
+                          ldfile_output_machine))
+    einfo ("%P%F:%s: can not set architecture: %E\n", name);
+
   bfd_set_gp_size (output, g_switch_value);
   return output;
 }
@@ -944,7 +956,7 @@ lang_place_undefineds ()
       *def_ptr = def;
       def->name = ptr->name;
       def->section = &bfd_und_section;
-      Q_enter_global_ref (def_ptr, ptr->name);
+      enter_global_ref (def_ptr, ptr->name);
       ptr = ptr->next;
     }
 }
@@ -1046,7 +1058,7 @@ map_input_to_output_sections (s, target, output_section_statement)
            os->addr_tree = s->address_statement.address;
            if (os->bfd_section == (asection *) NULL)
              {
-               einfo ("%P%F can't set the address of undefined section %s\n",
+               einfo ("%P%F: cannot set the address of undefined section %s\n",
                       s->address_statement.section_name);
              }
          }
@@ -1185,6 +1197,8 @@ print_symbol (q)
   fprintf (config.map_file, " ");
   print_address (outside_symbol_address (q));
   fprintf (config.map_file, "              %s", q->name ? q->name : " ");
+  if (q->flags & BSF_WEAK)
+    fprintf (config.map_file, " *weak*");
   print_nl ();
 }
 
@@ -1246,7 +1260,8 @@ print_input_section (in)
                    {
                      asymbol *q = *p;
 
-                     if (bfd_get_section (q) == i && q->flags & BSF_GLOBAL)
+                     if (bfd_get_section (q) == i
+                         && (q->flags & (BSF_GLOBAL | BSF_WEAK)) != 0)
                        {
                          print_symbol (q);
                        }
@@ -1636,7 +1651,7 @@ DEFUN (lang_size_sections, (s, output_section_statement, prev, fill, dot, relax)
               > os->region->origin + os->region->length)
             || ( os->region->origin > os->region->current ))
           {
-            einfo ("%X%P: Region %s is full (%B section %s)\n",
+            einfo ("%X%P: region %s is full (%B section %s)\n",
                    os->region->name,
                    os->bfd_section->owner,
                    os->bfd_section->name);
@@ -1827,7 +1842,7 @@ DEFUN (lang_do_assignments, (s, output_section_statement, fill, dot),
                                   lang_final_phase_enum, dot, &dot);
            s->data_statement.value = value.value;
            if (value.valid == false)
-             einfo ("%F%P: Invalid data statement\n");
+             einfo ("%F%P: invalid data statement\n");
          }
          switch (s->data_statement.type)
            {
@@ -1964,14 +1979,14 @@ lang_finish ()
   }
   else
   {
-    /* Can't find anything reasonable,
+    /* Cannot find anything reasonable,
        use the first address in the text section
        */
     asection *ts = bfd_get_section_by_name (output_bfd, ".text");
     if (ts)
     {
       if (warn)
-       einfo ("%P: Warning, can't find entry symbol %s, defaulting to %V\n",
+       einfo ("%P: warning: cannot find entry symbol %s, defaulting to %V\n",
              entry_symbol, ts->vma);
 
       bfd_set_start_address (output_bfd, ts->vma);
@@ -1979,7 +1994,7 @@ lang_finish ()
     else 
     {
       if (warn)
-       einfo ("%P: Warning, can't find entry symbol %s, not setting start address\n",
+       einfo ("%P: warning: cannot find entry symbol %s, not setting start address\n",
              entry_symbol);
     }
   }
@@ -2020,13 +2035,15 @@ lang_check ()
       else
        {
 
-         info ("%P: warning, %s architecture of input file `%B' incompatible with %s output\n",
+         info_msg ("%P: warning: %s architecture of input file `%B' is incompatible with %s output\n",
                bfd_printable_name (input_bfd), input_bfd,
                bfd_printable_name (output_bfd));
 
-         bfd_set_arch_mach (output_bfd,
-                            input_architecture,
-                            input_machine);
+         if (! bfd_set_arch_mach (output_bfd,
+                                  input_architecture,
+                                  input_machine))
+           einfo ("%P%F:%s: can't set architecture: %E\n",
+                  bfd_get_filename (output_bfd));
        }
 
     }
@@ -2119,7 +2136,7 @@ lang_common ()
                                                            name);
                          /* BFD backend must provide this section. */
                          if (newsec == (asection *) NULL)
-                           einfo ("%P%F: No output section %s", name);
+                           einfo ("%P%F: no output section %s", name);
                          com->section = newsec;
                        }
 
@@ -2199,7 +2216,7 @@ lang_place_orphans ()
                      if (default_common_section ==
                          (lang_output_section_statement_type *) NULL)
                        {
-                         info ("%P: No [COMMON] command, defaulting to .bss\n");
+                         info_msg ("%P: no [COMMON] command, defaulting to .bss\n");
 
                          default_common_section =
                            lang_output_section_statement_lookup (".bss");
@@ -2255,7 +2272,7 @@ lang_set_flags (ptr, flags)
          /*      ptr->flag_loadable= state;*/
          break;
        default:
-         einfo ("%P%F illegal syntax in flags\n");
+         einfo ("%P%F: invalid syntax in flags\n");
          break;
        }
       flags++;
@@ -2434,25 +2451,13 @@ DEFUN (create_symbol, (name, flags, section),
   def->flags = flags;
   def->section = section;
   *def_ptr = def;
-  Q_enter_global_ref (def_ptr, name);
+  enter_global_ref (def_ptr, name);
   return def;
 }
 
 void
 lang_process ()
 {
-  if (had_script == false)
-    {
-      /* Read the emulation's appropriate default script.  */
-      char *scriptname = ldemul_get_script ();
-      size_t size = strlen (scriptname) + 13;
-      char *buf = (char *) ldmalloc(size);
-
-      sprintf (buf, "-Tldscripts/%s", scriptname);
-      parse_line (buf, 0);
-      free (buf);
-    }
-
   lang_reasonable_defaults ();
   current_target = default_target;
 
@@ -2689,7 +2694,7 @@ lang_startup (name)
 {
   if (startup_file != (char *) NULL)
     {
-      einfo ("%P%FMultiple STARTUP files\n");
+      einfo ("%P%Fmultiple STARTUP files\n");
     }
   first_file->filename = name;
   first_file->local_sym_name = name;
This page took 0.028611 seconds and 4 git commands to generate.