From: Nick Clifton Date: Wed, 27 Jul 2016 12:18:13 +0000 (+0100) Subject: Fix seg fault in linker when performing garbage collection on COFF based targets. X-Git-Tag: binutils-2_27~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=492a7a54d688b511b0ed47c1f0ab054334a4b218;p=external%2Fbinutils.git Fix seg fault in linker when performing garbage collection on COFF based targets. PR ld/20401 bfd * coffgen.c (fini_reloc_cookie_rels): Check for the extistence of the coff_section_data before using it. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 992e54e..1e08f3d 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +2016-07-27 Nick Clifton + + * Import this patch from the mainline: + 2016-07-27 Ozkan Sezer + Nick Clifton + + PR ld/20401 + * coffgen.c (fini_reloc_cookie_rels): Check for the extistence + of the coff_section_data before using it. + 2016-07-01 Tristan Gingold * version.m4: Bump version to 2.26.90 diff --git a/bfd/coffgen.c b/bfd/coffgen.c index 56864ca..75512fb 100644 --- a/bfd/coffgen.c +++ b/bfd/coffgen.c @@ -2691,7 +2691,13 @@ static void fini_reloc_cookie_rels (struct coff_reloc_cookie *cookie, asection *sec) { - if (cookie->rels && coff_section_data (NULL, sec)->relocs != cookie->rels) + if (cookie->rels + /* PR 20401. The relocs may not have been cached, so check first. + If the relocs were loaded by init_reloc_cookie_rels() then this + will be the case. FIXME: Would performance be improved if the + relocs *were* cached ? */ + && coff_section_data (NULL, sec) + && coff_section_data (NULL, sec)->relocs != cookie->rels) free (cookie->rels); }