Bug 6888 - Segmentation fault for PowerPC ld and EABI + SDATA
Summary: Segmentation fault for PowerPC ld and EABI + SDATA
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.20
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-15 12:33 UTC by Sebastian Huber
Modified: 2008-09-15 23:48 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
Evil object file. (326 bytes, application/octet-stream)
2008-09-15 16:00 UTC, Sebastian Huber
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastian Huber 2008-09-15 12:33:43 UTC
The linker produces a segmentation fault on undefined references in the small
data area.

Test program:

extern int i;

void f()
{
        i = 1;
}

powerpc-rtems4.9-gcc -meabi -msdata -c test.c

Binutils version:

/tmp/binutils/bin/powerpc-rtems4.9-ld --version
GNU ld (GNU Binutils) 2.19.50.20080911
Copyright 2007 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

GDB output:

gdb --args /tmp/binutils/bin/powerpc-rtems4.9-ld test.o
GNU gdb 6.6.50.20070726-cvs
Copyright (C) 2007 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-suse-linux"...
Using host libthread_db library "/lib64/libthread_db.so.1".
(gdb) r
Starting program: /tmp/binutils/bin/powerpc-rtems4.9-ld test.o
/tmp/binutils/bin/powerpc-rtems4.9-ld: warning: cannot find entry symbol _start;
defaulting to 0000000001800054
test.o: In function `f':
test.c:(.text+0x10): undefined reference to `i'
/tmp/binutils/bin/powerpc-rtems4.9-ld: BFD (GNU Binutils) 2.19.50.20080911
assertion fail /home/sebastian_h/cvs-binutils/bfd/elf32-ppc.c:7076

Program received signal SIGSEGV, Segmentation fault.
ppc_elf_relocate_section (output_bfd=0x71aee0, info=0x706920,
input_bfd=0x727510, input_section=0x7299f8, contents=0x745900 "\224!��\223�",
    relocs=<value optimized out>, local_syms=0x7459f0, local_sections=0x745ae0)
at /home/sebastian_h/cvs-binutils/bfd/elf32-ppc.c:7077
7077                name = bfd_get_section_name (abfd, sec->output_section);
(gdb) info stack
#0  ppc_elf_relocate_section (output_bfd=0x71aee0, info=0x706920,
input_bfd=0x727510, input_section=0x7299f8, contents=0x745900 "\224!&#65533;&#65533;\223&#65533;",
    relocs=<value optimized out>, local_syms=0x7459f0, local_sections=0x745ae0)
at /home/sebastian_h/cvs-binutils/bfd/elf32-ppc.c:7077
#1  0x000000000045c0e2 in bfd_elf_final_link (abfd=0x71aee0, info=0x706920) at
/home/sebastian_h/cvs-binutils/bfd/elflink.c:9251
#2  0x0000000000415591 in ldwrite () at
/home/sebastian_h/cvs-binutils/ld/ldwrite.c:567
#3  0x0000000000414da2 in main (argc=2, argv=0x7fffa6ec6b98) at
/home/sebastian_h/cvs-binutils/ld/ldmain.c:462
(gdb) quit
Comment 1 Alan Modra 2008-09-15 15:52:46 UTC
Please attach test.o
Comment 2 Sebastian Huber 2008-09-15 16:00:55 UTC
Created attachment 2954 [details]
Evil object file.

Object file attached.