tests: backtrace-subr.sh (check_native_core) should check core file name.

Needed when /proc/sys/kernel/core_uses_pid is set to 0. Try to rename
the core file, and if it does still fail, skip the test.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
Fix corruption of non-C++ symbols by the demangler.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
lib: Add missing config.h #include to crc32_file.c.

Without config.h, there is no possibility of large file support.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
readelf: print_debug_macro_section clear vendor array before use.

Not setting a vendor code before use would be invalid which we tried to
catch. But to detect that we do need to initialize the vendor array to
zero first.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
backends: aarch64_check_special_symbol check shdr is not NULL before usage.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
Fix false FAILs on testsuite with ulimit -c unlimited.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
tests: run-backtrace-demangle.sh check exitcode and max number of frames.

There can be more than 3 frames, but depending on the system/installed
glibc we might not be able to unwind fully till the end.
cxxfunc -> f -> main
Expect to see the top two and a warning that there are more frames
(exit code 1)

Signed-off-by: Mark Wielaard <mjw@redhat.com>
tests: Reduce the total number of self-test files and add ET_REL files.

Some self tests would run for a really long time (especially under valgrind)
because we included all libebl backends in the list (there are 12 backends).
Now only test two explicitly. Also there were no ET_REL files in the
self test file list. So add two ET_REL files. The total number of self test
files is now 12.

run-nm-self.sh would run 4 * 3 * 3 * 22 = 792 tests (on all self test files).
Reduce the number of different files to test to 3 (one ET_EXEC, one ET_DYN
and one ET_REL file). Reducing the number of test runs to 99.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
robustify: Use gelf_fsize instead of relying on shdr->sh_entsize.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
robustify: elflint.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
robustify: readelf.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
robustify: strip.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
robustify: libelf.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
robustify: libelf gelf define INVALID_NDX macro.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
addr2line: handle_address initialize scopes to NULL.

dwarf_getscopes returns the number of scope DIEs containing a PC address.
It returns -1 for errors or 0 if no scopes match PC. If dwarf_getscopes
returned 0, then scopes will not be allocated and handle_address might free
the uninitialized scopes pointer. Make sure it always has a defined value.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
stack: Add -d, --debugname. Lookup DWARF debuginfo name for frame address.

Includes test that shows -d matches the function name that corresponds to
the actual source line we report with -s for a frame address.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
stack: Initialize -n maxframes to 256 by default.

Make -n default just 256 frames, 2048 was too big. Also Document magic
number used in frames.allocated initialization.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
stack: Add -i, --inlines. Show inlined call frames using DWARF debuginfo.

Using dwarf_getscopes_die we can get all scopes that make up the current
subprogram representing an address. Using the call_file/line/column
attributes we can also show the source locations of these "inlined" calls.
Includes a test that shows that when DWARF debuginfo is available all
inlined function call frames and their source location can be shown.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
Use -Wformat=2 by default for all files.

This just makes sure that all format strings are given as literals to
printf like functions so the compiler can see and check them. Remove
all no_Wformat, add -Wformat=2 unconditionally to AM_CFLAGS.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
backends: Update arm_reloc.def.

The elflint self test now also checks ET_REL files. Update the list of
relocation types to include all known relocations from elf.h.
R_ARM_SWI24 was obsolete and is now named R_ARM_TLS_DESC. The only other
relocation used in the dynamic linker is R_ARM_IRELATIVE.

Signed-off-by: Mark Wielaard <mjw@redhat.com>