aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ld/ChangeLog13
-rw-r--r--ld/emultempl/elf32.em2
-rw-r--r--ld/emultempl/mmo.em2
-rw-r--r--ld/emultempl/pe.em2
-rw-r--r--ld/ldlang.c76
-rw-r--r--ld/mri.c2
6 files changed, 64 insertions, 33 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index e768253..6954fc4 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -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*.
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index a85d97d..b1e7dd3 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -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')
{
diff --git a/ld/emultempl/mmo.em b/ld/emultempl/mmo.em
index 32be230..d8675bf 100644
--- a/ld/emultempl/mmo.em
+++ b/ld/emultempl/mmo.em
@@ -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;
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index ba5d83a..4701f6d 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -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')
{
diff --git a/ld/ldlang.c b/ld/ldlang.c
index bf26aa1..c3761ba 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -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;
diff --git a/ld/mri.c b/ld/mri.c
index 6ec0ab8..aed6e02 100644
--- 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;
}