This is the mail archive of the binutils@sourceware.org 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: PATCH: Don't check relocations against reloc sections


On Thu, Apr 12, 2012 at 6:45 PM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, Apr 12, 2012 at 11:37:05AM -0700, H.J. Lu wrote:
>> @@ -10370,6 +10370,15 @@ bfd_elf_final_link (bfd *abfd, struct bfd_link_info *info)
>> ? ?for (o = abfd->sections; o != NULL; o = o->next)
>> ? ? ?{
>> ? ? ? ?struct bfd_elf_section_data *esdo = elf_section_data (o);
>> +
>> + ? ? ?if (esdo->this_hdr.sh_type == SHT_REL
>> + ? ? ? || esdo->this_hdr.sh_type == SHT_RELA)
>> + ? ? {
>> + ? ? ? /* There should be no relocations against reloc sections. ?*/
>> + ? ? ? BFD_ASSERT (!(o->flags & SEC_RELOC) && o->reloc_count == 0);
>> + ? ? ? continue;
>> + ? ? }
>> +
>> ? ? ? ?o->reloc_count = 0;
>>
>> ? ? ? ?for (p = o->map_head.link_order; p != NULL; p = p->next)
>
> This doesn't look to be correct. ?Code below this point does more than
> just count relocs. ?Try this instead.
>
> Index: bfd/elflink.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elflink.c,v
> retrieving revision 1.436
> diff -u -p -r1.436 elflink.c
> --- bfd/elflink.c ? ? ? 12 Apr 2012 07:35:04 -0000 ? ? ?1.436
> +++ bfd/elflink.c ? ? ? 13 Apr 2012 01:43:23 -0000
> @@ -10396,7 +10396,13 @@ bfd_elf_final_link (bfd *abfd, struct bf
> ? ? ? ? ? ? ?if (sec->flags & SEC_MERGE)
> ? ? ? ? ? ? ? ?merged = TRUE;
>
> - ? ? ? ? ? ? if (info->relocatable || info->emitrelocations)
> + ? ? ? ? ? ? if (esdo->this_hdr.sh_type == SHT_REL
> + ? ? ? ? ? ? ? ? || esdo->this_hdr.sh_type == SHT_RELA)
> + ? ? ? ? ? ? ? /* Some backends use reloc_count in relocation sections
> + ? ? ? ? ? ? ? ? ?to count particular types of relocs. ?Of course,
> + ? ? ? ? ? ? ? ? ?reloc sections themselves can't have relocations. ?*/
> + ? ? ? ? ? ? ? reloc_count = 0;
> + ? ? ? ? ? ? else if (info->relocatable || info->emitrelocations)
> ? ? ? ? ? ? ? ?reloc_count = sec->reloc_count;
> ? ? ? ? ? ? ?else if (bed->elf_backend_count_relocs)
> ? ? ? ? ? ? ? ?reloc_count = (*bed->elf_backend_count_relocs) (info, sec);
>

It works.

Thanks.

-- 
H.J.


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