This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PowerPC64 ld segfault on R_PPC64_TOC16_LO absolute symbol
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Sun, 27 Jun 2010 18:08:34 +0930
- Subject: PowerPC64 ld segfault on R_PPC64_TOC16_LO absolute symbol
The PowerPC64 gcc -mcmodel=medium option, now removed, made ld
segfault in get_tls_mask due to a bug when handling TOC16_LO relocs
against absolute symbols. Even though gcc no longer generates this
code, it's worth fixing ld.
* elf64-ppc.c (get_tls_mask): Don't segfault on NULL elf_section_data.
(group_sections): Likewise.
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.329
diff -u -p -r1.329 elf64-ppc.c
--- bfd/elf64-ppc.c 27 Jun 2010 04:07:53 -0000 1.329
+++ bfd/elf64-ppc.c 27 Jun 2010 04:21:28 -0000
@@ -6689,6 +6689,7 @@ get_tls_mask (unsigned char **tls_maskp,
if ((*tls_maskp != NULL && **tls_maskp != 0)
|| sec == NULL
+ || ppc64_elf_section_data (sec) == NULL
|| ppc64_elf_section_data (sec)->sec_type != sec_toc)
return 1;
@@ -10666,7 +10667,8 @@ group_sections (struct ppc_link_hash_tab
curr = tail;
total = tail->size;
- big_sec = total > (ppc64_elf_section_data (tail)->has_14bit_branch
+ big_sec = total > (ppc64_elf_section_data (tail) != NULL
+ && ppc64_elf_section_data (tail)->has_14bit_branch
? stub14_group_size : stub_group_size);
if (big_sec && !suppress_size_errors)
(*_bfd_error_handler) (_("%B section %A exceeds stub group size"),
@@ -10675,7 +10677,8 @@ group_sections (struct ppc_link_hash_tab
while ((prev = PREV_SEC (curr)) != NULL
&& ((total += curr->output_offset - prev->output_offset)
- < (ppc64_elf_section_data (prev)->has_14bit_branch
+ < (ppc64_elf_section_data (prev) != NULL
+ && ppc64_elf_section_data (prev)->has_14bit_branch
? stub14_group_size : stub_group_size))
&& htab->stub_group[prev->id].toc_off == curr_toc)
curr = prev;
@@ -10708,7 +10711,8 @@ group_sections (struct ppc_link_hash_tab
total = 0;
while (prev != NULL
&& ((total += tail->output_offset - prev->output_offset)
- < (ppc64_elf_section_data (prev)->has_14bit_branch
+ < (ppc64_elf_section_data (prev) != NULL
+ && ppc64_elf_section_data (prev)->has_14bit_branch
? stub14_group_size : stub_group_size))
&& htab->stub_group[prev->id].toc_off == curr_toc)
{
--
Alan Modra
Australia Development Lab, IBM