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]

Patch to fix problems with memory regions and OVERLAYs


Several related problems here.

1/ When an OVERLAY specifies a memory region, the overlay is only as
   big as the last section.  Test case snippet:

       OVERLAY : 
	 {
	   .bss1 { ... }
	   .bss2 { ... }
	   .bss3 { ... }
	 } > DATAMEM

       .mbss : AT (__load_stop_bss3)
	 {
	   *(.mbss) { ... }
	 } > DATAMEM

   .mbss's VMA will always be

       ADDR (.bss3) + SIZEOF (.bss3)

   lang_leave_overlay() creates an assignment:

       /* Update . for the end of the overlay.  */
       lang_add_assignment (exp_assop ('=', ".",
	     exp_binop ('+', overlay_vma, overlay_max)));

   which normally handles this case.  But the assignment is evaluated
   as a normal top-level statement, and in the test case, it has no
   effect on DATAMEM's value of '.'.


2/ 'OVERLAY { ... } AT > A' only 'allocates' the first section to A
   (in the sense of updating A's '.').  The problem here is that
   lang_leave_overlay_statement() only sets the first section's
   'lma_region':

      if (lma_region != NULL && l->os->lma_region == NULL
	  && l->next == NULL && l->os->load_base == NULL)
	     ^^^^^^^^^^^^^^^
	l->os->lma_region = lma_region;

   The other overlaid sections have the correct load addresses, because
   they are all worked out from the first.  But we run into trouble
   if the OVERLAY is followed by something else.  If A starts at ABASE,
   then:

       OVERLAY { .foo { ... } .bar { ... } } AT > A
       .frob { ... } AT > A

   means that:

       .foo loads at ABASE
       .bar loads at ABASE + SIZEOF (.foo)
       .frob loads at ABASE + SIZEOF (.foo)
       A's . = ABASE + SIZEOF (.foo) + SIZEOF (.frob)


3/ Normal section statements and overlays do different things when no
   LMA region is given.  lang_leave_output_section_statement() says:

     if (strcmp (lma_memspec, "*default*") != 0)
       {
	 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 (strcmp (memspec, "*default*") == 0)
	   current_section->region = lang_memory_region_lookup (lma_memspec);
       }

   so 'lma_region' is null unless a region was specified with
   'AT > REGION'. lang_leave_overlay() (to quote it more fully)
   says:

       if (lma_memspec == NULL)
	 lma_region = NULL;
       else
	 lma_region = lang_memory_region_lookup (lma_memspec);
       ...
	   if (lma_region != NULL && l->os->lma_region == NULL
	       && l->next == NULL && l->os->load_base == NULL)
	     l->os->lma_region = lma_region;

   It looks like 'lma_memspec == NULL' should always be false, since
   'memspec_at_opt' is either a NAME or "*default*".  And as far as
   I can tell, 'l->os->lma_region == NULL' should always be true,
   since lang_leave_overlay_section() sets it up that way.  So it
   seems like the code reduces to:

       lma_region = lang_memory_region_lookup (lma_memspec);
       ...
	   if (l->next == NULL && l->os->load_base == NULL)
	     l->os->lma_region = lma_region;

   and if the OVERLAY has neither 'AT (...)' nor 'AT > ...', we'll
   point the first 'lma_region' to '*default*' rather than leaving
   it null.


4/ Just a cleanup really.  lang_leave_overlay() has:

       default_region = lang_memory_region_lookup ("*default*");

       if (memspec == NULL)
	 region = NULL;
       else
	 region = lang_memory_region_lookup (memspec);
       ...
	   /* Assign a region to the sections, if one has been specified.
	      Override the assignment of the default section, but not
	      other sections.  */
	   if (region != NULL &&
	       (l->os->region == NULL ||
		l->os->region == default_region))
	     l->os->region = region;

   which (for the same reasons as before) seems to be equivalent to:

       region = lang_memory_region_lookup (memspec);
       ...
	   l->os->region = region;


Changes in the patch below:

1/ Make 'memspec_at_opt' set $$ to null if no region is given.

   It makes sense for 'memspect_opt' to set $$ to "*default*"
   instead of null since every section must have a region.
   But it seems more natural for 'memspec_at_opt' to set it
   to null, since the LMA region can be left unspecified.

2/ Make lang_memory_region_lookup() return null for a null name.

   Then there's no need for extra checks when passing an LMA
   region to lang_memory_region_lookup.  The result of a
   'memspec_opt' or 'memspec_at_opt' rule can be passed
   directly to the function, and the return value assigned
   directly to 'region' or 'lma_region'.

3/ Add an 'update_dot_tree' field to the section statement structure.

   lang_leave_overlay() now sets the last section's update_dot_tree
   to '. = overlay_vma + overlay_max' (the assignment quoted at the
   beginning of the mail).  lang_size_sections_1() evaluates this
   statement before updating the region's dot value.

   I don't like this fix much, but I couldn't think of a cleaner one.

4/ Make lang_leave_overlay() set 'load_base' for all the sections,
   rather than doing it after parsing a single section.  Also,
   unconditionally set each section's 'region' and 'lma_region' to
   whatever the OVERLAY statement specifies.

   We don't know when parsing an overlay section whether the overlay
   itself specifies a load region.  Setting 'lma_region' and 'load_base'
   at the same time makes it easier to avoid conflict between them.

   Also, 'lma_region' and 'load_base' will both be non-null for

       OVERLAY : AT { ... } AT > ...

   So we now get the error mentioned in lang_leave_overlay()'s FIXME.

5/ Move the lma and nocrossrefs arguments from lang_enter_overlay() to
   lang_leave_overlay(), removing overlay_lma and overlay_nocrossrefs.

   Only lang_leave_overlay() uses overlay_nocrossrefs, so there's
   no need for a global.  Likewise overlay_lma after the previous
   change.

I've attached a test case below.  While ld seems to generate a
good executable, a further patch to bfd is needed before it can
be read back in properly.  So the map check should pass, but
the dump test still fails.

The test case only works on ELF, and it seems like a check for
ELF would be a useful library function.  I've pinched the
one in ld-scripts/weak.exp and moved it to ld-lib.exp.

Also, I've added -L$srcdir/$subdir to the ld command line for
'run_dump_test'.  That makes it possible to use '-T <basename>'
in the '# ld: ...' line.

Tested on i686-pc-linux-gnu, mips-elf, mipsel-elf, mips64-elf,
arm-coff (for non-ELF sanity), arm-elf and powerpc-eabi.

OK to install?

Richard


[ld/]
	* ldlang.h (lang_output_section_statement_type): Add update_dot_tree.
	(lang_enter_overlay): Remove the last two parameters.
	(lang_leave_overlay): Take them here instead.
	* ldgram.y (memspec_at_opt): Set $$ to null if no region is given.
	(section): Pass LMA and crossref flag to lang_leave_overlay rather
	than lang_enter_overlay.
	* ldlang.c (lang_memory_region_lookup): Return null for null names.
	(lang_output_section_statement_lookup): Initialize update_dot_tree.
	(lang_size_sections_1): Evaluate it.
	(lang_leave_output_section_statement): Rework LMA lookup.
	(overlay_lma, overlay_nocrossrefs): Remove.
	(lang_enter_overlay): Remove LMA and corssref arguments.
	(lang_enter_overlay_section): Don't set the LMA here.
	(lang_leave_overlay): Take LMA and crossref arguments.  Move the '.'
	assignment to the last section's update_dot_tree.  Unconditionally
	use the load and run-time regions specified in the OVERLAY statement.
	Likewise the first section's LMA.  Only set the other sections' LMAs
	when no load region is given.

[ld/testsuite/]
	* lib/ld-lib.exp (run_dump_test): Add -L$srcdir/$subdir.
	(is_elf_format): New, extracted from...
	* ld-scripts/weak.exp: ...here.
	* ld-scripts/overlay-size.exp: New test.
	* ld-scripts/overlay-size.[tsd],
	* ld-scripts/overlay-size-map.d: New files for it.

Index: ldlang.h
===================================================================
RCS file: /cvs/src/src/ld/ldlang.h,v
retrieving revision 1.18
diff -c -p -d -r1.18 ldlang.h
*** ldlang.h	15 Feb 2002 02:11:05 -0000	1.18
--- ldlang.h	1 May 2002 16:58:45 -0000
*************** typedef struct lang_output_section_state
*** 135,140 ****
--- 135,146 ----
  
    union etree_union *load_base;
  
+   /* If non-null, an expression to evaluate after setting the section's
+      size.  The expression is evaluated inside REGION (above) with '.'
+      set to the end of the section.  Used in the last overlay section
+      to move '.' past all the overlaid sections.  */
+   union etree_union *update_dot_tree;
+ 
    struct lang_output_section_phdr_list *phdrs;
  } lang_output_section_statement_type;
  
