* ldlang.c (lang_size_sections_1): Move check for conflicting load
authorRichard Sandiford <rdsandiford@googlemail.com>
Mon, 27 May 2002 08:22:08 +0000 (08:22 +0000)
committerRichard Sandiford <rdsandiford@googlemail.com>
Mon, 27 May 2002 08:22:08 +0000 (08:22 +0000)
addresses and regions from here...
(lang_get_regions): ...to this new function.
(lang_leave_output_section_statement): Use lang_get_regions.
(lang_leave_overlay): Likewise.
* mri.c (mri_draw_tree): Pass null as last argument to
lang_leave_output_section_statement.
* emultempl/elf32.em (gld*_place_orphan): Likewise.
* emultempl/mmo.em (mmo_place_orphan): Likewise.
* emultempl/pe.em (gld*_place_orphan): Likewise.

ld/ChangeLog
ld/emultempl/elf32.em
ld/emultempl/mmo.em
ld/emultempl/pe.em
ld/ldlang.c
ld/mri.c

index e768253f3b7fdaad6e06317cf138161c96d84a8f..6954fc4489d05d3d2310b619a8e118529e2425aa 100644 (file)
@@ -1,3 +1,16 @@
+2002-05-27  Richard Sandiford  <rsandifo@redhat.com>
+
+       * ldlang.c (lang_size_sections_1): Move check for conflicting load
+       addresses and regions from here...
+       (lang_get_regions): ...to this new function.
+       (lang_leave_output_section_statement): Use lang_get_regions.
+       (lang_leave_overlay): Likewise.
+       * mri.c (mri_draw_tree): Pass null as last argument to
+       lang_leave_output_section_statement.
+       * emultempl/elf32.em (gld*_place_orphan): Likewise.
+       * emultempl/mmo.em (mmo_place_orphan): Likewise.
+       * emultempl/pe.em (gld*_place_orphan): Likewise.
+
 2002-05-26  Jason Thorpe  <thorpej@wasabisystems.com>
 
        * configure.tgt: Use ns32k-*-netbsd* instead of ns32k-pc532-netbsd*.
index a85d97d76892de54fe8e95f6c190973b233240a5..b1e7dd3164327ee1e148f3bc8e91e496833aa2e8 100644 (file)
@@ -1222,7 +1222,7 @@ gld${EMULATION_NAME}_place_orphan (file, s)
 
   lang_leave_output_section_statement
     ((bfd_vma) 0, "*default*",
-     (struct lang_output_section_phdr_list *) NULL, "*default*");
+     (struct lang_output_section_phdr_list *) NULL, NULL);
 
   if (config.build_constructors && *ps == '\0')
     {
index 32be230122faf27d1136220a0baf5be5d65a1ed8..d8675bf392b50048b9e03225d317e942b924ae3a 100644 (file)
@@ -147,7 +147,7 @@ mmo_place_orphan (file, s)
 
   lang_leave_output_section_statement
     ((bfd_vma) 0, "*default*",
-     (struct lang_output_section_phdr_list *) NULL, "*default*");
+     (struct lang_output_section_phdr_list *) NULL, NULL);
 
   /* Restore the global list pointer.  */
   stat_ptr = old;
index ba5d83a94e6dd08902eae7245da02f1f8c135428..4701f6d0f833cad44b4f6c801a5644388216ef89 100644 (file)
@@ -1648,7 +1648,7 @@ gld_${EMULATION_NAME}_place_orphan (file, s)
 
       lang_leave_output_section_statement
        ((bfd_vma) 0, "*default*",
-        (struct lang_output_section_phdr_list *) NULL, "*default*");
+        (struct lang_output_section_phdr_list *) NULL, NULL);
 
       if (config.build_constructors && *ps == '\0')
         {
index bf26aa16b2a206bea0d3827662e6422c1ebe3585..c3761ba1686c2d8b32ca4bee041732010b81f102 100644 (file)
@@ -136,6 +136,9 @@ static void lang_set_startof PARAMS ((void));
 static void gc_section_callback
   PARAMS ((lang_wild_statement_type *, struct wildcard_list *, asection *,
           lang_input_statement_type *, PTR));
+static void lang_get_regions PARAMS ((struct memory_region_struct **,
+                                     struct memory_region_struct **,
+                                     const char *, const char *, int));
 static void lang_record_phdrs PARAMS ((void));
 static void lang_gc_wild PARAMS ((lang_wild_statement_type *));
 static void lang_gc_sections_1 PARAMS ((lang_statement_union_type *));
@@ -3053,26 +3056,14 @@ lang_size_sections_1 (s, output_section_statement, prev, fill, dot, relax)
                if (os->lma_region == NULL && os->load_base == NULL)
                  os->lma_region = os->region;
 
-               if (os->lma_region != NULL)
+               if (os->lma_region != NULL && os->lma_region != os->region)
                  {
-                   if (os->load_base != NULL)
-                     {
-                       einfo (_("%X%P: use an absolute load address or a load memory region, not both\n"));
-                     }
-                   else
-                     {
-                       /* Don't allocate twice.  */
-                       if (os->lma_region != os->region)
-                         {
-                           /* Set load_base, which will be handled later.  */
-                           os->load_base =
-                             exp_intop (os->lma_region->current);
-                           os->lma_region->current +=
-                             os->bfd_section->_raw_size / opb;
-                           os_region_check (os, os->lma_region, NULL,
-                                            os->bfd_section->lma);
-                         }
-                     }
+                   /* Set load_base, which will be handled later.  */
+                   os->load_base = exp_intop (os->lma_region->current);
+                   os->lma_region->current +=
+                     os->bfd_section->_raw_size / opb;
+                   os_region_check (os, os->lma_region, NULL,
+                                    os->bfd_section->lma);
                  }
              }
          }
