* emultempl/hppaosf.em: Various fixes and support for linker stub
[deliverable/binutils-gdb.git] / ld / ldlang.c
index b8f6aaaf5d28f41959da97ea019d217651b97152..0fb4a1856dab4d445c43923c8a63d0ce1b12cf57 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.
 
@@ -33,10 +33,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "ldindr.h"
 #include "ldctor.h"
 
-#define BYTE_SIZE      (1)
-#define SHORT_SIZE     (2)
-#define LONG_SIZE      (4)
-
 /* FORWARDS */
 static void print_statements PARAMS ((void));
 static void print_statement PARAMS ((lang_statement_union_type *,
@@ -86,6 +82,7 @@ boolean lang_has_input_file = false;
 lang_output_section_statement_type *create_object_symbols = 0;
 boolean had_output_filename = false;
 boolean lang_float_flag = false;
+boolean delete_output_file_on_failure = false;
 
 /* IMPORTS */
 extern char *default_target;
@@ -328,6 +325,7 @@ lang_add_input_file (name, file_type, target)
 {
   /* Look it up or build a new one */
   lang_has_input_file = true;
+
 #if 0
   lang_input_statement_type *p;
 
@@ -353,10 +351,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;
 }
 
@@ -779,6 +777,7 @@ wild (s, section, file, target, output)
 /*
   read in all the files
   */
+
 static bfd *
 open_output (name)
      CONST char *CONST name;
@@ -808,6 +807,8 @@ open_output (name)
       einfo ("%P%F: cannot open output file %s: %E\n", name);
     }
 
+  delete_output_file_on_failure = 1;
+
   /*  output->flags |= D_PAGED;*/
 
   if (! bfd_set_format (output, bfd_object))
@@ -1194,6 +1195,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 ();
 }
 
@@ -1255,7 +1258,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);
                        }
@@ -1625,11 +1629,10 @@ DEFUN (lang_size_sections, (s, output_section_statement, prev, fill, dot, relax)
        /* Ignore the size of the input sections, use the vma and size to */
        /* align against */
 
-
        after = ALIGN_N (os->bfd_section->vma +
-                     os->bfd_section->_raw_size,
-                     os->block_value);
-
+                       os->bfd_section->_raw_size,
+                       /* The coercion here is important, see ld.h.  */
+                       (bfd_vma) os->block_value);
 
        os->bfd_section->_raw_size = after - os->bfd_section->vma;
        dot = os->bfd_section->vma + os->bfd_section->_raw_size;
@@ -2029,7 +2032,7 @@ lang_check ()
       else
        {
 
-         info ("%P: warning: %s architecture of input file `%B' is 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));
 
@@ -2137,7 +2140,9 @@ lang_common ()
                      /*  Fix the size of the common section */
 
                      com->section->_raw_size =
-                       ALIGN_N (com->section->_raw_size, align);
+                       ALIGN_N (com->section->_raw_size,
+                                /* The coercion here is important, see ld.h.  */
+                                (bfd_vma) align);
 
                      /* Remember if this is the biggest alignment ever seen */
                      if (power_of_two > com->section->alignment_power)
@@ -2210,7 +2215,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");
@@ -2460,6 +2465,8 @@ lang_process ()
      file */
   lang_create_output_section_statements ();
 
+  ldemul_create_output_section_statements ();
+
   /* Create a dummy bfd for the script */
   lang_init_script_file ();
 
@@ -2508,50 +2515,41 @@ lang_process ()
   /* Now run around and relax if we can */
   if (command_line.relax)
     {
-      /* First time round is a trial run to get the 'worst case' addresses of the
-         objects if there was no relaxing */
+      /* First time round is a trial run to get the 'worst case'
+        addresses of the objects if there was no relaxing.  */
       lang_size_sections (statement_list.head,
                          (lang_output_section_statement_type *) NULL,
                          &(statement_list.head), 0, (bfd_vma) 0, false);
 
+      /* Move the global symbols around so the second pass of relaxing
+        can see them.  */
+      lang_relocate_globals ();
 
+      reset_memory_regions ();
 
-  /* Move the global symbols around so the second pass of relaxing can
-     see them */
-  lang_relocate_globals ();
-
-  reset_memory_regions ();
-
-  /* Do all the assignments, now that we know the final restingplaces
-     of all the symbols */
-
-  lang_do_assignments (statement_list.head,
-                      abs_output_section,
-                      0, (bfd_vma) 0);
+      /* Do all the assignments, now that we know the final resting
+        places of all the symbols.  */
 
+      lang_do_assignments (statement_list.head,
+                          abs_output_section,
+                          0, (bfd_vma) 0);
 
       /* Perform another relax pass - this time we know where the
-        globals are, so can make better guess */
+        globals are, so can make better guess */
       lang_size_sections (statement_list.head,
                          (lang_output_section_statement_type *) NULL,
                          &(statement_list.head), 0, (bfd_vma) 0, true);
-
-
-
     }
-
   else
     {
-      /* Size up the sections */
+      /* Size up the sections */
       lang_size_sections (statement_list.head,
                          abs_output_section,
                          &(statement_list.head), 0, (bfd_vma) 0, false);
-
     }
 
-
   /* See if anything special should be done now we know how big
-     everything is */
+     everything is */
   ldemul_after_allocation ();
 
   /* Do all the assignments, now that we know the final restingplaces
@@ -2570,6 +2568,12 @@ lang_process ()
   lang_check ();
 
   /* Final stuffs */
+
+  ldemul_finish ();
+  /* Size up the sections.  */
+  lang_size_sections (statement_list.head,
+                     abs_output_section,
+                     &(statement_list.head), 0, (bfd_vma) 0, false);
   lang_finish ();
 }
 
This page took 0.026137 seconds and 4 git commands to generate.