import-trace: fix same-address symbol import

This bugfix makes sure that from a set of symbols with the same
address, only the first one gets imported.

After an assessment whether analysis scripts can deal with multiple
symbols at the same address, an import of all symbols should be made
possible in the future.  This will also require to relax the
primary-key constraint of the `symbols' table.

Change-Id: I61c4ddb1af1556d44eab54e53eaa3d0fc20de7c1
This commit is contained in:
Horst Schirmeier
2018-07-30 16:00:48 +02:00
parent 2c7640fe90
commit 68229afa84

View File

@ -49,6 +49,8 @@ EOT
LAST_ADDR=
LAST_SYMBOL=
LAST_INSERTED_ADDR=
# The "dummy" entry at the end makes sure the last real symbol from the
# nm output makes it into the database.
(nm -n -S -C $ELF; echo ffffffff a dummy) \
@ -65,17 +67,21 @@ EOT
if [ $LAST_ADDR ]; then
# only create INSERT-line, if $ADDR is new to us
if [ ! $ADDR = $LAST_ADDR ]; then
if [ $LAST_ADDR != "$LAST_INSERTED_ADDR" ]; then
echo "INSERT INTO $TABLE (variant_id, address, size, name) VALUES "
echo "($ID, cast(0x$LAST_ADDR AS UNSIGNED), CAST(0x$ADDR AS UNSIGNED)-CAST(0x$LAST_ADDR AS UNSIGNED), '$LAST_SYMBOL');"
LAST_INSERTED_ADDR=$LAST_ADDR
fi
fi
if [ $SIZE != unknown ]; then
echo "INSERT INTO $TABLE (variant_id, address, size, name) VALUES "
echo "($ID, cast(0x$ADDR AS UNSIGNED), CAST(0x$SIZE AS UNSIGNED), '$SYMBOL');"
LAST_ADDR=
LAST_SYMBOL=
if [ $ADDR != "$LAST_INSERTED_ADDR" ]; then
echo "INSERT INTO $TABLE (variant_id, address, size, name) VALUES "
echo "($ID, cast(0x$ADDR AS UNSIGNED), CAST(0x$SIZE AS UNSIGNED), '$SYMBOL');"
LAST_ADDR=
LAST_SYMBOL=
LAST_INSERTED_ADDR=$ADDR
fi
else
LAST_ADDR=$ADDR
LAST_SYMBOL=$SYMBOL