PATCH: fix som_get_reloc_upper_bound if no reloc

Tristan Gingold gingold@adacore.com
Wed Sep 26 08:13:00 GMT 2007


On Sep 26, 2007, at 1:23 AM, Alan Modra wrote:

> On Tue, Sep 25, 2007 at 05:14:49PM +0100, Nick Clifton wrote:
>> Hi Tristan,
>>
>>> This seems to be an obvious patch: if there are no relocs,
>>> bfd_get_reloc_upper_bound should returns
>>> sizeof (arelent *) for the ending NULL (and not 0).
>>
>> I am not so sure about this.  If the section does not have any relocs
>> associated with it then there should be no need to store anything,  
>> not even
>> a NUL reloc.  So returning 0 seems to be the correct thing to me.
>
> som_get_reloc_upper_bound returns the number of bytes needed by
> som_canonicalize_reloc.  The latter function returns a NULL terminated
> array of pointers.  So one of these functions need changing.  I think
> Tristan's patch is the right way to go.

I just tried to be coherent with other implementations.  For example  
in elf.c:

long
_bfd_elf_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED,
				sec_ptr asect)
{
   return (asect->reloc_count + 1) * sizeof (arelent *);
}





More information about the Binutils mailing list