This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: New "make check" failure on ia64


Alan Modra <amodra@bigpond.net.au> writes:
> On Thu, May 23, 2002 at 01:56:50PM -0700, H . J . Lu wrote:
> > On Thu, May 23, 2002 at 09:28:13AM -0700, H . J . Lu wrote:
> > > ./ld-new: use an absolute load address or a load memory region,
> > > not both
> > 
> > Hi Richard,
> > 
> > It is a new feature you added.

Steady on!  I only the added the test case.  The feature's
been there for a while.

> I came to the same conclusion last night when I started debugging the
> problem.  We'll probably hit the warning on any target that does
> linker relaxation.  The quick fix, probably incorrect, is to disable
> the warning in lang_size_sections_1 when "relax" is non-NULL.

The error seems to be there to catch things like:

    foo : AT (addr) { ... } > AT region

So we should probably check for the error while parsing.
Then you'll get a source position, as well as avoiding the
relaxation problem.

> I'm concerned about what happens if the linker changes section sizes
> during a relaxation pass.  Are overlay lma's correct?  Hmm, are
> non-overlay lma's correct??

Not at the moment, I guess, since the code only works out the
base address once.

Patch below moves the error check as suggested.  It means
we work out the base address from the LMA region on each
sizing pass.  Also, I noticed my overlay patch missed out
some calls to lang_leave_output_section_statement(), which
was probably contributing to the problem.

Tested on i686-pc-linux-gnu, mips64-elf and ia64-elf.
Fixes overlay-size for ia64-elf.  OK to install?

Richard

	* 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.
	
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.86
diff -c -d -p -r1.86 ldlang.c
*** ld/ldlang.c	23 May 2002 13:12:52 -0000	1.86
--- ld/ldlang.c	24 May 2002 14:19:08 -0000
*************** static void lang_set_startof PARAMS ((vo
*** 136,141 ****
--- 136,144 ----
  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 *));
*************** lang_size_sections_1 (s, output_section_
*** 3053,3078 ****
  		if (os->lma_region == NULL && os->load_base == NULL)
  		  os->lma_region = os->region;
  
! 		if (os->lma_region != NULL)
  		  {
! 		    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);
! 			  }
! 		      }
  		  }
  	      }
  	  }
--- 3056,3069 ----
  		if (os->lma_region == NULL && os->load_base == NULL)
  		  os->lma_region = os->region;
  
! 		if (os->lma_region != NULL && 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);
  		  }
  	      }
  	  }
*************** lang_float (maybe)
*** 4517,4522 ****
--- 4508,4543 ----
    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;
*************** lang_leave_output_section_statement (fil
*** 4524,4538 ****
       struct lang_output_section_phdr_list *phdrs;
       const char *lma_memspec;
  {
    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;
  }
--- 4545,4555 ----
       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->phdrs = phdrs;
    stat_ptr = &statement_list;
  }
*************** lang_leave_overlay (lma_expr, nocrossref
*** 4934,4941 ****
    struct overlay_list *l;
    struct lang_nocrossref *nocrossref;
  
!   region = lang_memory_region_lookup (memspec);
!   lma_region = lang_memory_region_lookup (lma_memspec);
  
    nocrossref = NULL;
  
--- 4951,4959 ----
    struct overlay_list *l;
    struct lang_nocrossref *nocrossref;
  
!   lang_get_regions (&region, &lma_region,
! 		    memspec, lma_memspec,
! 		    lma_expr != 0);
  
    nocrossref = NULL;
  
Index: ld/mri.c
===================================================================
RCS file: /cvs/src/src/ld/mri.c,v
retrieving revision 1.7
diff -c -d -p -r1.7 mri.c
*** ld/mri.c	3 Aug 2001 01:11:21 -0000	1.7
--- ld/mri.c	24 May 2002 14:19:08 -0000
*************** mri_draw_tree ()
*** 260,266 ****
  
  	  lang_leave_output_section_statement
  	    (0, "*default*", (struct lang_output_section_phdr_list *) NULL,
! 	     "*default*");
  
  	  p = p->next;
  	}
--- 260,266 ----
  
  	  lang_leave_output_section_statement
  	    (0, "*default*", (struct lang_output_section_phdr_list *) NULL,
! 	     NULL);
  
  	  p = p->next;
  	}
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.75
diff -c -d -p -r1.75 elf32.em
*** ld/emultempl/elf32.em	22 May 2002 09:02:04 -0000	1.75
--- ld/emultempl/elf32.em	24 May 2002 14:19:08 -0000
*************** gld${EMULATION_NAME}_place_orphan (file,
*** 1222,1228 ****
  
    lang_leave_output_section_statement
      ((bfd_vma) 0, "*default*",
!      (struct lang_output_section_phdr_list *) NULL, "*default*");
  
    if (config.build_constructors && *ps == '\0')
      {
--- 1222,1228 ----
  
    lang_leave_output_section_statement
      ((bfd_vma) 0, "*default*",
!      (struct lang_output_section_phdr_list *) NULL, NULL);
  
    if (config.build_constructors && *ps == '\0')
      {
Index: ld/emultempl/mmo.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mmo.em,v
retrieving revision 1.5
diff -c -d -p -r1.5 mmo.em
*** ld/emultempl/mmo.em	17 Feb 2002 21:38:03 -0000	1.5
--- ld/emultempl/mmo.em	24 May 2002 14:19:08 -0000
*************** mmo_place_orphan (file, s)
*** 147,153 ****
  
    lang_leave_output_section_statement
      ((bfd_vma) 0, "*default*",
!      (struct lang_output_section_phdr_list *) NULL, "*default*");
  
    /* Restore the global list pointer.  */
    stat_ptr = old;
--- 147,153 ----
  
    lang_leave_output_section_statement
      ((bfd_vma) 0, "*default*",
!      (struct lang_output_section_phdr_list *) NULL, NULL);
  
    /* Restore the global list pointer.  */
    stat_ptr = old;
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.62
diff -c -d -p -r1.62 pe.em
*** ld/emultempl/pe.em	22 May 2002 18:03:09 -0000	1.62
--- ld/emultempl/pe.em	24 May 2002 14:19:08 -0000
*************** gld_${EMULATION_NAME}_place_orphan (file
*** 1648,1654 ****
  
        lang_leave_output_section_statement
  	((bfd_vma) 0, "*default*",
! 	 (struct lang_output_section_phdr_list *) NULL, "*default*");
  
        if (config.build_constructors && *ps == '\0')
          {
--- 1648,1654 ----
  
        lang_leave_output_section_statement
  	((bfd_vma) 0, "*default*",
! 	 (struct lang_output_section_phdr_list *) NULL, NULL);
  
        if (config.build_constructors && *ps == '\0')
          {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]