elf-ops: bail out if we have no function symbols
commit040425f849b959ed903610cc028e0996d921f9ca
authorAlex Bennée <alex.bennee@linaro.org>
Fri, 3 Apr 2020 19:11:39 +0000 (3 20:11 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Tue, 7 Apr 2020 15:19:49 +0000 (7 16:19 +0100)
treeabcb701fda090377cdbec99860ff077e81e0596e
parent20a4f14f6e6f543100bfdd93705cbdebb549d250
elf-ops: bail out if we have no function symbols

It's perfectly possible to have no function symbols in your elf file
and if we do the undefined behaviour sanitizer rightly complains about
us passing NULL to qsort. Check nsyms before we go ahead.

While we are at it lets drop the unchecked return value and cleanup
the fail leg by use of g_autoptr.

Another fix was proposed 101 weeks ago in:
Message-Id: 20180421232120.22208-1-f4bug@amsat.org

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200403191150.863-2-alex.bennee@linaro.org>
include/hw/elf_ops.h