*************** extern void lang_new_phdr
*** 456,468 ****
    PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
  	   etree_type *));
  extern void lang_add_nocrossref PARAMS ((struct lang_nocrossref *));
! extern void lang_enter_overlay PARAMS ((etree_type *, etree_type *, int));
  extern void lang_enter_overlay_section PARAMS ((const char *));
  extern void lang_leave_overlay_section
    PARAMS ((fill_type *, struct lang_output_section_phdr_list *));
  extern void lang_leave_overlay
!   PARAMS ((fill_type *, const char *, struct lang_output_section_phdr_list *,
!            const char *));
  
  extern struct bfd_elf_version_tree *lang_elf_version_info;
  
--- 462,474 ----
    PARAMS ((const char *, etree_type *, boolean, boolean, etree_type *,
  	   etree_type *));
  extern void lang_add_nocrossref PARAMS ((struct lang_nocrossref *));
! extern void lang_enter_overlay PARAMS ((etree_type *));
  extern void lang_enter_overlay_section PARAMS ((const char *));
  extern void lang_leave_overlay_section
    PARAMS ((fill_type *, struct lang_output_section_phdr_list *));
  extern void lang_leave_overlay
!   PARAMS ((etree_type *, int, fill_type *, const char *,
! 	   struct lang_output_section_phdr_list *, const char *));
  
  extern struct bfd_elf_version_tree *lang_elf_version_info;
  
