This is the mail archive of the 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]

Re: [RFA:] Use refcount in SH ELF backend

> This patch affects SHMEDIA code for which I can't do enough
> tests, so should be checked by SH5 experts.

I've been looking at SHmedia-related problems in this area
recently.  I was thinking it may be necessary to introduce
refcounts to get the gotplt relocations working properly,
so I'm pleased you've done this.

I looked at your patch today - there are a few SHmedia related

- The datalabel got references really ought to be counted
  in the same way that the normal got references are.
  I'd suggest turning datalabel_got_offset into a union:

!   union
!   {
!     bfd_signed_vma refcount;
!     bfd_vma offset;
!   } datalabel_got;

  to make this cleaner.
- In allocate_dynrelocs(), an shmedia symbol may need to be given two
  got entries, one if h->got.refcount > 0, and another if
  h->datalabel_got.refcount > 0.  There's no need for the
  if (h->type == STT_DATALABEL) code: this flag isn't set in the
  true symbol, it's set in an indirect symbol that points to the
  true symbol (and indirect symbols are ignored here).  Anyhow, at this
  point you can just look at the h->datalabel_got.refcount to see
  if you need to allocate a got entry for the datalabel version.

- In sh_elf_gc_sweep_hook when decrementing got refcounts,
  you need to know whether to decrement the refcount of the got
  offset or of the datalabel got offset.
  For a global symbol, this can be deduced using a loop through
  indirect symbols looking for the STT_DATALABEL flag (just like
  seen_stt_datalabel is set in other functions).
  If seen_stt_datalabel is true, then decrement
  h->datalabel_got.refcount, otherwise decrement h->got.refcount.
  For a local symbol, you either want to decrement
  local_got_refcounts[symtab_hdr->sh_info + r_symndx] or
  local_got_refcounts[r_symndx], something like this:

            if (rel->r_addend & 1)
                if (local_got_refcounts[symtab_hdr->sh_info + r_symndx] > 0)
                  local_got_refcounts[symtab_hdr->sh_info + r_symndx] -= 1;
            else if (local_got_refcounts[r_symndx] > 0)
	        local_got_refcounts[r_symndx] -= 1;    

- In sh_elf_check_relocs, when incrementing got refcounts, you
  need to know whether to increment the refcount of the got
  offset or of the datalabel got offset.
  Should be just like the handling of this in sh_elf_gc_sweep_hook.

- sh_elf_copy_indirect_symbol should copy the datalabel_got
  refcount and offset in the same way as _bfd_elf_link_hash_copy_indirect
  copies the normal got offset.  This is missing from the current
  cvs version, but it is necessary.

I've merged your patch into my working sources, with the above
fixes.  We are currently bringing up glibc on SH-5, so I'll let you
know if I find any more issues.

Stephen Clarke, Principal Engineer, SuperH Inc.
Phone:1-408-922-4062, Fax:1-408-954-8507,
Mail:  SuperH Inc., 3801 Zanker Rd., San Jose, CA 95134, USA.

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