This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH, bfin] Clear relocs for removed entries in .eh_frame section
- From: Alan Modra <amodra at bigpond dot net dot au>
- To: Jie Zhang <jzhang918 at gmail dot com>
- Cc: binutils at sourceware dot org, Alexandre Oliva <aoliva at redhat dot com>, Bernd Schmidt <bernds_cb1 at t-online dot de>
- Date: Wed, 26 Apr 2006 16:02:29 +0930
- Subject: Re: [PATCH, bfin] Clear relocs for removed entries in .eh_frame section
- References: <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