public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@bigpond.net.au>
To: Jie Zhang <jzhang918@gmail.com>
Cc: binutils@sourceware.org, Alexandre Oliva <aoliva@redhat.com>,
		Bernd Schmidt <bernds_cb1@t-online.de>
Subject: Re: [PATCH, bfin] Clear relocs for removed entries in .eh_frame section
Date: Wed, 26 Apr 2006 09:34:00 -0000	[thread overview]
Message-ID: <20060426063229.GV27430@bubble.grove.modra.org> (raw)
In-Reply-To: <6f48278f0604252045u3b055875v1a3e1e8bfab74a22@mail.gmail.com>

On Wed, Apr 26, 2006 at 11:45:19AM +0800, Jie Zhang wrote:
> 1. I saw this in elflink.c:elf_link_input_bfd ()
> 
> 		      /* This is a reloc for a deleted entry or somesuch.
> 			 Turn it into an R_*_NONE reloc, at the same
> 			 offset as the last reloc.  elf_eh_frame.c and
> 			 elf_bfd_discard_info rely on reloc offsets
> 			 being ordered.  */
> 
> In my patch I just set the offset to zero. It seems works. I don't
> know if we need do the same.
> 
> Alan: The comment was from you. Can you help me understand it?

bfd_elf_discard_info indirectly calls bfd_elf_reloc_symbol_deleted_p,
which scans relocs looking for a particular offset.

  for (; rcookie->rel < rcookie->relend; rcookie->rel++)
    {
      unsigned long r_symndx;

      if (! rcookie->bad_symtab)
	if (rcookie->rel->r_offset > offset)
	  return FALSE;
      if (rcookie->rel->r_offset != offset)
	continue;

There are some macros in elf-eh-frame.c, ENSURE_NO_RELOCS and
SKIP_RELOCS that similarly test r_offset.  The above code won't work in
general if relocs are unordered.  However, I see that the way the code
is written, setting r_offset to zero is OK.  You just need to ensure
r_offset is not set to some larger value than r_offset in following
relocs.

> 2. In bfinfdpic_relocate_section () there are several calls to
> _bfd_elf_section_offset () before calling _bfinfdpic_add_dyn_reloc ().
> Only in one place the return value of _bfd_elf_section_offset () is
> checked in my patch. It seems works. But I'm not sure if we need add
> such check for all these calls.

If _bfd_elf_section_offset can return -1 or -2 then you need to add the
check.  If it cannot, eg. because the particular reloc type is not used
in eh_frame or stabs section, then you don't need the check.  Of course,
if you don't need the check, then you also don't need to call
_bfd_elf_section_offset.  :-)

> 3. Is it possible to not emit the reloc instead of set its type to R_*_NONE?

It's too late.  You have already allocated space for the dynamic relocs.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

  reply	other threads:[~2006-04-26  6:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-26  9:29 Jie Zhang
2006-04-26  9:34 ` Alan Modra [this message]
2006-04-27 16:42   ` Jie Zhang
2006-05-23  9:42 ` Jie Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060426063229.GV27430@bubble.grove.modra.org \
    --to=amodra@bigpond.net.au \
    --cc=aoliva@redhat.com \
    --cc=bernds_cb1@t-online.de \
    --cc=binutils@sourceware.org \
    --cc=jzhang918@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).