bug-binutils
[Top][All Lists]
Advanced

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

ld segfaults on parisc


From: Alexander Beregalov
Subject: ld segfaults on parisc
Date: Tue, 17 Mar 2009 16:46:29 +0300

Hi

address@hidden ~/linux-2.6 $ uname -a
Linux livecd 2.6.24-gentoo-r3-livecd32 #1 Mon Jun 16 18:59:19 UTC 2008
parisc PA8700 (PCX-W2) 9000/785/J6700 GNU/Linux

address@hidden ~/linux-2.6 $ binutils-config -l
 [1] hppa2.0-unknown-linux-gnu-2.19.51.0.3 *

address@hidden ~/linux-2.6 $ gcc -v
Using built-in specs.
Target: hppa2.0-unknown-linux-gnu
Configured with:
/var/tmp/portage/sys-devel/gcc-4.3.3-r1/work/gcc-4.3.3/configure
--prefix=/usr --bindir=/usr/hppa2.0-unknown-linux-gnu/gcc-bin/4.3.3
--includedir=/usr/lib/gcc/hppa2.0-unknown-linux-gnu/4.3.3/include
--datadir=/usr/share/gcc-data/hppa2.0-unknown-linux-gnu/4.3.3
--mandir=/usr/share/gcc-data/hppa2.0-unknown-linux-gnu/4.3.3/man
--infodir=/usr/share/gcc-data/hppa2.0-unknown-linux-gnu/4.3.3/info
--with-gxx-include-dir=/usr/lib/gcc/hppa2.0-unknown-linux-gnu/4.3.3/include/g++-v4
--host=hppa2.0-unknown-linux-gnu --build=hppa2.0-unknown-linux-gnu
--disable-altivec --disable-fixed-point --disable-nls
--with-system-zlib --disable-checking --disable-werror
--enable-secureplt --disable-multilib --disable-libmudflap
--disable-libssp --disable-libgomp --enable-cld --disable-libgcj
--enable-languages=c,c++,treelang --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu
--with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo
4.3.3-r1 p1.1, pie-10.1.5'
Thread model: posix
gcc version 4.3.3 (Gentoo 4.3.3-r1 p1.1, pie-10.1.5)


address@hidden ~/linux-2.6 $ ld --build-id -o .tmp_vmlinux1 -T
arch/parisc/kernel/vmlinux.lds arch/parisc/kernel/head.o
init/built-in.o --start-group usr/built-in.o arch/parisc/mm/built-in.o
arch/parisc/kernel/built-in.o arch/parisc/math-emu/built-in.o
arch/parisc/kernel/init_task.o kernel/built-in.o mm/built-in.o
fs/built-in.o ipc/built-in.o security/built-in.o crypto/built-in.o
block/built-in.o lib/lib.a arch/parisc/lib/lib.a `gcc
-print-libgcc-file-name` lib/built-in.o arch/parisc/lib/built-in.o
`gcc -print-libgcc-file-name` drivers/built-in.o sound/built-in.o
firmware/built-in.o net/built-in.o --end-group
ld: Segmentation fault

gdb:

Program received signal SIGSEGV, Segmentation fault.
strlen (str=0xc84 <Address 0xc84 out of bounds>) at strlen.c:64
64            /* 64-bit version of the magic.  */
(gdb) bt
#0  strlen (str=0xc84 <Address 0xc84 out of bounds>) at strlen.c:64
#1  0x407b7530 in _IO_vfprintf_internal (s=0xfb1487a0,
    format=0xfb147d80 "arch/parisc/kernel/built-in.o(.text+0x%lx):
cannot reach %s, recompile with -ffunction-sections", ap=0xfb147d0c)
    at vfprintf.c:1581
#2  0x407b8284 in buffered_vfprintf (s=0x408bfb98, format=0xfb147da9
"): cannot reach %s, recompile with -ffunction-sections",
    args=0xfb14a850) at vfprintf.c:2188
#3  0x407b42e0 in _IO_vfprintf_internal (s=0x408bfb98,
    format=0xfb147d80 "arch/parisc/kernel/built-in.o(.text+0x%lx):
cannot reach %s, recompile with -ffunction-sections", ap=0xfb147d14)
    at vfprintf.c:1288
