This is the mail archive of the gdb-prs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug gdb/20861] New: BFD assertion fail bfd/linker.c:3131


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

            Bug ID: 20861
           Summary: BFD assertion fail bfd/linker.c:3131
           Product: gdb
           Version: 7.12.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gdb
          Assignee: unassigned at sourceware dot org
          Reporter: chrisfriedt at gmail dot com
  Target Milestone: ---

Created attachment 9665
  --> https://sourceware.org/bugzilla/attachment.cgi?id=9665&action=edit
Patch required to compile on Mac OS X 10.12.1 (see commit message for details)

Hi,

I'm on Mac OS X 10.12.1 and have compiled gdb from git (gdb-7.12-branch) for
x86_64-pc-linux.

I've configured my build using the following:

CFLAGS="-O2 -pipe -I/usr/local/include" \
  CXXFLAGS="-O2 -pipe -I/usr/local/include" \
  LDFLAGS="-L/usr/local/lib" \
  ../binutils-gdb/configure --prefix=/usr/local --target=x86_64-pc-linux

I had to apply a small patch (which is attached) to get it to build succesfully
(I assume that since the procedures were originally void, returning TRUE is
fine).

I'm attaching to a gdbserver instance in a linux vm for a simple executable
(originally I was trying to debug my Linux kernel, but that hit the same wall,
so I opted to submit a simple test case).

$ cat hello.c
#include <stdio.h>

int main( int argc, char *argv[] ) {
  printf( "Hello, world!\n" );
  return 0;
}

$ x86_64-pc-linux-gcc -O0 -g -o hello hello.c

$ file hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.4.0, not stripped

Copied hello to the vm.

livecd ~ # gdbserver localhost:4321 hello
Process hello created; pid = 4455
Listening on port 4321
...
<see below>
...
Remote debugging from host 172.16.1.1
Remote side has terminated connection.  GDBserver will reopen the connection.
Listening on port 4321

$ x86_64-pc-linux-gdb
GNU gdb (GDB) 7.12.0.20161123-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-apple-darwin16.1.0
--target=x86_64-pc-linux".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) target remote gentoo:4321
Remote debugging using gentoo:4321
Reading /root/hello from remote target...
warning: File transfers from remote targets can be slow. Use "set sysroot" to
access files locally instead.
Reading /root/hello from remote target...
Reading symbols from target:/root/hello...BFD: BFD (GNU Binutils) 2.27.51
assertion fail ../../binutils-gdb/bfd/linker.c:3131
Segmentation fault: 11

>From bfd/linker.c:

bfd_boolean
bfd_generic_define_common_symbol (bfd *output_bfd,
                                  struct bfd_link_info *info ATTRIBUTE_UNUSED,
                                  struct bfd_link_hash_entry *h)
{
  unsigned int power_of_two;
  bfd_vma alignment, size;
  asection *section;

  BFD_ASSERT (h != NULL && h->type == bfd_link_hash_common);

  size = h->u.c.size;
  power_of_two = h->u.c.p->alignment_power;
  section = h->u.c.p->section;
...

In this case, h is actually NULL (I split the BFD_ASSERT into two separate
assertions to check) and it seems to be required given that it is dereferenced
in the next few lines.

Note: I have used this setup before with an older version of gdb and have not
encountered this issue in the past. I don't have the exact versions, but it was
likely about a year ago.

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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]