OSDN Git Service

lf2flt crashes on Linux/amd64:
authorGreg Ungerer <gerg@snapgear.com>
Wed, 1 Aug 2007 03:40:12 +0000 (03:40 +0000)
committerGreg Ungerer <gerg@snapgear.com>
Wed, 1 Aug 2007 03:40:12 +0000 (03:40 +0000)
(gdb)  run  -a -o links -p links.gdb links.gdb
Starting program: /home/stsp/dslinux/toolchain/prefix/bin/arm-linux-elf-elf2flt -a -o links -p links.gdb links.gdb

Program received signal SIGSEGV, Segmentation fault.
_bfd_elf_canonicalize_reloc (abfd=<value optimized out>, section=0x5f6900,
    relptr=0xffffffffa6360010, symbols=<value optimized out>)
    at /home/stsp/dslinux/toolchain/src/binutils-2.17/bfd/elf.c:6367
6367        *relptr++ = tblptr++;
(gdb) bt
#0  _bfd_elf_canonicalize_reloc (abfd=<value optimized out>, section=0x5f6900,
    relptr=0xffffffffa6360010, symbols=<value optimized out>)
    at /home/stsp/dslinux/toolchain/src/binutils-2.17/bfd/elf.c:6367
#1  0x00000000004006dd in output_relocs (abs_bfd=0x5f5570,
    symbols=0x2b30a5e99010, number_of_symbols=16585, n_relocs=0x7fff04c0fe58,
    text=0x2b30a6102010 "", text_len=<value optimized out>, text_vma=0,
    data=0x2b30a627b010 "", data_len=934480, data_vma=1541824,
    rel_bfd=0x5f4400)
    at /home/stsp/dslinux/toolchain/src/elf2flt-20051225/elf2flt.c:587
#2  0x0000000000401180 in main (argc=<value optimized out>,
    argv=<value optimized out>)
    at /home/stsp/dslinux/toolchain/src/elf2flt-20051225/elf2flt.c:1949

The problem seems to be that the one and only call to xmalloc()
in elf2flt.c does not return a valid pointer for some reason.

I'm wondering why xmalloc() is used exactly once in elf2flt.c.
All other heap allocations in elf2flt are done with plain malloc().

The attached patch fixes the segfault by replacing the call to xmalloc()
with a call to malloc(). It also makes elf2flt check for return
values of malloc() calls, providing the equivalent behaviour of
using xmalloc().

Patch submitted by Stefan Sperling <stsp@stsp.name>


No differences found