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

            Bug ID: 20267
           Summary: ld.bfd crash when link with LLVMgold.so plugin
           Product: binutils
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: zyfwong at gmail dot com
  Target Milestone: ---

=== foo.c ====
int global_var;

=== main.c ====
int global_var;
int main(void)
{
  return global_var;
}

void _start()
{
  main();
}

=== Compile ===
$ clang -emit-llvm -Os foo.c -c foo.o
$ ar rs --plugin LLVMgold.so foo.a foo.o
$ clang -emit-llvm -Os main.c -c main.o
$ ld --plugin LLVMgold.so main.o foo.a
segmentation fault (core dumped)

ld.bfd will crash in `elf_link_is_defined_archive_symbol`.

The original code:
  /* Return FALSE if the object has been claimed by plugin.  */
  if (abfd->plugin_format == bfd_plugin_yes)
    return FALSE;

  if (! bfd_check_format (abfd, bfd_object))
    return FALSE;

If I add one more check after `bfd_check_format`, it seems that the problem is
fixed:

  if (abfd->plugin_format == bfd_plugin_yes)
    return FALSE;

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