This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: binutils is broken on ELF/mips (Re: binutils is broken on Linux/alpha)
On Thu, Oct 04, 2001 at 11:00:25AM +0930, Alan Modra wrote:
> On Wed, Oct 03, 2001 at 03:12:38PM -0700, H . J . Lu wrote:
> > >
> > > Alan, your latest patch is still not correct for all ELF targets.
> > > ELF/mips doesn't use refcount. However, -1 offset and 0 offset have
> > > special meanings. Now, with your change, ELF/mips is broken. I believe
> > > you need to do
> > >
> > > # grep "t\.offset" elf*.?
> > >
> > > and exam every single useage of it. Could you please fix it?
>
> I did do that, but obviously not well enough. Actually, what I used was
> emacs `find . -type f \! -name \*~ \! -name .\#\* \! -name \#\* \! -name ChangeLog\* \! -name TAGS | xargs egrep -l '(plt|got)\.(offset|refcount)'`
>
> > Ok, you don't need to exam all. Here is a subset:
>
> It appears that mips is the only back end that does weird things with
> got.offset (or plt.offset). Please test whether this patch fixes the
> problem.
>
> * elf32-mips.c (mips_elf_record_global_got_symbol): Set got.offset
> to 1 rather than 0 to avoid confusing copy_indirect_symbol.
> (mips_elf_sort_hash_table_f): Compare got.offset against 1.
>
> Index: bfd/elf32-mips.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elf32-mips.c,v
> retrieving revision 1.115
> diff -u -p -r1.115 elf32-mips.c
> --- elf32-mips.c 2001/09/21 14:25:08 1.115
> +++ elf32-mips.c 2001/10/04 01:25:10
> @@ -5502,14 +5502,15 @@ mips_elf_record_global_got_symbol (h, in
> && !bfd_elf32_link_record_dynamic_symbol (info, h))
> return false;
>
> - /* If we've already marked this entry as need GOT space, we don't
> + /* If we've already marked this entry as needing GOT space, we don't
> need to do it again. */
> - if (h->got.offset != (bfd_vma) - 1)
> + if (h->got.offset != (bfd_vma) -1)
> return true;
>
> /* By setting this to a value other than -1, we are indicating that
> - there needs to be a GOT entry for H. */
> - h->got.offset = 0;
> + there needs to be a GOT entry for H. Avoid using zero, as the
> + generic ELF copy_indirect_symbol tests for <= 0. */
> + h->got.offset = 1;
>
> return true;
> }
> @@ -5547,7 +5548,7 @@ mips_elf_sort_hash_table_f (h, data)
> if (h->root.dynindx == -1)
> return true;
>
> - if (h->root.got.offset != 0)
> + if (h->root.got.offset != 1)
> h->root.dynindx = hsd->max_non_got_dynindx++;
> else
> {
It passed my testcase. It is ok with me. I will let you know if I find
anything else wrong. I think I am quite good at it :-(.
Thanks.
H.J.