* elf64-ppc.c (ppc64_elf_edit_toc): Clear "repeat" inside

loop.  Really mark toc entry referring to another toc entry
	only if the first is used.
This commit is contained in:
Alan Modra
2012-11-05 05:17:34 +00:00
parent 26a4e9cbc4
commit d4f1ee75e7
2 changed files with 138 additions and 126 deletions

@ -1,3 +1,9 @@
2012-11-05 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc64_elf_edit_toc): Clear "repeat" inside
loop. Really mark toc entry referring to another toc entry
only if the first is used.
2012-10-30 H.J. Lu <hongjiu.lu@intel.com> 2012-10-30 H.J. Lu <hongjiu.lu@intel.com>
* configure.in: Also handle --enable-64-bit-bfd when setting * configure.in: Also handle --enable-64-bit-bfd when setting

@ -8372,8 +8372,9 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
goto error_ret; goto error_ret;
/* Mark toc entries referenced as used. */ /* Mark toc entries referenced as used. */
repeat = 0;
do do
{
repeat = 0;
for (rel = relstart; rel < relstart + sec->reloc_count; ++rel) for (rel = relstart; rel < relstart + sec->reloc_count; ++rel)
{ {
enum elf_ppc64_reloc_type r_type; enum elf_ppc64_reloc_type r_type;
@ -8487,8 +8488,10 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
break; break;
case R_PPC64_TOC16_LO_DS: case R_PPC64_TOC16_LO_DS:
off = rel->r_offset + (bfd_big_endian (ibfd) ? -2 : 3); off = rel->r_offset;
if (!bfd_get_section_contents (ibfd, sec, &opc, off, 1)) off += (bfd_big_endian (ibfd) ? -2 : 3);
if (!bfd_get_section_contents (ibfd, sec, &opc,
off, 1))
{ {
free (used); free (used);
goto error_ret; goto error_ret;
@ -8504,18 +8507,21 @@ ppc64_elf_edit_toc (struct bfd_link_info *info)
} }
} }
/* For the toc section, we only mark as used if if (sec != toc)
this entry itself isn't unused. */ used[val >> 3] = 1;
if (sec == toc /* For the toc section, we only mark as used if this
&& !used[val >> 3] entry itself isn't unused. */
&& (used[rel->r_offset >> 3] else if ((used[rel->r_offset >> 3]
|| !(skip[rel->r_offset >> 3] & ref_from_discarded))) || !(skip[rel->r_offset >> 3] & ref_from_discarded))
&& !used[val >> 3])
{
/* Do all the relocs again, to catch reference /* Do all the relocs again, to catch reference
chains. */ chains. */
repeat = 1; repeat = 1;
used[val >> 3] = 1; used[val >> 3] = 1;
} }
}
}
while (repeat); while (repeat);
if (elf_section_data (sec)->relocs != relstart) if (elf_section_data (sec)->relocs != relstart)