https://sourceware.org/bugzilla/show_bug.cgi?id=20401

            Bug ID: 20401
           Summary: segfault in fini_reloc_cookie_rels() with
                    --gc-sections
           Product: binutils
           Version: 2.26
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: sezeroz at gmail dot com
  Target Milestone: ---

We ran into a segfault with the djgpp port of ld in fini_reloc_cookie_rels()
when --gc-sections is used.  It appears that coff_section_data (NULL, sec)
i.e. (sec)->used_by_bfd is NULL.  The issue seems to have started with the
git commit 0f088b2a.  My workaround is like the following:

diff -urNp binutils-2.26/bfd/coffgen.c.orig binutils-2.26/bfd/coffgen.c
--- binutils-2.26/bfd/coffgen.c.orig    2015-11-13 10:27:40.000000000 +0200
+++ binutils-2.26/bfd/coffgen.c 2016-07-22 11:41:02.000000000 +0300
@@ -2688,7 +2688,7 @@
 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 && (!coff_section_data (NULL, sec) || coff_section_data
(NULL, sec)->relocs != cookie->rels))
     free (cookie->rels);
 }


It is possible that this is a wrong way of fixing it.  The coff maintainers
surely would do it correctly.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils

Reply via email to