--gc-sections causes assertion failure

Bug #1216106 reported by slide
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Linaro Binutils
Incomplete
Undecided
Unassigned
Linaro Toolchain Binaries
New
Undecided
Charles Baylis

Bug Description

When running with the Linaro GCC 4.8.1 2013.08 release, I get the following assertion when using -ffunction-sections and -fdata-sections to GCC along with --gc-sections to LD. From searching the web, it looks like there are various possible reasons for the assertion in upstream binutils, but I couldn't narrow it down directly as they were slightly different.

c:/gnu/arm-none-eabi-4.8.1/bin/../lib/gcc/arm-none-eabi/4.8.1/../../../../arm-none-eabi/bin/ld.exe: BFD (GNU Binutils) 2.23.2 assertion fail ../../../src/binutils-2.23.2/bfd/elf32-arm.c:12334

This corresponds to the first assert in the code below:

if (may_need_local_target_p
   && elf32_arm_get_plt_info (abfd, eh, r_symndx, &root_plt, &arm_plt))
 {
   /* If PLT refcount book-keeping is wrong and too low, we'll
      see a zero value (going to -1) for the root PLT reference
      count. */
   if (root_plt->refcount >= 0)
     {
       BFD_ASSERT (root_plt->refcount != 0);
       root_plt->refcount -= 1;
     }
   else
     /* A value of -1 means the symbol has become local, forced
        or seeing a hidden definition. Any other negative value
        is an error. */
     BFD_ASSERT (root_plt->refcount == -1);

Tags: binutils
Changed in linaro-toolchain-binaries:
assignee: nobody → Charles Baylis (cbaylis)
Revision history for this message
Charles Baylis (cbaylis) wrote :

Thanks for the bug report. Unfortunately, I can't reproduce this problem, could you provide an example or a link to code which causes this?

Revision history for this message
slide (slide-o-mix) wrote :

I will try and create a minimal test case to reproduce the issue and attach it. I forgot to mention that I am using the mingw32 version of the compiler.

Revision history for this message
Charles Baylis (cbaylis) wrote :

Did you manage to reproduce this?

Revision history for this message
slide (slide-o-mix) wrote :

I haven't been able to reproduce it outside of my environment yet. Is there something I can look for in my code that might cause this issue to appear so I can zero in a test case a little better?

Revision history for this message
slide (slide-o-mix) wrote :

I'm more than willing to add in additional debug to the binutils source as well if that will help, I just don't know what add and to where.

Revision history for this message
Will Newton (will-newton) wrote :

Can you still reproduce this issue?

I haven't been able to come up with a way that the code could get the refcounts out of sync in this way (which doesn't mean its not possible, just that its not obvious).

Even a moderately complex reproducer is fine as long as it comes with clear instructions.

Thanks,

Changed in binutils-linaro:
status: New → Incomplete
Revision history for this message
slide (slide-o-mix) wrote :

I can't seem to replicate this with the 4.9 release from 2014-07, so I think it can be closed out.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.