Index: ldgram.y
===================================================================
RCS file: /cvs/src/src/ld/ldgram.y,v
retrieving revision 1.20
diff -c -p -d -r1.20 ldgram.y
*** ldgram.y	17 Apr 2002 13:05:55 -0000	1.20
--- ldgram.y	1 May 2002 16:58:45 -0000
*************** exp	:
*** 820,826 ****
  
  memspec_at_opt:
                  AT '>' NAME { $$ = $3; }
!         |       { $$ = "*default*"; }
          ;
  
  opt_at:
--- 820,826 ----
  
  memspec_at_opt:
                  AT '>' NAME { $$ = $3; }
!         |       { $$ = 0; }
          ;
  
  opt_at:
*************** section:	NAME 		{ ldlex_expression(); }
*** 851,857 ****
  			{ ldlex_popstate (); ldlex_script (); }
  		'{' 
  			{
! 			  lang_enter_overlay ($3, $5, (int) $4);
  			}
  		overlay_section
  		'}'
--- 851,857 ----
  			{ ldlex_popstate (); ldlex_script (); }
  		'{' 
  			{
! 			  lang_enter_overlay ($3);
  			}
  		overlay_section
  		'}'
*************** section:	NAME 		{ ldlex_expression(); }
*** 859,865 ****
  		memspec_opt memspec_at_opt phdr_opt fill_opt
  			{
  			  ldlex_popstate ();
! 			  lang_leave_overlay ($15, $12, $14, $13);
  			}
  		opt_comma
  	|	/* The GROUP case is just enough to support the gcc
--- 859,866 ----
  		memspec_opt memspec_at_opt phdr_opt fill_opt
  			{
  			  ldlex_popstate ();
! 			  lang_leave_overlay ($5, (int) $4,
! 					      $15, $12, $14, $13);
  			}
  		opt_comma
  	|	/* The GROUP case is just enough to support the gcc
Index: ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.81
diff -c -p -d -r1.81 ldlang.c
*** ldlang.c	30 Apr 2002 09:21:27 -0000	1.81
--- ldlang.c	1 May 2002 16:58:45 -0000
*************** lang_memory_region_lookup (name)
*** 617,622 ****
--- 617,626 ----
  {
    lang_memory_region_type *p;
  
+   /* NAME is NULL for LMA memspecs if no region was specified.  */
+   if (name == NULL)
+     return NULL;
+ 
    for (p = lang_memory_region_list;
         p != (lang_memory_region_type *) NULL;
         p = p->next)
