bug-binutils
[Top][All Lists]
Advanced

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

[Bug ld/17226] New: ld --gc-sections segfaults on sparc-linux


From: mikpelinux at gmail dot com
Subject: [Bug ld/17226] New: ld --gc-sections segfaults on sparc-linux
Date: Sun, 03 Aug 2014 11:50:46 +0000

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

            Bug ID: 17226
           Summary: ld --gc-sections segfaults on sparc-linux
           Product: binutils
           Version: 2.25 (HEAD)
            Status: NEW
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: mikpelinux at gmail dot com

Created attachment 7737
  --> https://sourceware.org/bugzilla/attachment.cgi?id=7737&action=edit
gcsec-1.s from GCC's testsuite

GCC's gcc/testsuite/gcc.dg/special/gcsec-1.c fails on sparc-linux because it
causes ld to segfault.  This is reproducible both natively on sparc-linux and
with cross toolchains hosted on x86_64-linux.  Occurs with (at least) binutils
2.25 (HEAD), 2.24, and 2.23.2.  Occurs with both 32 and 64-bit sparc targets.

To reproduce natively on sparc-linux, do sth like:

> gcc -m32 -c gcsec-1.s
> ld -m elf32_sparc -static -relax -o a.out /usr/lib/crt1.o /usr/lib/crti.o 
> /usr/lib/gcc/sparcv9-brewer-linux/4.7.4/crtbeginT.o gcsec-1.o --gc-sections 
> --start-group /usr/lib/libc.a 
> /usr/lib/gcc/sparcv9-brewer-linux/4.7.4/libgcc.a 
> /usr/lib/gcc/sparcv9-brewer-linux/4.7.4/libgcc_eh.a --end-group 
> /usr/lib/gcc/sparcv9-brewer-linux/4.7.4/crtend.o /usr/lib/crtn.o
Segmentation fault

Running the above in gdb shows:

Program received signal SIGSEGV, Segmentation fault.
0xf7f2ec2c in _bfd_sparc_elf_gc_sweep_hook (abfd=0x15ce98, info=0x9bc28
<link_info>, sec=0x16f418, relocs=<optimized out>) at elfxx-sparc.c:2003
2003                      if (local_got_refcounts[r_symndx] > 0)
Missing separate debuginfos, use: debuginfo-install
glibc-2.17-2.bl17.bl.2.sparcv9 libgcc-4.7.4-10.bl17.bl.2.sparcv9
zlib-1.2.5-7.bl17.sparcv9
(gdb) list
1998                    case R_SPARC_GOTDATA_OP_HIX22:
1999                    case R_SPARC_GOTDATA_OP_LOX10:
2000                      break;
2001
2002                    default:
2003                      if (local_got_refcounts[r_symndx] > 0)
2004                        local_got_refcounts[r_symndx]--;
2005                      break;
2006                    }
2007                }
(gdb) bt
#0  0xf7f2ec2c in _bfd_sparc_elf_gc_sweep_hook (abfd=0x15ce98, info=0x9bc28
<link_info>, sec=0x16f418, relocs=<optimized out>) at elfxx-sparc.c:2003
#1  0xf7f5e264 in elf_gc_sweep (info=0x9bc28 <link_info>, abfd=0xa9618) at
elflink.c:11936
#2  bfd_elf_gc_sections (abfd=0xa9618, info=0x9bc28 <link_info>) at
elflink.c:12199
#3  0x00028e58 in lang_gc_sections () at ldlang.c:6401
#4  lang_process () at ldlang.c:6744
#5  0x00013b04 in main (argc=19, argv=0xffffd2b4) at ./ldmain.c:386
(gdb) print local_got_refcounts
$1 = (bfd_signed_vma *) 0x0

Removing the --gc-sections option allows the link to succeed.

To reproduce with a cross toolchain, do sth like:

> sparc64-unknown-linux-gcc -m32 -c gcsec-1.s
> sparc64-unknown-linux-ld -m elf32_sparc -static -relax -o a.out 
> /home/mikpe/pkgs/linux-x86_64/cross-sparc64/usr/lib/crt1.o 
> /home/mikpe/pkgs/linux-x86_64/cross-sparc64/usr/lib/crti.o 
> /home/mikpe/pkgs/linux-x86_64/cross-sparc64/lib/gcc/sparc64-unknown-linux/4.8.3/32/crtbeginT.o
>  gcsec-1.o --gc-sections --start-group 
> /home/mikpe/pkgs/linux-x86_64/cross-sparc64/usr/lib/libc.a 
> /home/mikpe/pkgs/linux-x86_64/cross-sparc64/lib/gcc/sparc64-unknown-linux/4.8.3/32/libgcc.a
>  --end-group 
> /home/mikpe/pkgs/linux-x86_64/cross-sparc64/lib/gcc/sparc64-unknown-linux/4.8.3/32/crtend.o
>  /home/mikpe/pkgs/linux-x86_64/cross-sparc64/usr/lib/crtn.o
Segmentation fault

The cross toolchain was built with binutils-2.24, gcc-4.8.3, Linux 3.13 kernel
headers, and glibc-2.19.

I've tried to make the test case standalone, but simply stubbing out the
references to libc makes the segfault go away.

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