@@ -4517,6 +4508,36 @@ lang_float (maybe)
   lang_float_flag = maybe;
 }
 
+
+/* Work out the load- and run-time regions from a script statement, and
+   store them in *LMA_REGION and *REGION respectively.
+
+   MEMSPEC is the name of the run-time region, or "*default*" if the
+   statement didn't specify one.  LMA_MEMSPEC is the name of the
+   load-time region, or null if the statement didn't specify one.
+   HAVE_LMA_P is true if the statement had an explicit load address.
+
+   It is an error to specify both a load region and a load address.  */
+
+static void
+lang_get_regions (region, lma_region, memspec, lma_memspec, have_lma_p)
+     struct memory_region_struct **region, **lma_region;
+     const char *memspec, *lma_memspec;
+     int have_lma_p;
+{
+  *lma_region = lang_memory_region_lookup (lma_memspec);
+
+  /* If no runtime region has been given, but the load region has
+     been, use the load region.  */
+  if (lma_memspec != 0 && strcmp (memspec, "*default*") == 0)
+    *region = *lma_region;
+  else
+    *region = lang_memory_region_lookup (memspec);
+
+  if (have_lma_p && lma_memspec != 0)
+    einfo (_("%X%P:%S: section has both a load address and a load region\n"));
+}
+
 void
 lang_leave_output_section_statement (fill, memspec, phdrs, lma_memspec)
      fill_type *fill;
@@ -4524,15 +4545,11 @@ lang_leave_output_section_statement (fill, memspec, phdrs, lma_memspec)
      struct lang_output_section_phdr_list *phdrs;
      const char *lma_memspec;
 {
+  lang_get_regions (&current_section->region,
+                   &current_section->lma_region,
+                   memspec, lma_memspec,
+                   current_section->load_base != 0);
   current_section->fill = fill;
-  current_section->region = lang_memory_region_lookup (memspec);
-  current_section->lma_region = lang_memory_region_lookup (lma_memspec);
-
-  /* If no runtime region has been given, but the load region has
-     been, use the load region.  */
-  if (current_section->lma_region != 0 && strcmp (memspec, "*default*") == 0)
-    current_section->region = current_section->lma_region;
-
   current_section->phdrs = phdrs;
   stat_ptr = &statement_list;
 }
@@ -4934,8 +4951,9 @@ lang_leave_overlay (lma_expr, nocrossrefs, fill, memspec, phdrs, lma_memspec)
   struct overlay_list *l;
   struct lang_nocrossref *nocrossref;
 
-  region = lang_memory_region_lookup (memspec);
-  lma_region = lang_memory_region_lookup (lma_memspec);
+  lang_get_regions (&region, &lma_region,
+                   memspec, lma_memspec,
+                   lma_expr != 0);
 
   nocrossref = NULL;
 
index 6ec0ab8f846cfed8459e63845bc745bf01679616..aed6e0263f235777aef18da2dd333b22fe01f40d 100644 (file)
--- a/ld/mri.c
+++ b/ld/mri.c
@@ -260,7 +260,7 @@ mri_draw_tree ()
 
          lang_leave_output_section_statement
            (0, "*default*", (struct lang_output_section_phdr_list *) NULL,
-            "*default*");
+            NULL);
 
          p = p->next;
        }
This page took 0.0404099999999999 seconds and 4 git commands to generate.