Frame pointer (FP) cannot always be relied upon if DWARF unwinding
fails. Depending on position in the function prologue/epilogue, the
frame record may be pointed to by the FP, SP, or at an offset to SP.
Detect which case it is by inspecting the function disassembly and
matching to known frame record store/load instructions.
Unittest added to verify different frame record store/load methods are
detected when given real function examples from a python2.7 binary.
This issue was found by static analysis. It makes comprehending what the
tests do a little more difficult. There is no functional change.
Verified on Ubuntu 20.04 x86_64.
This was dertected by static analysis. The function scan_hex() had a
logic error. It was unlikely to be encountered in real life but fixing
it guarantees it won;t have any effect.
Built and tested Ubunbtu 20.04 x86_64. No regressions.
The error message is as follows:
```
--- x86/Gos-freebsd.lo ---
x86/Gos-freebsd.c:127:10: error: use of undeclared identifier 'i'
for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i)
^
x86/Gos-freebsd.c:127:17: error: use of undeclared identifier 'i'
for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i)
^
x86/Gos-freebsd.c:127:49: error: use of undeclared identifier 'i'
for (i = 0; i < DWARF_NUM_PRESERVED_REGS; ++i)
^
x86/Gos-freebsd.c:128:20: error: use of undeclared identifier 'i'
c->dwarf.loc[i] = DWARF_NULL_LOC;
^
4 errors generated.
*** [x86/Gos-freebsd.lo] Error code 1
```
Various backtraces were failing on QNX x86_64 (including the
x64-unwind-badjmp-signal-frame unit test) with a segfault. Turns out
checking the 'validate memory' flag was not being done when checking for
a signal trampoline in the OS-specific code.
If ip is invalid, _get_remote_elf_image should return negative value,
otherwise elf_w(get_proc_name) will think elf image is loaded, then
crash in elf_w(valid_object) when want to access elf image buffer.
In ELF lookup_symbol_from_dynamic() the DYNAMIC segment was using the raw
virtual address of various sections rather than the offset within the mapped
file. They needed to be adjusted by the virtual address offset withing the ELF
file itself.
Fixes some CI FAILS on x86_64.
It's a convention that unadorned section 3 man pages are libc functions
and other libraries adorn the section name.
Also added example code to the ptrace and nto remotes and fixed some
unusual Engish-language constructs.
Regenerated all man pages from their LaTEX sources.
QNX aarch64 kernel call without frame pointer and cfi directives,
this will fallback to use frame pointer unwinder, but the frame pointer
is caller's frame pointer, causing caller frame be skipped.
Try to sniff kernel call pattern, get procedure's ip range by symtab
and do the matchup from the beginning of procedure. If matched, then
fallback to use link register unwinder.
src/coredump/_UCD_get_proc_name.c:
src/elfxx.c:
src/elfxx.h:
Rename load_debuglib to the more generic/agnostic load_debuginfo.
Fix minor pointer infelicity.
ELF_NOTE_GNU and NT_GNU_BUILD_ID will not be defined for non-gnu platforms resulting in compilation failure. Via conditional compilation ensure that find_build_id_path simply returns fail for such platforms - the code will then fall through to the next option. Note that NT_GNU_BUILD_ID doesn't appear in glibc header files until version 2.7 (2007 vintage).
Section headers might be stripped so switch to look for the notes in the PT_NOTE segment in the program headers.
In some namespace setups the binary might not even be present in the mnt_ns.
This is the case if it's launched from an fd in a specially prepared empty mnt_ns via a execveat (sandboxing usecase).
Therefore it makes sense to fallback to the original path.
Coredump remote use ucd_file to get proc name directly, the backing elf image
file maybe stripped and without symtab, try to get proc name use debug file referred
by debuglink if it can, and elfxx always use debuglink to get proc name.
Signed-off-by: Xiang.Lin <myd.xia@gmail.com>
Previous implementation could only handle cases where IP was at the
first instruction in the PLT. This change implements detecting PLT
entries regardless of where the current IP is within the entry.
Added AArch64-only unittest for is_plt_entry. Mock instructions are set
up for testing, using different offsets and non-PLT replacements.
The order in which the libraries are installed is significant so that
dependendies can be properly linked in. Made that depepdency order manifest in
src/Makefile.am.
Took the opportunity to modify the style of src/Makefile.am for consistency,
inclusing alphabetizing all source file lists.
The ptrace and coredump remote libraries were underlinked -- they did
not have DT_NEEDED entries for their direct depdendencies. This is bad
practice and is only alleviated by developers guessing what needs to be
linked where and when when using these libraries.
This change adds those dependencies.
glibc printf() needs using atomic instruction to acquire the stdout lock.
Under ARMv8.0 ISA, atomic instruction is realized using LL-SC routine, which
will keep retrying if other cpu accesses the target memory during the atomic
instruction.
In mapper testcase, parent process uses ptrace to single step mapper program,
thus if calling printf between SIGUSR1 and SIGUSR2, printf will be single-
step executed, and the atomic instruction will be stuck in deadloop.
Added function to detect when specified IP is within a PLT entry. This
is determined by reading surrounding instructions and matching them to
known PPC64 PLT procedure instructions.
Added PPC64-only unittest for is_plt_entry. Mock instructions are set up
for testing, using different offsets and non-PLT replacements.
This target is no longer supported by common toolchains or operating
systems. If support is required, it can still be found in libunwind
version 1.7 and earlier.