*************** lang_output_section_statement_lookup (na
*** 738,743 ****
--- 742,748 ----
        lookup->subsection_alignment = -1;
        lookup->section_alignment = -1;
        lookup->load_base = (union etree_union *) NULL;
+       lookup->update_dot_tree = NULL;
        lookup->phdrs = NULL;
  
        lang_statement_append (&lang_output_section_statement,
*************** lang_size_sections_1 (s, output_section_
*** 3009,3017 ****
--- 3014,3027 ----
  	    else
  	      os->bfd_section->_raw_size =
  		(after - os->bfd_section->vma) * opb;
+ 
  	    dot = os->bfd_section->vma + os->bfd_section->_raw_size / opb;
  	    os->processed = true;
  
+ 	    if (os->update_dot_tree != 0)
+ 	      exp_fold_tree (os->update_dot_tree, abs_output_section,
+ 			     lang_allocating_phase_enum, dot, &dot);
+ 
  	    /* Update dot in the region ?
  	       We only do this if the section is going to be allocated,
  	       since unallocated sections do not contribute to the region's
*************** lang_leave_output_section_statement (fil
*** 4514,4527 ****
  {
    current_section->fill = fill;
    current_section->region = lang_memory_region_lookup (memspec);
!   if (strcmp (lma_memspec, "*default*") != 0)
!     {
!       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 (strcmp (memspec, "*default*") == 0)
!         current_section->region = lang_memory_region_lookup (lma_memspec);
!     }
    current_section->phdrs = phdrs;
    stat_ptr = &statement_list;
  }
--- 4524,4536 ----
  {
    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;
  }
*************** lang_add_nocrossref (l)
*** 4803,4814 ****
  /* The overlay virtual address.  */
  static etree_type *overlay_vma;
  
- /* The overlay load address.  */
- static etree_type *overlay_lma;
- 
- /* Whether nocrossrefs is set for this overlay.  */
- static int overlay_nocrossrefs;
- 
  /* An expression for the maximum section size seen so far.  */
  static etree_type *overlay_max;
  
--- 4812,4817 ----
*************** static struct overlay_list *overlay_list
*** 4824,4847 ****
  /* Start handling an overlay.  */
  
  void
! lang_enter_overlay (vma_expr, lma_expr, nocrossrefs)
       etree_type *vma_expr;
-      etree_type *lma_expr;
-      int nocrossrefs;
  {
    /* The grammar should prevent nested overlays from occurring.  */
!   ASSERT (overlay_vma == NULL
! 	  && overlay_lma == NULL
! 	  && overlay_list == NULL
! 	  && overlay_max == NULL);
  
    overlay_vma = vma_expr;
-   overlay_lma = lma_expr;
-   overlay_nocrossrefs = nocrossrefs;
  }
  
  /* Start a section in an overlay.  We handle this by calling
!    lang_enter_output_section_statement with the correct VMA and LMA.  */
  
  void
  lang_enter_overlay_section (name)
--- 4827,4844 ----
  /* Start handling an overlay.  */
  
  void
! lang_enter_overlay (vma_expr)
       etree_type *vma_expr;
  {
    /* The grammar should prevent nested overlays from occurring.  */
!   ASSERT (overlay_vma == NULL && overlay_max == NULL);
  
    overlay_vma = vma_expr;
  }
  
  /* Start a section in an overlay.  We handle this by calling
!    lang_enter_output_section_statement with the correct VMA.
!    lang_leave_overlay sets up the LMA and memory regions.  */
  
  void
  lang_enter_overlay_section (name)
*************** lang_enter_overlay_section (name)
*** 4851,4866 ****
    etree_type *size;
  
    lang_enter_output_section_statement (name, overlay_vma, normal_section,
! 				       0, 0, 0, overlay_lma);
  
!   /* If this is the first section, then base the VMA and LMA of future
       sections on this one.  This will work correctly even if `.' is
       used in the addresses.  */
    if (overlay_list == NULL)
!     {
!       overlay_vma = exp_nameop (ADDR, name);
!       overlay_lma = exp_nameop (LOADADDR, name);
!     }
  
    /* Remember the section.  */
    n = (struct overlay_list *) xmalloc (sizeof *n);
--- 4848,4860 ----
    etree_type *size;
  
    lang_enter_output_section_statement (name, overlay_vma, normal_section,
! 				       0, 0, 0, 0);
  
!   /* If this is the first section, then base the VMA of future
       sections on this one.  This will work correctly even if `.' is
       used in the addresses.  */
    if (overlay_list == NULL)
!     overlay_vma = exp_nameop (ADDR, name);
  
    /* Remember the section.  */
    n = (struct overlay_list *) xmalloc (sizeof *n);
*************** lang_enter_overlay_section (name)
*** 4870,4878 ****
  
    size = exp_nameop (SIZEOF, name);
  
-   /* Adjust the LMA for the next section.  */
-   overlay_lma = exp_binop ('+', overlay_lma, size);
- 
    /* Arrange to work out the maximum section end address.  */
    if (overlay_max == NULL)
      overlay_max = size;
--- 4864,4869 ----
*************** lang_leave_overlay_section (fill, phdrs)
*** 4895,4902 ****
  
    name = current_section->name;
  
!   lang_leave_output_section_statement (fill, "*default*",
!                                        phdrs, "*default*");
  
    /* Define the magic symbols.  */
  
--- 4886,4895 ----
  
    name = current_section->name;
  
!   /* For now, assume that "*default*" is the run-time memory region and
!      that no load-time region has been specified.  It doesn't really
!      matter what we say here, since lang_leave_overlay will override it.  */
!   lang_leave_output_section_statement (fill, "*default*", phdrs, 0);
  
    /* Define the magic symbols.  */
  
*************** lang_leave_overlay_section (fill, phdrs)
*** 4926,4957 ****
     looks through all the sections in the overlay and sets them.  */
  
  void
! lang_leave_overlay (fill, memspec, phdrs, lma_memspec)
       fill_type *fill;
       const char *memspec;
       struct lang_output_section_phdr_list *phdrs;
       const char *lma_memspec;
  {
    lang_memory_region_type *region;
-   lang_memory_region_type * default_region;
    lang_memory_region_type *lma_region;
    struct overlay_list *l;
    struct lang_nocrossref *nocrossref;
  
!   default_region = lang_memory_region_lookup ("*default*");
! 
!   if (memspec == NULL)
!     region = NULL;
!   else
!     region = lang_memory_region_lookup (memspec);
! 
!   if (lma_memspec == NULL)
!     lma_region = NULL;
!   else
!     lma_region = lang_memory_region_lookup (lma_memspec);
  
    nocrossref = NULL;
  
    l = overlay_list;
    while (l != NULL)
      {
--- 4919,4948 ----
     looks through all the sections in the overlay and sets them.  */
  
  void
! lang_leave_overlay (lma_expr, nocrossrefs, fill, memspec, phdrs, lma_memspec)
!      etree_type *lma_expr;
!      int nocrossrefs;
       fill_type *fill;
       const char *memspec;
       struct lang_output_section_phdr_list *phdrs;
       const char *lma_memspec;
  {
    lang_memory_region_type *region;
    lang_memory_region_type *lma_region;
    struct overlay_list *l;
    struct lang_nocrossref *nocrossref;
  
!   region = lang_memory_region_lookup (memspec);
!   lma_region = lang_memory_region_lookup (lma_memspec);
  
    nocrossref = NULL;
  
+   /* After setting the size of the last section, set '.' to end of the
+      overlay region.  */
+   if (overlay_list != NULL)
+     overlay_list->os->update_dot_tree
+       = exp_assop ('=', ".", exp_binop ('+', overlay_vma, overlay_max));
+ 
    l = overlay_list;
    while (l != NULL)
      {
*************** lang_leave_overlay (fill, memspec, phdrs
*** 4960,4987 ****
        if (fill != (fill_type *) 0 && l->os->fill == (fill_type *) 0)
  	l->os->fill = fill;
  
!       /* Assign a region to the sections, if one has been specified.
! 	 Override the assignment of the default section, but not
! 	 other sections.  */
!       if (region != NULL &&
! 	  (l->os->region == NULL ||
! 	   l->os->region == default_region))
! 	l->os->region = region;
  
!       /* We only set lma_region for the first overlay section, as
! 	 subsequent overlay sections will have load_base set relative
! 	 to the first section.  Also, don't set lma_region if
! 	 load_base is specified.  FIXME:  There should really be a test
! 	 that `AT ( LDADDR )' doesn't conflict with `AT >LMA_REGION'
! 	 rather than letting LDADDR simply override LMA_REGION.  */
!       if (lma_region != NULL && l->os->lma_region == NULL
! 	  && l->next == NULL && l->os->load_base == NULL)
! 	l->os->lma_region = lma_region;
  
        if (phdrs != NULL && l->os->phdrs == NULL)
  	l->os->phdrs = phdrs;
  
!       if (overlay_nocrossrefs)
  	{
  	  struct lang_nocrossref *nc;
  
--- 4951,4974 ----
        if (fill != (fill_type *) 0 && l->os->fill == (fill_type *) 0)
  	l->os->fill = fill;
  
!       l->os->region = region;
!       l->os->lma_region = lma_region;
  
!       /* The first section has the load address specified in the
! 	 OVERLAY statement.  The rest are worked out from that.
! 	 The base address is not needed (and should be null) if
! 	 an LMA region was specified.  */
!       if (l->next == 0)
! 	l->os->load_base = lma_expr;
!       else if (lma_region == 0)
! 	l->os->load_base = exp_binop ('+',
! 				      exp_nameop (LOADADDR, l->next->os->name),
! 				      exp_nameop (SIZEOF, l->next->os->name));
  
        if (phdrs != NULL && l->os->phdrs == NULL)
  	l->os->phdrs = phdrs;
  
!       if (nocrossrefs)
  	{
  	  struct lang_nocrossref *nc;
  
*************** lang_leave_overlay (fill, memspec, phdrs
*** 4999,5011 ****
    if (nocrossref != NULL)
      lang_add_nocrossref (nocrossref);
  
-   /* Update . for the end of the overlay.  */
-   lang_add_assignment (exp_assop ('=', ".",
- 				  exp_binop ('+', overlay_vma, overlay_max)));
- 
    overlay_vma = NULL;
-   overlay_lma = NULL;
-   overlay_nocrossrefs = 0;
    overlay_list = NULL;
    overlay_max = NULL;
  }
--- 4986,4992 ----
Index: testsuite/lib/ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.13
diff -c -p -d -r1.13 ld-lib.exp
*** testsuite/lib/ld-lib.exp	31 Jan 2002 03:57:52 -0000	1.13
--- testsuite/lib/ld-lib.exp	1 May 2002 18:00:44 -0000
*************** proc default_ld_nm { nm nmflags object }
*** 323,328 ****
--- 323,351 ----
  }
  
  #
+ # is_elf_format
+ #	true if the object format is known to be ELF
+ #
+ proc is_elf_format {} {
+     if { ![istarget *-*-sysv4*] \
+ 	 && ![istarget *-*-unixware*] \
+ 	 && ![istarget *-*-elf*] \
+ 	 && ![istarget *-*-eabi*] \
+ 	 && ![istarget *-*-linux*] \
+ 	 && ![istarget *-*-irix5*] \
+ 	 && ![istarget *-*-irix6*] \
+ 	 && ![istarget *-*-solaris2*] } {
+ 	return 0
+     }
+ 
+     if { [istarget *-*-linux*aout*] \
+ 	 || [istarget *-*-linux*oldld*] } {
+ 	return 0
+     }
+     return 1
+ }
+ 
+ #
  # simple_diff
  #	compares two files line-by-line
  #	returns differences if exist
*************** proc run_dump_test { name } {
*** 685,691 ****
      # Perhaps link the file(s).
      if { $run_ld } {
  	set objfile "tmpdir/dump"
! 	set cmd "$LD $LDFLAGS $opts(ld) -o $objfile $objfiles"
  
  	send_log "$cmd\n"
  	set cmdret [catch "exec $cmd" comp_output]
--- 708,718 ----
      # Perhaps link the file(s).
      if { $run_ld } {
  	set objfile "tmpdir/dump"
! 
! 	# Add -L$srcdir/$subdir so that the linker command can use
! 	# linker scripts in the source directory.
! 	set cmd "$LD $LDFLAGS -L$srcdir/$subdir \
! 		   $opts(ld) -o $objfile $objfiles"
  
  	send_log "$cmd\n"
  	set cmdret [catch "exec $cmd" comp_output]
Index: testsuite/ld-scripts/weak.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/weak.exp,v
retrieving revision 1.5
diff -c -p -d -r1.5 weak.exp
*** testsuite/ld-scripts/weak.exp	13 Mar 2001 06:14:28 -0000	1.5
--- testsuite/ld-scripts/weak.exp	1 May 2002 18:00:44 -0000
*************** set testname "weak symbols"
*** 21,42 ****
  
  # This test only works for ELF targets.  It ought to work for some
  # a.out targets, but it doesn't.
! 
! if { ![istarget *-*-sysv4*] \
!      && ![istarget *-*-unixware*] \
!      && ![istarget *-*-elf*] \
!      && ![istarget *-*-eabi*] \
!      && ![istarget *-*-linux*] \
!      && ![istarget *-*-irix5*] \
!      && ![istarget *-*-irix6*] \
!      && ![istarget *-*-solaris2*] } then {
      return
  }
  
- if { [istarget *-*-linux*aout*] \
-      || [istarget *-*-linux*oldld*] } {
-     return
- }
  
  if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
      || ! [ld_assemble $as $srcdir/$subdir/weak2.s tmpdir/weak2.o]} then {
--- 21,30 ----
  
  # This test only works for ELF targets.  It ought to work for some
  # a.out targets, but it doesn't.
! if ![is_elf_format] {
      return
  }
  
  
  if {! [ld_assemble $as $srcdir/$subdir/weak1.s tmpdir/weak1.o]
      || ! [ld_assemble $as $srcdir/$subdir/weak2.s tmpdir/weak2.o]} then {
*** /dev/null	Tue Nov 14 21:44:43 2000
--- testsuite/ld-scripts/overlay-size.d	Wed May  1 18:11:50 2002
***************
*** 0 ****
--- 1,26 ----
+ # ld: -T overlay-size.t -Map tmpdir/overlay-size.map
+ # name: overlay size
+ # objdump: --headers
+ #...
+   0 \.bss1 +0+010 +0+20000 +0+20000 .*
+ #...
+   1 \.bss2 +0+030 +0+20000 +0+20010 .*
+ #...
+   2 \.bss3 +0+020 +0+20000 +0+20040 .*
+ #...
+   3 \.mtext +0+020 +0+10000 +0+30000 .*
+ #...
+   4 \.mbss +0+230 +0+20030 +0+20060 .*
+ #...
+   5 \.text1 +0+080 +0+10020 +0+30020 .*
+ #...
+   6 \.text2 +0+040 +0+10020 +0+300a0 .*
+ #...
+   7 \.text3 +0+020 +0+10020 +0+300e0 .*
+ #...
+   8 \.data1 +0+030 +0+20260 +0+30100 .*
+ #...
+   9 \.data2 +0+040 +0+20260 +0+30130 .*
+ #...
+  10 \.data3 +0+050 +0+20260 +0+30170 .*
+ #pass
*** /dev/null	Tue Nov 14 21:44:43 2000
--- testsuite/ld-scripts/overlay-size.exp	Wed May  1 19:00:37 2002
***************
*** 0 ****
--- 1,31 ----
+ # Test the OVERLAY statement.
+ # Copyright 2002 Free Software Foundation, Inc.
+ #
+ # This file is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or
+ # (at your option) any later version.
+ # 
+ # This program is distributed in the hope that it will be useful,
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ # GNU General Public License for more details.
+ # 
+ # You should have received a copy of the GNU General Public License
+ # along with this program; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ 
+ if ![is_elf_format] {
+     return
+ }
+ 
+ run_dump_test overlay-size
+ 
+ set testname "overlay size (map check)"
+ 
+ if [regexp_diff "tmpdir/overlay-size.map" \
+ 	        "$srcdir/$subdir/overlay-size-map.d"] {
+     fail $testname
+ } else {
+     pass $testname
+ }
*** /dev/null	Tue Nov 14 21:44:43 2000
--- testsuite/ld-scripts/overlay-size-map.d	Wed May  1 18:36:59 2002
***************
*** 0 ****
--- 1,23 ----
+ #...
+ \.bss1 *0x0*20000 *0x10
+ #...
+ \.bss2 *0x0*20000 *0x30 load address 0x0*20010
+ #...
+ \.bss3 *0x0*20000 *0x20 load address 0x0*20040
+ #...
+ \.mtext *0x0*10000 *0x20 load address 0x0*30000
+ #...
+ \.mbss *0x0*20030 *0x230 load address 0x0*20060
+ #...
+ \.text1 *0x0*10020 *0x80 load address 0x0*30020
+ #...
+ \.text2 *0x0*10020 *0x40 load address 0x0*300a0
+ #...
+ \.text3 *0x0*10020 *0x20 load address 0x0*300e0
+ #...
+ \.data1 *0x0*20260 *0x30 load address 0x0*30100
+ #...
+ \.data2 *0x0*20260 *0x40 load address 0x0*30130
+ #...
+ \.data3 *0x0*20260 *0x50 load address 0x0*30170
+ #pass
*** /dev/null	Tue Nov 14 21:44:43 2000
--- testsuite/ld-scripts/overlay-size.s	Wed May  1 18:10:48 2002
***************
*** 0 ****
--- 1,25 ----
+ 	.section .bss1, "aw", "nobits"
+ 	.space 0x10
+ 	.section .bss2, "aw", "nobits"
+ 	.space 0x30
+ 	.section .bss3, "aw", "nobits"
+ 	.space 0x20
+ 
+ 	.section .text1, "ax", "progbits"
+ 	.space 0x80
+ 	.section .text2, "ax", "progbits"
+ 	.space 0x40
+ 	.section .text3, "ax", "progbits"
+ 	.space 0x20
+ 
+ 	.section .data1, "aw", "progbits"
+ 	.space 0x30
+ 	.section .data2, "aw", "progbits"
+ 	.space 0x40
+ 	.section .data3, "aw", "progbits"
+ 	.space 0x50
+ 
+ 	.section .mtext, "ax", "progbits"
+ 	.space 0x20
+ 	.section .mbss, "aw", "nobits"
+ 	.space 0x30
*** /dev/null	Tue Nov 14 21:44:43 2000
--- testsuite/ld-scripts/overlay-size.t	Wed May  1 18:11:07 2002
***************
*** 0 ****
--- 1,57 ----
+ MEMORY
+ {
+   TEXTMEM (ARX) : ORIGIN = 0x10000, LENGTH = 32K
+   DATAMEM (AW)  : ORIGIN = 0x20000, LENGTH = 32K
+   LOADMEM (AW)  : ORIGIN = 0x30000, LENGTH = 32K
+ }
+ 
+ /* Map should be:
+ 
+            SIZE    VMA    LMA
+    .bss1     10  20000  20000
+    .bss2     30  20000  20010
+    .bss3     20  20000  20040
+    .mbss    230  20030  20060
+ 
+    .mtext    20  10000  30000
+    .text1    80  10020  30020
+    .text2    40  10020  300a0
+    .text3    20  10020  300e0
+ 
+    .data1    30  20260  30100
+    .data2    40  20260  30130
+    .data3    50  20260  30170  */
+ 
+ SECTIONS
+ {
+   OVERLAY : 
+     {
+       .bss1 { *(.bss1) }
+       .bss2 { *(.bss2) }
+       .bss3 { *(.bss3) }
+     } > DATAMEM
+ 
+   .mtext : { *(.mtext) } > TEXTMEM AT > LOADMEM
+ 
+   .mbss : AT (__load_stop_bss3)
+     {
+       *(.mbss)
+       . += 0x200;
+     } > DATAMEM
+ 
+   OVERLAY :
+     {
+       .text1 { *(.text1) }
+       .text2 { *(.text2) }
+       .text3 { *(.text3) }
+     } > TEXTMEM AT > LOADMEM
+ 
+   OVERLAY :
+     {
+       .data1 { *(.data1) }
+       .data2 { *(.data2) }
+       .data3 { *(.data3) }
+     } > DATAMEM AT > LOADMEM
+ 
+   . = 0x8000;
+ }


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