Subject: toolchain/17942: ld: bfd assertion fail and segmentation fault
To: None <gnats-bugs@gnats.netbsd.org>
From: None <ChristianBiere@gmx.de>
List: netbsd-bugs
Date: 08/14/2002 16:53:49
>Number:         17942
>Category:       toolchain
>Synopsis:       ld: bfd assertion fail and segmentation fault
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Aug 14 16:54:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Christian Biere
>Release:        NetBSD 1.6_BETA4
>Organization:
>Environment:
NetBSD localhost 1.6_BETA4 NetBSD 1.6_BETA4 (DURON) #1: Sat Aug 10 12:09:01 CEST 2002     root@localhost:/usr/src-1-6/sys/arch/i386/compile/DURON i386
>Description:
ld crashes when using a shared object file with -R:

1st case:

ld: warning: cannot find entry symbol _start; defaulting to 08048074
/usr/lib/libc.so: undefined reference to `environ'
/usr/lib/libc.so: undefined reference to `__progname'
ld: bfd assertion fail /usr/src/gnu/lib/libbfd/../../dist/toolchain/bfd/elf32-i386.c:2004
Segmentation fault

2nd case:

ld: warning: cannot find entry symbol _start; defaulting to 08048074
/usr/lib/libc.so: undefined reference to `environ'
/usr/lib/libc.so: undefined reference to `__progname'
Segmentation fault

This is around line 2004 from elf32-i386.c:
2002: get_vma:
2003:   s = bfd_get_section_by_name (output_bfd, name);
2004:   BFD_ASSERT (s != NULL);
2005:   dyn.d_un.d_ptr = s->vma;
2006:   bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon);
2007:   break;

>How-To-Repeat:
1st case:

$ cat > blah.c <<EOF
  #include <stdio.h>
     int main(int argc, char *argv[]) {
     printf("blah");
    
    }
 EOF
$ gcc -c blah.c
$ ld blah.o -R/usr/lib/libc.so

2nd case:

$ echo "int main(int argc, char *argv[]){}" > blah.c
$ gcc -c blah.c
$ ld -R/usr/lib/libc.so blah.o

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted: