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]

[RFA:] Relaxation-related fixes in bfd/reloc.c, ld/ldlang.c


These two patches are necessary for a linker relaxation implementation
for MMIX.  The bfd/reloc.c one is actually a bug fix, exposed by
having linker relaxation and the mmo format's use of the default
relaxation machinery (it doesn't handle relocs; input is in other
formats).  Noteworthy: of all tests, ld/ld-bootstrap "bootstrap with
--relax" on i686-pc-linux-gnu caught me when I set _cooked_size
unconditionally in bfd_generic_relax_section.  See the comment.

About the ld/ldlang.c patch, there seems to be no hooks to
enable the MMIX port to keep track of output section size in
relaxation rounds on its own.

Due to the delicate nature of fiddling with the relocation
machinery and as a field test before other sweeping changes, for
example the coordinate system change {_raw_size, _cooked_size} ->
{_orig_size, _size_delta} (other names solicited) that Alan
volunteered me for, I (ab)used the Hewlett-Packard testdrive
system (thank you) to make sure there were no regressions for
the following targets in a unified tree except ada (how's that
for a run-on-sentence):

 Testing gas, binutils, ld only:
sparc64-elf, ip2k-elf, z8k-coff, mmix-knuth-mmixware, m32r-elf,
mips-ecoff (gas testsuite has lots of failures, not regressions),
sh64-unknown-elf, powerpc-eabisim, xstormy16-elf, xtensa-elf,
cris-elf

 Cross-testing of gas, binutils, ld and gcc using simulators:
h8300-coff, arm-elf, sh-coff, mips-elf, m68hc11-elf
v850-elf, h8300-elf, mn10300-elf, sh-elf.

 Bootstrap and general make check:
i686-pc-linux-gnu (default), ia64-unknown-linux-gnu,
alphaev67-unknown-linux-gnu i686-pc-linux-gnu (--enable-targets=all
--enable-64-bit-bfd)

Ok to commit?

bfd:
	* reloc.c (bfd_generic_relax_section): Default-set
	section->_cooked_size here.
	(bfd_generic_get_relocated_section_contents): Don't set it here.
	Explain why.

ld:
	* ldlang.c (lang_size_sections): Last, set _cooked_size for output
	sections.

Index: bfd/reloc.c
===================================================================
RCS file: /cvs/src/src/bfd/reloc.c,v
retrieving revision 1.91
diff -p -c -r1.91 reloc.c
*** bfd/reloc.c	25 Aug 2003 12:39:14 -0000	1.91
--- bfd/reloc.c	12 Oct 2003 13:06:42 -0000
*************** SYNOPSIS
*** 4029,4035 ****

  DESCRIPTION
  	Provides default handling for relaxing for back ends which
! 	don't do relaxing -- i.e., does nothing.
  */

  bfd_boolean
--- 4031,4038 ----

  DESCRIPTION
  	Provides default handling for relaxing for back ends which
! 	don't do relaxing -- i.e., does nothing except make sure that the
! 	final size of the section is set.
  */

  bfd_boolean
*************** bfd_generic_relax_section (bfd *abfd ATT
*** 4038,4043 ****
--- 4041,4051 ----
  			   struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
  			   bfd_boolean *again)
  {
+   /* We're not relaxing the section, so just copy the size info if it's
+      zero.  Someone else, like bfd_merge_sections, might have set it, so
+      don't overwrite a non-zero value.  */
+   if (section->_cooked_size == 0)
+     section->_cooked_size = section->_raw_size;
    *again = FALSE;
    return TRUE;
  }
*************** bfd_generic_get_relocated_section_conten
*** 4132,4139 ****
  				 input_section->_raw_size))
      goto error_return;

!   /* We're not relaxing the section, so just copy the size info.  */
!   input_section->_cooked_size = input_section->_raw_size;
    input_section->reloc_done = TRUE;

    reloc_count = bfd_canonicalize_reloc (input_bfd,
--- 4140,4152 ----
  				 input_section->_raw_size))
      goto error_return;

!   /* Don't set input_section->_cooked_size here.  The caller has set
!      _cooked_size or called bfd_relax_section, which sets _cooked_size.
!      Despite using this generic relocation function, some targets perform
!      target-specific relaxation or string merging, which happens before
!      this function is called.  We do not want to clobber the _cooked_size
!      they computed.  */
!
    input_section->reloc_done = TRUE;

    reloc_count = bfd_canonicalize_reloc (input_bfd,
Index: ld/ldlang.c
===================================================================
RCS file: /cvs/src/src/ld/ldlang.c,v
retrieving revision 1.119
diff -p -c -r1.119 ldlang.c
*** ld/ldlang.c	11 Oct 2003 09:16:20 -0000	1.119
--- ld/ldlang.c	12 Oct 2003 13:06:45 -0000
*************** lang_size_sections
*** 3227,3232 ****
--- 3227,3233 ----
     bfd_boolean check_regions)
  {
    bfd_vma result;
+   asection *o;

    /* Callers of exp_fold_tree need to increment this.  */
    lang_statement_iteration++;
*************** lang_size_sections
*** 3252,3257 ****
--- 3253,3266 ----
  					 fill, dot, relax, check_regions);
  	}
      }
+
+   /* Some backend relaxers want to refer to the output section size.  Give
+      them a section size that does not change on the next call while they
+      relax.  We can't set this at top because lang_reset_memory_regions
+      which is called before we get here, sets _raw_size to 0 on relaxing
+      rounds.  */
+   for (o = output_bfd->sections; o != NULL; o = o->next)
+     o->_cooked_size = o->_raw_size;

    return result;
  }

brgds, H-P


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