This is the mail archive of the binutils@sourceware.org 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: Fix address assignment for variables declared immediately after overlay sections


Hi Guys,

  I am checking in the attached patch to fix a bug reported by a
  customer:  When a set of overlayed sections have different sizes,
  the linker guarantees that the effective size as seen by objects
  outside of the overlay is the size of the largest section inside the
  overlay.  This has been working for assignment of locations to
  sections after the overlay, but not for the assignment of locations
  to variables defined immediately after the overlay.

  The patch fixes this problem and extends the overlay-size test in
  the linker testsuite to include checks for the correct assignment of
  values.  Checked by running regression tests for loads of different
  toolchains.

Cheers
  Nick

ld/ChangeLog
2008-06-12  Nick Clifton  <nickc@redhat.com>

	* ldlang.c (print_output_section_statement): If the output section
	statement has an update_dot_tree expression, apply it to
	print_dot.
	(print_input_section): Do not update print_dot if it would move
	print_dot backwards.
	(lang_do_assignments_1): If the output section statement has an
	update_dot_tree expression apply it to dot.

ld/testsuite/ChangeLog
2008-06-12  Nick Clifton  <nickc@redhat.com>

	* ld-scripts/overlay-size.t (end_of_bss_overlays): Define.
	(end_of_text_overlays): Define.
	(end_of_data_overlays): Define.
	* ld-scripts/overlay-size-map.d: Add expected values for
	end_of_bss_overlays, end_of_text_overlays and
	end_of_data_overlays.

Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.288
diff -c -3 -p -r1.288 ldlang.c
*** ld/ldlang.c	7 Jun 2008 11:35:46 -0000	1.288
--- ld/ldlang.c	12 Jun 2008 11:15:05 -0000
*************** print_output_section_statement
*** 3653,3658 ****
--- 3653,3662 ----
  
  	  if (section->vma != section->lma)
  	    minfo (_(" load address 0x%V"), section->lma);
+ 
+ 	  if (output_section_statement->update_dot_tree != NULL)
+ 	    exp_fold_tree (output_section_statement->update_dot_tree,
+ 			   bfd_abs_section_ptr, &print_dot);
  	}
  
        print_nl ();
*************** print_input_section (asection *i)
*** 3899,3905 ****
        else
  	print_all_symbols (i);
  
!       print_dot = addr + TO_ADDR (size);
      }
  }
  
--- 3903,3913 ----
        else
  	print_all_symbols (i);
  
!       /* Update print_dot, but make sure that we do not move it
! 	 backwards - this could happen if we have overlays and a
! 	 later overlay is shorter than an earier one.  */
!       if (addr + TO_ADDR (size) > print_dot)
! 	print_dot = addr + TO_ADDR (size);
      }
  }
  
*************** lang_do_assignments_1 (lang_statement_un
*** 5151,5156 ****
--- 5159,5167 ----
  		    || (os->bfd_section->flags & SEC_THREAD_LOCAL) == 0
  		    || link_info.relocatable)
  		  dot += TO_ADDR (os->bfd_section->size);
+ 
+ 		if (os->update_dot_tree != NULL)
+ 		  exp_fold_tree (os->update_dot_tree, bfd_abs_section_ptr, &dot);
  	      }
  	  }
  	  break;
Index: ld/testsuite/ld-scripts/overlay-size.t
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/overlay-size.t,v
retrieving revision 1.2
diff -c -3 -p -r1.2 overlay-size.t
*** ld/testsuite/ld-scripts/overlay-size.t	15 Sep 2006 16:19:33 -0000	1.2
--- ld/testsuite/ld-scripts/overlay-size.t	12 Jun 2008 11:15:05 -0000
*************** SECTIONS
*** 31,36 ****
--- 31,38 ----
        .bss3 { *(.bss3) }
      } > DATAMEM
  
+   end_of_bss_overlays = . ;
+     
    .mtext : { *(.mtext) } > TEXTMEM AT > LOADMEM
  
    .mbss : AT (__load_stop_bss3)
*************** SECTIONS
*** 46,51 ****
--- 48,55 ----
        .text3 { *(.text3) }
      } > TEXTMEM AT > LOADMEM
  
+   end_of_text_overlays = . ;
+ 
    OVERLAY :
      {
        .data1 { *(.data1) }
*************** SECTIONS
*** 53,58 ****
--- 57,64 ----
        .data3 { *(.data3) }
      } > DATAMEM AT > LOADMEM
  
+   end_of_data_overlays = . ;
+   
    . = 0x8000;
    /DISCARD/ : { *(.reginfo) }
  }
Index: ld/testsuite/ld-scripts/overlay-size-map.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-scripts/overlay-size-map.d,v
retrieving revision 1.4
diff -c -3 -p -r1.4 overlay-size-map.d
*** ld/testsuite/ld-scripts/overlay-size-map.d	12 Dec 2006 08:10:40 -0000	1.4
--- ld/testsuite/ld-scripts/overlay-size-map.d	12 Jun 2008 11:15:05 -0000
***************
*** 5,10 ****
--- 5,12 ----
  #...
  \.bss3 *0x0*20000 *0x20 load address 0x0*20040
  #...
+ .*0x0+020030[ 	]*end_of_bss_overlays.*
+ #...
  \.mtext *0x0*10000 *0x20 load address 0x0*30000
  #...
  \.mbss *0x0*20030 *0x230 load address 0x0*20060
***************
*** 15,23 ****
--- 17,29 ----
  #...
  \.text3 *0x0*10020 *0x20 load address 0x0*300e0
  #...
+ .*0x0+0100a0[ 	]*end_of_text_overlays.*
+ #...
  \.data1 *0x0*20260 *0x30 load address 0x0*30100
  #...
  \.data2 *0x0*20260 *0x40 load address 0x0*30130
  #...
  \.data3 *0x0*20260 *0x50 load address 0x0*30170
+ #...
+ .*0x0+0202b0[ 	]*end_of_data_overlays.*
  #pass

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