Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2013-05

BFD (GNU Binutils) 2.23.1 assertion fail elf32-arm.c:12328

5 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bruce Tulloch

Next step in my ARM cross compilation journey...this error...

It's produced by arm-linux.ld which I've built from binutils upstream source (2.23.1) and am using for cross compiling using FPC 2.7.1.

It occurs when building a large project so I've not identified what may be triggering it yet. The relevant part of the ld source is:

      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;
        }

which says the procedure linkage table reference count is already zero when it should not be.

An apparently relevant discussion about it is here:

http://sourceware.org/ml/binutils/2012-04/msg00228.html

according to which, this assert arises in arm-linux-gnueabi when:

- There's a reference (call-reloc) to a symbol undefined at first reference, preliminary requiring a PLT.

- The symbols' definition is found in the linked objects and is hidden (or forced local).

- The referencing section (containing the call-reloc) is GC'd (its global symbols are forced local by the version script and found to be unused).

Then, the gc_sweep function tries to balance the books by -= 1 on the now-GC'd-away PLT (with refcount set to -1 from the already forced-local symbol) which is guarded by a "BFD_ASSERT (root_plt->refcount > 0)". So the assert strikes.

I will try to isolate what part of my build triggers this but I thought I'd post details in case anyone more familiar with GNU linking on ARM can suggest anything.

Bruce.

Reply by email

Bruce Tulloch
to Bruce Tulloch

The patch and a link to the bug report that generated it is here:

https://dev.openwrt.org/browser/trunk/toolchain/binutils/patches/2.22/500-arm_ld_assert_fix.patch?rev=35812

Bruce Tulloch wrote 49 lines
Next step in my ARM cross compilation journey...this error... It's produced by arm-linux.ld which I've built from binutils upstream source (2.23.1) and am using for cross compiling using FPC 2.7.1. It occurs when building a large project so I've not identified what may be triggering it yet. The relevant part of the ld source is: 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; } which says the procedure linkage table reference count is already zero when it should not be. An apparently relevant discussion about it is here: http://sourceware.org/ml/binutils/2012-04/msg00228.html according to which, this assert arises in arm-linux-gnueabi when: - There's a reference (call-reloc) to a symbol undefined at first reference, preliminary requiring a PLT. - The symbols' definition is found in the linked objects and is hidden (or forced local). - The referencing section (containing the call-reloc) is GC'd (its global symbols are forced local by the version script and found to be unused). Then, the gc_sweep function tries to balance the books by -= 1 on the now-GC'd-away PLT (with refcount set to -1 from the already forced-local symbol) which is guarded by a "BFD_ASSERT (root_plt->refcount > 0)". So the assert strikes. I will try to isolate what part of my build triggers this but I thought I'd post details in case anyone more familiar with GNU linking on ARM can suggest anything. Bruce.

Reply by email

Bruce Tulloch
to Bruce Tulloch

Okay it appears this problem is related to smart link; removal of -XX avoids it.

Given advances with dead code elimination in ld I'm guessing smartlink isn't really needed these days anyway or is there still some advantage to it at the compiler level?

Bruce.

Reply by email

Jonas Maebe
to Bruce Tulloch
Bruce Tulloch wrote 5 lines
Okay it appears this problem is related to smart link; removal of -XX avoids it. Given advances with dead code elimination in ld I'm guessing smartlink isn't really needed these days anyway or is there still some advantage to it at the compiler level?

"Smart linking" is simply the term used in the (Borland-derivative) Pascal community to describe dead code stripping/elimination. If you don't use -XX, the compiler will not instruct the linker to eliminate dead code.

Jonas

Reply by email

Bruce Tulloch
to Jonas Maebe

Okay, well that would seem to imply there's a problem with dead code stripping in binutils 2.23.1, at least for this arm target if all FPC is doing is instructing ld to strip dead code but is otherwise doing nothing else differently. No matter, I'll just not use it for now, thanks.

On a related point, presumably there is no point specifying -CX without -XX?

Bruce

Jonas Maebe wrote 15 lines
On 25 May 2013, at 06:22, Bruce Tulloch wrote: > Okay it appears this problem is related to smart link; removal of -XX avoids it. > > Given advances with dead code elimination in ld I'm guessing smartlink > isn't really needed these days anyway or is there still some advantage > to it at the compiler level? "Smart linking" is simply the term used in the (Borland-derivative) Pascal community to describe dead code stripping/elimination. If you don't use -XX, the compiler will not instruct the linker to eliminate dead code. Jonas_______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel

Reply by email