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]

Re: another round of h8300-rtems/coff problems


Should I leave the previous patch in as well?

Alan Modra wrote:
> 
> On Thu, 2 Nov 2000, I wrote:
> 
> > my way around the coff code.  The snag I hit with this simple "fix" is
> > that coff_slurp_reloc_table is called too early in the link process to
> > have set up section->offset, and saves away the relocs in asect->relocation.
> > When called later, at a stage where we could make use of section->offset,
> > nothing happens in coff_slurp_reloc_table because the saved relocs are
> > available.  Looks like a generic coff bug.
> 
> Try this one.
> 
> bfd/ChangeLog
>         * coffcode.h (coff_slurp_reloc_table): Move asect->relocation test
>         from here..
>         (coff_canonicalize_reloc): ..to here.  Adjust reloc addresses for
>         relocatable link.
> 
> Alan Modra
> --
> Linuxcare.  Support for the Revolution.
> 
> Index: coffcode.h
> ===================================================================
> RCS file: /cvs/src/src/bfd/coffcode.h,v
> retrieving revision 1.47
> diff -u -p -r1.47 coffcode.h
> --- coffcode.h  2000/10/06 19:47:51     1.47
> +++ coffcode.h  2000/11/02 07:02:33
> @@ -4745,8 +4745,6 @@ coff_slurp_reloc_table (abfd, asect, sym
> 
>    unsigned int idx;
> 
> -  if (asect->relocation)
> -    return true;
>    if (asect->reloc_count == 0)
>      return true;
>    if (asect->flags & SEC_CONSTRUCTOR)
> @@ -4883,9 +4881,7 @@ coff_canonicalize_reloc (abfd, section,
>       arelent ** relptr;
>       asymbol ** symbols;
>  {
> -  arelent *tblptr = section->relocation;
> -  unsigned int count = 0;
> -
> +  unsigned int count;
> 
>    if (section->flags & SEC_CONSTRUCTOR)
>      {
> @@ -4902,16 +4898,32 @@ coff_canonicalize_reloc (abfd, section,
>      }
>    else
>      {
> -      if (! coff_slurp_reloc_table (abfd, section, symbols))
> -       return -1;
> +      arelent *tblptr = section->relocation;
> 
> -      tblptr = section->relocation;
> +      if (tblptr != NULL)
> +       {
> +         /* We have already been called once during the load_symbols
> +            stage of a link.  If called again, it's from the ldwrite
> +            stage of a relocatable link.  We need to adjust all the
> +            reloc offsets here in that case.  */
> +         if (section->output_offset != 0)
> +           for (count = 0; count < section->reloc_count; count++)
> +             {
> +               tblptr->address += section->output_offset;
> +               tblptr++;
> +             }
> +       }
> +      else
> +       {
> +         if (! coff_slurp_reloc_table (abfd, section, symbols))
> +           return -1;
> +       }
> 
> -      for (; count++ < section->reloc_count;)
> +      tblptr = section->relocation;
> +      for (count = 0; count < section->reloc_count; count++)
>         *relptr++ = tblptr++;
> -
> -
>      }
> +
>    *relptr = 0;
>    return section->reloc_count;
>  }

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel@OARcorp.com                 On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
   Support Available             (256) 722-9985

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