* src/arm/unwind_i (arm_lock, arm_local_resume): Define.
* src/ptrace/_UPT_find_proc_info.c: Handle ARM like X86 etc.
* tests/flush-cache.S (flush_cache): Add (dummy) ARM-version.
ARM does need executable stack, even on Linux...
Signed-off-by: Anderson Lizardo <anderson.lizardo@indt.org.br>
Signed-off-by: Bruna Moreira <bruna.moreira@indt.org.br>
The current pattern is too restrictive and doesn't work well on
modern glibcs.
Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
* Use explicit types for XMM registers
* Support full width (128 bits) access
Signed-off-by: Andrew Cagney <cagney@redhat.com>
Signed-off-by: Arun Sharma <aruns@google.com>
as "weak". Since the elf-support is in the library anyhow, this serves
no purpose and in fact causes problem because the weak reference alone
is not enough to pull in the ELF-code from an archive file, causing to
spurious failures of get_proc_name.
On some systems executable stacks are denied. Since libunwind and the
tests don't actually need executable stacks this patch marks all
assembly files as not needing it.
The original patch comes from frysk:
2007-04-05 Jan Kratochvil <jan.kratochvil@redhat.com>
* src/hppa/getcontext.S, src/hppa/setcontext.S, src/hppa/siglongjmp.S,
src/ia64/Ginstall_cursor.S, src/ia64/Linstall_cursor.S,
src/ia64/dyn_info_list.S, src/ia64/getcontext.S, src/ia64/longjmp.S,
src/ia64/setjmp.S, src/ia64/siglongjmp.S, src/ia64/sigsetjmp.S,
src/ppc64/longjmp.S, src/ppc64/siglongjmp.S, src/x86/longjmp.S,
src/x86/siglongjmp.S, src/x86_64/longjmp.S, src/x86_64/setcontext.S,
src/x86_64/siglongjmp.S: Stack should be non-executable, for SELinux.
I added a couple more markers for new files in current libunwind.
Before this patch you would get the following on selinux enabled
systems without allow_exec_stack: error while loading shared
libraries:
libunwind.so.7: cannot enable executable stack as shared object
requires: Permission denied
After the patch that error disappears and all test results are similar
to the results on systems without executable stack protection.
routine and add address-space argument. This is needed because on
PPC64, a the function-name symbol refers to a function descriptor
(unlike, for example, on ia64, where the @fptr() operator is needed to
refer to a function descriptor). Thus, in order to look up the name
of a function, we need to dereference the function descriptor. To
make matters more "interesting", the function descriptors are normally
resolved by the dynamic linker, so we can't get their values from the
ELF file. Instead, we have to read them from the running image, hence
the need for the address-space argument.
This is so that the source file gets distributed and _ucontext_i.h is
generated properly on the target machine.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
When libunwind is linked with a C++ program that throws exceptions,
the exception that's thrown is passed in %rax. However, libc's
setcontext clears %rax, causing problems.
This patch implements a setcontext that doesn't clobber rax.
TBD: Add dwarf CFI annotations
Signed-off-by: Arun Sharma <arun.sharma@google.com>
Yes, it casts to signed, but then converts right back to
unsigned via the return type. Fixed thus.
Signed-off-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
CFA should be incremented by 16 in the hope that the previous frame
may have valid unwind info.
Also increase the default frame pointer recognition heuristic from 4k
to 16k.
Signed-off-by: Andrey Veskov <Andrey.Veskov@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
Now that dwarf_find_save_locs() not just finds the save-locations but
also updates the cursor-state, document this fact (the function really
is misnamed now).
Be sure to clear pi->unwind_info when looking up the kernel table and
not needing the unwind-info. Otherwise, _UPT_put_unwind_info() may
erroneously call free() on the pointer, even though that space wasn't
malloc'd, leading to crashes..
(maps_next): After reading less than a full buffer of data, copy
remaining data to the top of the buffer so as to maintain the
invariant that all data between mi->buf and mi->buf_end is valid.
This avoids maps_next() parsing uninitialized data.
(get_initial_stack_pointers): Likewise.
(unw_init_local): Use new functions to make code more readable and add
Linux kernel support.
(Logical change 1.296)
Include "libunwind_i.h" instead of "internal.h" and "tdep.h".
Define rbs_cover_and_flush() only for the !UNW_REMOTE_ONLY case.
(ia64_is_big_endian): New macro.
(ia64_get_abi): Likewise.
(ia64_set_abi): Likewise.
(ia64_get_abi_marker): Likewise.
(Logical change 1.294)
Use ia64_get_abi_marker() instead of directly referencing c->last_abi_marker.
(linux_scratch_loc): When accessing an fp-reg, default to IA64_FPREG_LOC.
Handle more registers for the Linux interrupt-frame case.
(tdep_access_reg): Use ia64_get_abi() instead of c->as->abi.
Use ia64_is_big_endian() instead of c->as->big_endian.
(Logical change 1.294)
2005/05/17 14:14:23-07:00 hp.com!davidm
(linux_sigtramp): Add "prev_cfm_loc" argument. Use it to set c->ec_loc.
(linux_interrupt): Likewise.
(hpux_sigtramp): Likewise.
(update_frame_state): Copy old cfm_loc to prev_cfm_loc and pass it to
ABI-specific handlers. Initialize c->ec_loc to c->cfm_loc by default.
(Logical change 1.293)
Abstract ia64-specific code into bsp_match() routine.
Support any platform with at least 2 EH argument registers.
2004/12/06 01:33:16-08:00 mostang.com!davidm
Rename: src/longjmp.c -> src/setjmp/longjmp.c
(Logical change 1.290)
2004/11/17 02:43:39-08:00 mostang.com!davidm
(struct callback_data): New structure.
(linear_search): New function.
(callback): Convert to getting auxiliary info passed via a pointer to
a callback_data structure, rather than an unw_dyn_info_t
structure.
Keep track of the maximum load address in max_load_addr.
If an object doesn't have a binary search-table, fall back
on a linear search.
(dwarf_find_proc_info): Fill in callback-data structure before calling
dl_iterate_phdr(). Upon returning, check whether
cb_data.single_fde is set and, if so, return directly, without
searching the DWARF unwind-table.
(dwarf_search_unwind_table): Adjust for renaming of
dwarf_parse_fde() to dwarf_extract_proc_info_from_fde().
If IP doesn't fall into the IP-range of the FDE-entry found
by the search, return UNW_ENOINFO.
(Logical change 1.290)
2004/12/15 15:40:09-08:00 hp.com!davidm
Include "tdep.h" on ia64 (we need the cursor).
(bsp_match): Fix it so it compiles again.
(resume_restore_sigmask): Likewise.
2004/12/06 10:40:49-08:00 mostang.com!davidm
(Logical change 1.290)
2004/11/23 16:59:56-08:00 mostang.com!davidm
(_UPT_access_reg): If the register is out of range, set errno
to EINVAL.
When encountering an error while accessing a register,
print the corresponding error string.
(Logical change 1.290)
a signal-trampoline, assume that it's a PLT stub.
If non-DWARF stepping fails to change IP and CFA, declare
it a bad frame.
2004/11/23 16:59:56-08:00 mostang.com!davidm
(unw_step): Also print IP as part of the function-trace.
2004/11/23 16:17:37-08:00 mostang.com!davidm
(unw_step): When dwarf_step() fails on a signal-frame, fill in all
the known locations because dwarf_step() fails on older
kernels which don't export the kernel vDSO even though every-
thing else may be providing proper DWARF unwind-info.
2004/10/25 17:43:57+02:00 homeip.net!davidm
Add Debug statement for return-value.
(Logical change 1.290)
2004/11/23 12:49:54-08:00 mostang.com!davidm
(unw_step): If dwarf_step() fails on a signal-frame, fill in the
save-locations for everything that gets saved in the
sigcontext structure.
2004/10/25 17:43:57+02:00 homeip.net!davidm
Add Debug statement for return-value.
(Logical change 1.290)
(parse_cie): Adjust for moving DWARF2 extra-info from
unw_dyn_dwarf_fde_info_t to dwarf_cie_info.
Add support for `S' augmentation ("special frames").
(dwarf_extract_proc_info_from_fde): Rename frm dwarf_parse_fde().
Convert to returning data via dwarf_cie_info rather than
unw_dyn-dwarf_fde_info_t. Allow 0-length FDE since those
can be used to indicate the end of the FDE-table. Return
the end of the FDE via *ADDRP. Ignore CIEs (we may pick them
up during linear searches through the FDE-table).
Fill in the unwind-info only if really needed. When needed,
return the info via a dynamically allocated dwarf_cie_info
structure. Add support for `S' augmentation (ABI/tag pairs).
(Logical change 1.290)
unwind-info, since DWARF expects us to do so (unlikey for ia64,
where we are guaranteed that the (return) IP points to the
correct unwind-info).
2004/11/17 02:43:39-08:00 mostang.com!davidm
(run_cfi_program): Switch over to using dwarf_cie_info instead of
unw_dyn_dwarf_fde_info_t.
(fetch_proc_info): Clear c->pi before filling it in.
(put_unwind_info): If we got non-dynamic unwind-info, free it
via a call to mempool_free().
(parse_fde): Switch over to using dwarf_cie_info instead of
unw_dyn_dwarf_fde_info_t.
(apply_reg_state): Drop accessees to c->cfa_is_sp.
2004/10/25 17:38:51+02:00 homeip.net!davidm
Fix typo: DW_CFA_CFA_expression -> DW_CFA_expression.
2004/10/21 11:15:44+02:00 homeip.net!davidm
Auto merged
2004/10/21 11:15:12+02:00 homeip.net!davidm
(run_cfi_program): Add missing newline in Debug statement.
(apply_reg_state): It was wrong to do a dwarf_get() on the CFA-location
returned by eval_location_expr(). Instead, we must make sure
we're dealing with a memory-location and, if so, just extract
the memory address as the CFA.
Also, update c->cfa only _after_ the other frame-state has
been updated. This seems to be necessary for correct parsing
of the sigtramp unwind info. Not sure yet this is 100% correct,
but it gets us through Gtest-resume-sig.
2004/10/19 23:24:56-07:00 mostang.com!davidm
(run_cfi_program): Fix typos in Debug statements.
(Logical change 1.290)
2005/04/07 12:19:38-07:00 hp.com!davidm
(ia64_make_proc_info): After looking up proc-info, cache it if
caching is enabled.
2005/02/20 21:42:55-08:00 mostang.com!davidm
Adjust for NELEMS to ARRAY_SIZE renaming.
(Logical change 1.290)
2004/12/02 18:37:47-08:00 hp.com!davidm
(get_list_addr): Even the "it's missing" version of this routine
must clear *countp to avoid spurious failures.
2004/11/03 11:45:24-08:00 hp.com!davidm
Auto merged
2004/10/21 16:06:28+02:00 homeip.net!davidm
(get_list_addr): Don't fail with -UNW_ENOINFO just because something
in /proc/maps isn't mappable.
(Logical change 1.290)
2004/11/30 22:44:47-08:00 mostang.com!davidm
(my_rt_sigreturn): New function.
(x86_64_local_resume): Use my_rt_sigreturn(). The normal sigreturn()
does nothing (returns with an error).
2004/11/23 18:01:09-08:00 mostang.com!davidm
(x86_64_local_resume): Provide a minimal implementation (a la x86).
(establish_machine_state): Fix off-by-one error.
(Logical change 1.290)
local case since it's trivial to do so and saves us time if
later on we need to build a script for that procedure.
2005/02/23 14:40:44-08:00 mostang.com!davidm
Adjust for sigset_t to intrmask_t renaming.
2004/10/25 05:21:51-07:00 hp.com!davidm
(unw_search_ia64_unwind_table): Clarify comment and add a Debug() statement
for the case where we find a bad unwind-header version.
(Logical change 1.290)
(access_reg): Adjust & enable sanity-check.
(acces_fpreg): Provide minimal implementation.
2004/12/02 00:40:45-08:00 mostang.com!davidm
(uc_addr): Implement it so it starts to be useful.
(_Uhppa_uc_addr): Rename from _Ux86_uc_addr.
(get_static_proc_name): New function.
(hppa_local_addr_space_init): Rename from x86_local_addr_space_init().
Use dwarf_find_proc_info, hppa_local_resume, and
get_static_proc_name callbacks.
(Logical change 1.290)
eh_valid_mask instead. When reading and the corresponding
eh_valid_mask bit is set, read from eh_args[] instead.
2004/11/17 02:43:39-08:00 mostang.com!davidm
(tdep_access_reg): Treat UNW_X86_64_RSP exactly like UNW_X86_64_CFA.
(Logical change 1.290)
and UNW_HPPA_EH{0,1,2,3} correctly.
(tdep_access_fpreg): Implement.
2004/12/02 00:40:45-08:00 mostang.com!davidm
(tdep_access_reg): Provide a minimally working implementation.
(tdep_access_fpreg): New (unimplemented) function.
(Logical change 1.290)
(put_script_cache): Fix typo in argument name.
2005/04/07 12:19:38-07:00 hp.com!davidm
(ia64_get_cache_proc_info): Move it to near the end of the file.
(script_init): Also call ia64_fetch_proc_info() if the script was
found in the cache but it's empty (count == 0 and NULL
unwind_info pointer). Also invoke build_script() if
script has no instructions yet (count==0). Add assertion
to ensure that build_script() never returns an empty
script.
(ia64_cache_proc_info): New function to cache the proc_info only.
2005/02/23 14:40:44-08:00 mostang.com!davidm
Adjust for sigset_t to intrmask_t renaming.
2005/02/23 13:10:05-08:00 mostang.com!davidm
Adjust for "ia64_rse" to "rse" prefix change.
(Logical change 1.290)
2004/10/19 23:15:02-07:00 mostang.com!davidm
(update_frame_state): Take additional argument "prev_cfa".
When we detect a NULL-frame, debug-print the IP and the CFA
so we know where things went wrong.
(dwarf_step): Get "prev_cfa" before we call dwarf_find_save_locs(),
since update_frame_state() doesn't actually update
the CFA.
(Logical change 1.290)
(pick): Likewise.
(dwarf_eval_expr): Fix "while" conditional so we see all operators.
Fix DW_OP_litN typo: "opcode = DW_OP_lit0" to
"opcode - DW_OP_lit0".
Add lots of Debug() statements so we can see what's going
on. Debug level 15 will show just entry/return values.
Debug level 16 shows all operators.
(Logical change 1.290)
_U_dyn_info_list_addr as weak and fail if the symbol remained
undefined.
(get_static_proc_name): Likewise for _Uelf64_get_proc_name().
(Logical change 1.282)
successfully. This avoids a failure in ia64-test-setjmp which
was due to the fact that sigprocmask() caused a segfault (due to
overflowing the stack) and at that point we had a partially updated
jmp_buf.
(Logical change 1.272)
For ia64, if the longjmp is crossing a signal-frame, install
the new signal mask by updating the sc_mask member in the
oldest signal-frame.
(Logical change 1.259)
(rbs_cover_and_flush): Take additional arguments "dirty_partition",
"dirty_rnat", and "bspstore". When it is necessary to copy
backing-store words, copy them to "dirty_partition" instead of
the target rbs, which may be full already.
(Logical change 1.259)
from lib_LTLIBRARIES_cdep to here.
(libunwind_la_SOURCES_x86_64_common): Mention x86_64/ucontext_i.h so
it gets included in the tar-ball, too.
(lib_LTLIBRARIES): List $(lib_LTLIBRARIES_cdep_setjmp) after the
other libraries.
(Logical change 1.254)
printing them. Avoids compiler-warning for 64-bit targets.
(apply_reg_state): Handle the special case where the stack-pointer
plays the role of the CFA and the stack-pointer hasn't
been saved. This is based on a patch by Max Asbock.
(Logical change 1.253)
In theory, this may not be needed. In practice, I find that
Red Hat Enterprise Linux AS release 3, the _start() routine has
no unwind-info, but we need to be able to unwind into this
routine to find the end-of-frame-chain marker (RBP == 0).
(Logical change 1.253)
Drop DWARF-parsing debug prints from level 16 to 15.
(struct table_entry): Change member types from unw_word_t to int32_t. The members
need to be of a signed type and forcing them to 32 bits makes the type
work for both 32-bit and 64-bit executables (up to 4GB of text-size).
(callback): Only allow search tables which have 32-bit members.
Fix initialization of di->u.rti.table_len to express table-length as a count
of unw_word_t, as it's defined to be (we get lucky here: even with 32-bit
members, each table-entry contains two members so we're guaranteed that the
table has a size that is an integer-multiple of unw_word_t even on 64-bit
platforms).
(lookup): Change type of "rel_ip" from unw_word_t to int32_t. Simplify the
code a bit.
(remote_read): Delete.
(remote_lookup): Use dwarf_reads32() instead of remote_read() to read out table
members. Simplify code a bit.
(Logical change 1.248)