bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/24567] New: Assertion failure in ldlang.c:6868 when compiling wi


From: ohngeonocaewoungooth at xff dot cz
Subject: [Bug ld/24567] New: Assertion failure in ldlang.c:6868 when compiling with -flto
Date: Thu, 16 May 2019 15:31:34 +0000

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

            Bug ID: 24567
           Summary: Assertion failure in ldlang.c:6868 when compiling with
                    -flto
           Product: binutils
           Version: 2.33 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: ohngeonocaewoungooth at xff dot cz
  Target Milestone: ---

I've originally reported this issue in gcc bugzilla here:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90392 but because it's an
assertion failure in ld, maybe I'll have more chances that someone will help me
solve this here.

The assertion failure happens when cross-compiling openssl with
aarch64-linux-musl cross-compiler (gcc 9.1.0) with -flto (non-lto build works
fine) in ldlang.c:6868:

void
ldlang_add_file (lang_input_statement_type *entry)
{
  lang_statement_append (&file_chain,
                         (lang_statement_union_type *) entry,
                         &entry->next);

  /* The BFD linker needs to have a list of all input BFDs involved in
     a link.  */
  ASSERT (entry->the_bfd->link.next == NULL);      <----- line 6868
  ASSERT (entry->the_bfd != link_info.output_bfd);


I've added this code prior to the asserts:

  info_msg ("A:%pI\n", entry);
  info_msg ("B:%pB\n", entry->the_bfd);
  if (entry->the_bfd->link.next)
    info_msg ("C:%pB\n", entry->the_bfd->link.next);

This results in this output (I also have -Wl,--trace enabled here):

.....snip....

A:/workspace/megous.com/apps-c/static-deps/toolchains/aarch64-linux-musl/lib/gcc/aarch64-linux-musl/9.0.1/crtend.o
B:/workspace/megous.com/apps-c/static-deps/toolchains/aarch64-linux-musl/lib/gcc/aarch64-linux-musl/9.0.1/crtend.o
attempt to open
/workspace/megous.com/apps-c/static-deps/toolchains/aarch64-linux-musl/lib/gcc/aarch64-linux-musl/9.0.1/../../../../aarch64-linux-musl/lib/crtn.o
succeeded
/workspace/megous.com/apps-c/static-deps/toolchains/aarch64-linux-musl/lib/gcc/aarch64-linux-musl/9.0.1/../../../../aarch64-linux-musl/lib/crtn.o
A:/workspace/megous.com/apps-c/static-deps/toolchains/aarch64-linux-musl/lib/gcc/aarch64-linux-musl/9.0.1/../../../../aarch64-linux-musl/lib/crtn.o
B:/workspace/megous.com/apps-c/static-deps/toolchains/aarch64-linux-musl/lib/gcc/aarch64-linux-musl/9.0.1/../../../../aarch64-linux-musl/lib/crtn.o
apps/libapps.a
./libssl.a
./libcrypto.a
A:armcap.o
B:armcap.o (symbol from plugin)
C:a_bitstr.o (symbol from plugin)
/workspace/megous.com/apps-c/static-deps/toolchains/aarch64-linux-musl/lib/gcc/aarch64-linux-musl/9.0.1/../../../../aarch64-linux-musl/bin/ld:
internal error
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldlang.c
6873

That is, as soon as libcrypto.a starts being linked, the assertion fails. The
linked list at entry->the_bfd->link.next is not empty, but seems to contains
object files from the libcrypto.a archive. (I'v explored a few items in the
list in gdb)

I'v compiled the HEAD of binutils with -Og -g and prepared a simple script that
runs ld under gdb for easy debugging.

This is the backtrace at the point of the assertion failure:

#0  ldlang_add_file (entry=0x55555871adf0) at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldlang.c:6868
#1  0x00005555555a0531 in add_archive_element (info=0x5555558092a0 <link_info>,
abfd=0x555557c1aa50, name=0x7ffff7f9e12b "OPENSSL_armcap_P",
subsbfd=0x7fffffffcd00)
    at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldmain.c:850
#2  0x000055555560be2c in elf_link_add_archive_symbols (abfd=0x555556073f00,
info=0x5555558092a0 <link_info>)
    at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/bfd/elflink.c:5718
#3  0x000055555561775b in bfd_elf_link_add_symbols (abfd=<optimized out>,
info=<optimized out>) at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/bfd/elflink.c:5774
#4  0x000055555559cade in load_symbols (entry=0x555555835310,
place=0x7fffffffcdb0) at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldlang.c:3081
#5  0x000055555559d597 in open_input_bfds (s=0x555555835310,
mode=OPEN_BFD_FORCE) at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldlang.c:3530
#6  0x000055555559d525 in open_input_bfds (s=0x55555582e230,
mode=OPEN_BFD_NORMAL) at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldlang.c:3485
#7  0x000055555559e235 in lang_process () at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldlang.c:7383
#8  0x00005555555a0e2a in main (argc=<optimized out>, argv=<optimized out>) at
/workspace/megous.com/apps-c/static-deps/toolchains/sources/binutils-gdb/ld/ldmain.c:441

And here I'm out of my wits. :)

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]