#4  0x40113064 in _bfd_default_error_handler (fmt=0x401ce5a9 "+0x%lx):
cannot reach %s, recompile with -ffunction-sections")
    at 
/var/tmp/portage/sys-devel/binutils-2.19.51.0.3/work/binutils-2.19.51.0.3/bfd/bfd.c:698
#5  0x40153db0 in final_link_relocate (input_section=0x1067b8,
contents=0x43647008 "cows can fly", rela=0x140bb8,
    value=18446744073709532028, htab=0x8eae8, sym_sec=0x1067b8,
hh=0x0, info=0x7bf78)
    at 
/var/tmp/portage/sys-devel/binutils-2.19.51.0.3/work/binutils-2.19.51.0.3/bfd/elf32-hppa.c:3574
#6  0x40155d7c in elf32_hppa_relocate_section (output_bfd=0x8c8c0,
info=0x7bf78, input_bfd=0xc4448, input_section=0x1067b8,
    contents=0x43647008 "cows can fly", relocs=0x140618,
local_syms=0x1876ea0, local_sections=0x1b2a008)
    at 
/var/tmp/portage/sys-devel/binutils-2.19.51.0.3/work/binutils-2.19.51.0.3/bfd/elf32-hppa.c:4240
#7  0x401932e4 in elf_link_input_bfd (finfo=0xfb1475ac, input_bfd=0xc4448)
    at 
/var/tmp/portage/sys-devel/binutils-2.19.51.0.3/work/binutils-2.19.51.0.3/bfd/elflink.c:9505
#8  0x401968d8 in bfd_elf_final_link (abfd=0x8c8c0, info=0x7bf78)
    at 
/var/tmp/portage/sys-devel/binutils-2.19.51.0.3/work/binutils-2.19.51.0.3/bfd/elflink.c:10635
#9  0x40152f94 in elf32_hppa_final_link (abfd=0x8c8c0, info=0x7bf78)
    at 
/var/tmp/portage/sys-devel/binutils-2.19.51.0.3/work/binutils-2.19.51.0.3/bfd/elf32-hppa.c:3241


I use the following testcase:

===============
#include <stdio.h>
#include <stdarg.h>
#include <stdint.h>

void
_bfd_error_handler (const char *fmt, ...)
{
        va_list ap;
        va_list ap2;
        const char *new_fmt;

        ap2 = ap;
        va_start(ap, fmt);
        new_fmt = fmt;

        char *bfd = va_arg(ap, char *);
        char *sec = va_arg(ap, char *);

        printf("0x%lx 0x%lx\n", (unsigned long)bfd, (unsigned long)*bfd);
        printf("0x%lx 0x%lx\n", (unsigned long)sec, (unsigned long)*sec);

        vfprintf(stderr, new_fmt, ap2);

        va_end(ap);
}

int main(void)
{
        char input_bfd = 't';
        char input_section = 'e';
        const char *string = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
        uint64_t offset = 3204;

        _bfd_error_handler("%lx(%lx+0x%lx): cannot reach %s, recompile
with -ffunction-sections\n",
                (unsigned long)&input_bfd, (unsigned
long)&input_section, offset, string);

        return 0;
}
===================

it segfaults at vfprintf()

$ ./test
0xfb2882c8 0x74
0xfb2882c9 0x65
Segmentation fault

It represents the following lines of binutils source:

bfd/elf32-hppa.c:

3570   /* Make sure we can reach the stub.  */
3571   if (max_branch_offset != 0
3572       && value + addend + max_branch_offset >= 2*max_branch_offset)
3573     {
3574       (*_bfd_error_handler)
3575         (_("%B(%A+0x%lx): cannot reach %s, recompile with
-ffunction-sections"),
3576          input_bfd,
3577          input_section,
3578          offset,
3579          hsh->bh_root.string);
3580       bfd_set_error (bfd_error_bad_value);
3581       return bfd_reloc_notsupported;
3582     }

bfd/bfd.c:

 552 void
 553 _bfd_default_error_handler (const char *fmt, ...)
 554 {
 555   va_list ap;

 698   vfprintf (stderr, new_fmt, ap);
 699   va_end (ap);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]