This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: PATCH: BZ/175: Fix dynamic string offset
On Sat, May 22, 2004 at 11:27:22AM +0930, Alan Modra wrote:
> On Thu, May 20, 2004 at 08:30:24PM -0700, H. J. Lu wrote:
> > On Fri, May 21, 2004 at 10:55:03AM +0930, Alan Modra wrote:
> > > I think it quite possible that this patch will break other accesses
> > > into merged sections. To properly fix the problem, you would need to
> > > distinguish this particular access from others. Perhaps the reloc used
> > > might give you enough information.
> >
> > Good idea. Here it is.
>
> > * elfxx-ia64.c (elfNN_ia64_relax_section): Call
> > _bfd_merged_section_offset with irel->r_addend as dynamic
> > offset if it isn't a branch.
>
> I doubt this patch is complete. If you need to special case certain
> accesses in relax_section, how is it that relocate_section escapes a
> need for the same special case code? This might prove more difficult,
> as you might need to pull apart _bfd_elf_rela_local_sym. I'm also still
> concerned that other ia64 code sequences might use R_IA64_LTOFF22X in a
> way that requires you include the addend. Please discuss this with Jim,
> I'm not familiar enough with ia64 to know.
>
elfNN_ia64_relax_section shouldn't calls _bfd_merged_section_offset just
because tsec->sec_info_type == ELF_INFO_TYPE_MERGE. For local symbols,
it should also check
(tsec->flags & SEC_MERGE) && ELF_ST_TYPE (isym->st_info) == STT_SECTION
H.J.
----
2004-05-25 H.J. Lu <hongjiu.lu@intel.com>
* elfxx-ia64.c (elfNN_ia64_relax_section): Properly call
_bfd_merged_section_offset for local symbols.
--- bfd/elfxx-ia64.c.merge 2004-05-19 08:30:21.000000000 -0700
+++ bfd/elfxx-ia64.c 2004-05-25 18:05:02.936045175 -0700
@@ -874,6 +874,16 @@ elfNN_ia64_relax_section (abfd, sec, lin
toff = isym->st_value;
dyn_i = get_dyn_sym_info (ia64_info, NULL, abfd, irel, FALSE);
+
+ if ((tsec->flags & SEC_MERGE)
+ && ELF_ST_TYPE (isym->st_info) == STT_SECTION
+ && tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
+ toff = _bfd_merged_section_offset (abfd, &tsec,
+ elf_section_data (tsec)->sec_info,
+ toff + irel->r_addend,
+ (bfd_vma) 0);
+ else
+ toff += irel->r_addend;
}
else
{
@@ -918,16 +928,16 @@ elfNN_ia64_relax_section (abfd, sec, lin
tsec = h->root.u.def.section;
toff = h->root.u.def.value;
}
+
+ if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
+ toff = _bfd_merged_section_offset (abfd, &tsec,
+ elf_section_data (tsec)->sec_info,
+ toff + irel->r_addend,
+ (bfd_vma) 0);
+ else
+ toff += irel->r_addend;
}
- if (tsec->sec_info_type == ELF_INFO_TYPE_MERGE)
- toff = _bfd_merged_section_offset (abfd, &tsec,
- elf_section_data (tsec)->sec_info,
- toff + irel->r_addend,
- (bfd_vma) 0);
- else
- toff += irel->r_addend;
-
symaddr = tsec->output_section->vma + tsec->output_offset + toff;
roff = irel->r_offset;