linux-user: Fix the load of ELF files that have no "useful" symbol
commitb947527941b17c8f4a31f95dfa114e467ba1325d
authorCédric VINCENT <cedric.vincent@st.com>
Wed, 1 Jun 2011 12:36:38 +0000 (1 14:36 +0200)
committerRiku Voipio <riku.voipio@iki.fi>
Tue, 21 Jun 2011 17:28:38 +0000 (21 20:28 +0300)
treeabce75256b9aef83035effb1a0bec2708f5582f5
parent9a826d7854baf6b90de46fea785d1bfc5d2c22a7
linux-user: Fix the load of ELF files that have no "useful" symbol

This patch fixes a "double free()" due to "realloc(syms, 0)" in the
loader when the ELF file has no "useful" symbol, as with the following
example (compiled with "sh4-linux-gcc -nostdlib"):

    .text
    .align 1
    .global _start
    _start:
        mov     #1, r3
        trapa   #40     // syscall(__NR_exit)
        nop

The bug appears when the log (option "-d") is enabled.

Signed-off-by: Cédric VINCENT <cedric.vincent@st.com>
Signed-off-by: Yves JANIN <yves.janin@st.com>
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
Reviewed-by: Richard Henderson <rth@twiddle.net>
linux-user/elfload.c