1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-11-06 01:34:29 +01:00
Commit graph

1448 commits

Author SHA1 Message Date
Arun Sharma
649f1fb344 [X86-64] For local unwinding, we have a defence mechanism against
bad/missing unwind information, which could result in libunwind
dereferencing bad pointers. This mechanism is based on msync(2) system
call and significantly reduces the chances of a bad pointer
dereference in libunwind.

The original idea was to turn this mechanism on only when necessary
i.e. libunwind didn't find proper unwind information for a IP.

There are a couple of problems in the current implementation.

* The flag is global and is modified without locking
* The flag isn't reset when starting a new unwind

The attached patch makes ->validate a per-thread setting by moving it
into struct cursor from unw_local_addr_space and resets it to false
when starting a new unwind. As a result, cursor->as_arg points to the
cursor itself instead of the ucontext (for the local case).

This was found to reduce the number of msync() system calls from an
application using libunwind significantly.

Signed-off-by: Paul Pluzhnikov <ppluzhnikov@google.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2008-06-16 14:35:53 -06:00
David Mosberger-Tang
183d28a066 Rebuild autoconf files with autoreconf. 2008-06-16 14:30:38 -06:00
Arun Sharma
8081e82ba1 Make the linking of C++ ABI related code for exceptions optional.
The default is to have it enabled.

Signed-off-by: Arun Sharma <arun.sharma@google.com>
2008-06-16 14:28:36 -06:00
Bruna Moreira
1eddefc371 [ARM] This patch add some missing bits on ARM platform.
* 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>
2008-04-21 13:43:18 -06:00
Paul Pluzhnikov
bb9d3dc689 [X86-64] Fix the pattern used to match signal frames.
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>
2008-04-16 08:05:49 -06:00
Daniel Jacobowitz
3842dac733 Add initial ARM and MIPS support. To support this, also enable the
reading of .debug_frame sections (used in lieu of .eh_frame sections
when they're not available).
2008-02-04 17:16:37 -07:00
Mark Wielaard
5ed2da2a40 [DWARF] Fix error return.
* src/dwarf/Gfde.c (dwarf_extract_proc_info_from_fde):
	  Return -UNW_ENOMEM.
2008-02-04 16:31:34 -07:00
David Mosberger-Tang
f5cb2c52dc 2007-12-14 Mark Wielaard <mwielaard@redhat.com>
* src/mi/Gget_reg.c (unw_get_reg): Use tdep_get_ip() when
   looking for UNW_REG_IP.
2008-01-07 15:43:42 -07:00
David Mosberger-Tang
a8be10e251 [X86] Cleanup XMM handling for x86
* 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>
2008-01-07 15:41:20 -07:00
David Mosberger-Tang
826374cee5 Merge ../libunwind-v0.98
Conflicts:

	configure
	configure.in
	src/ia64/Ginit.c
2007-11-14 16:51:14 -07:00
David Mosberger-Tang
3899ab7039 Update NEWS file and rerun "autoreconf". 2007-11-14 13:04:15 -07:00
Curt Wohlgemuth
7fda769769 ia64 [src/ia64/Ginit.c]: Don't mark the reference to _Uelf64_get_proc_name
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.
2007-11-14 12:59:10 -07:00
Curt Wohlgemuth
253f3e5738 [Linux] Fix potentially overlapping memory-copy to use memmove() instead
of memcpy().
2007-10-18 10:45:55 -06:00
Andrew Cagney
05c8284b43 [X86] 2007-10-10 Andrew Cagney <cagney@redhat.com>
* src/x86/init.h (common_init): Fix typo: use UNW_X86_ESI for
     dwarf.loc[ESI].

Acked-by: Arun Sharma <aruns@google.com>
2007-10-15 10:32:07 -06:00
Jose Flavio Aguilar Paulino
9ea6af8ed5 [PPC32] Make PPC32 unwinding work for real. 2007-10-08 12:33:18 -06:00
Jan Kratochvil
57e5696463 Mark Wielaard <mwielaard@redhat.com> writes:
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.
2007-10-01 08:35:01 -06:00
Jose Flavio Aguilar Paulino
c340d04279 [PPC32] Make get_func_addr() a no-op function.
[PPC64] Add .../lib64 library directory when targeting ppc64.
2007-09-20 11:11:37 -06:00
Jose Flavio Aguilar Paulino
4499bb29a6 [PPC32] First check-in to add preliminary support for Linux/PPC32. 2007-09-12 21:52:25 -06:00
David Mosberger-Tang
6d75df39b5 Regenerate Makefile.in. 2007-08-27 15:31:10 -06:00
Jose Flavio Aguilar Paulino
32e2187fab [PPC64] Get "make check" to work on PPC64 Linux. Add a README entry
describing the expected results.
2007-08-27 09:11:37 -06:00
Jose Flavio Aguilar Paulino
3e24581adc [PPC64] Add PPC64 entry to README and fix David's typo in ppc64/get_func_addr.c 2007-08-24 10:54:00 -06:00
David Mosberger-Tang
e6b9f350f7 Introduce a tdep_get_func_addr_hook() in the ELF lookup_symbol()
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.
2007-08-22 13:02:09 -06:00
David Mosberger-Tang
03e05b4138 Fix two minor compiler-warnings. 2007-08-22 12:57:49 -06:00
David Mosberger-Tang
7fdd022ccf Update autoconf files. 2007-08-09 21:18:15 -06:00
Arun Sharma
bcca3ddcc0 [x86-64] Fix cross-compilation. setcontext.S can only be built natively. 2007-08-07 21:09:12 -06:00
David Mosberger-Tang
297315675e Recreate autoconf files. 2007-08-06 20:27:29 -06:00
David Mosberger-Tang
5c95d139df Cleanup some files from previous patch and rerurn autoconf tools. 2007-08-06 19:59:28 -06:00
Arun Sharma
3afd613545 [X86-64]: Instead of auto-generating _u_context_i.h, hardcode the
necessary offsets in offsets.h as is done for other
	  platforms.  This fixes cross-builds.
2007-08-06 19:58:12 -06:00
David Mosberger-Tang
fad8b04c9f Rebuilt configure and Makefile.in files. 2007-08-06 19:56:28 -06:00
Jose Flavio Aguilar Paulino
b33021e4b2 Add PPC64 support. 2007-08-02 09:59:43 -06:00
David Mosberger-Tang
a6393c0be1 Merge ../libunwind-v0.98 2007-06-06 20:58:56 -06:00
Andreas Schwab
09c8c7d0f3 (unw_create_addr_space): Fix address-leak that triggered when function
was called with an unsupported "byte_order".

Signed-off-by: David Mosberger-Tang <dmosberger@gmail.com>
2007-06-06 20:55:36 -06:00
David Mosberger-Tang
7923ae31a0 Re-run aclocal and automake to update Makefiles so new files (e.g.,
x86_64/gen_offsets.c) get distributed.
2007-04-10 20:35:15 -06:00
Arun Sharma
497b987043 Add gen-offsets to the Makefile
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>
2007-04-10 20:18:56 -06:00
Arun Sharma
31440e9796 Make libunwind pass C++ exceptions correctly
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>
2007-04-05 20:40:41 -06:00
Arun Sharma
55fe524775 Cleanup the hash() function copied from ia64
Fixes the compiler warning on x86-32.

Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-08-16 15:43:49 -06:00
Arun Sharma
a5d0c1f8b7 Remove HAVE___THREAD. This was never tested.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-08-16 15:41:32 -06:00
David Mosberger-Tang
62bacfcf1f [x86-64] Minor reformatting for GNU-style and use memset() in lieu of bzero(). 2006-08-10 21:34:31 -06:00
Arun Sharma (अरुण)
795529eee3 [x86-64] Add a known good address cache.
This improves the performance of Lperf-simple from 500ns to 195ns
on the avg.

Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-08-10 21:30:01 -06:00
David Mosberger-Tang
bde67706ed Delete some backup files that accidentally made it into git. 2006-07-27 21:30:19 -06:00
Arun Sharma
11ea1275bd [dwarf] The sword() function in Gexpr.c doesn't do what's intended.
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>
2006-07-26 22:12:10 -06:00
Arun Sharma
cdb96f333c [x86] (common_init): Fix spurious errors caused by uninitialized members.
Signed-off-by: Richard Henderson <rth@redhat.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 22:09:10 -06:00
Arun Sharma
8297866bd4 [x86-64] (unw_step): Further refine handling of functions without unwind-info.
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>
2006-07-26 22:06:48 -06:00
Arun Sharma
06d2ffa41a [x86-64] (unw_step): Improve handling of functions which lack unwind info.
If following the frame-chain leads to a frame >= 4KB away, we conclude that
the frame-pointer isn't really valid.
2006-07-26 22:04:40 -06:00
Arun Sharma
7c0907634d [x86-64] (unw_is_signal_frame): If access mem fails, it's not a signal frame. 2006-07-26 21:58:27 -06:00
Arun Sharma
58888a5060 (dwarf_find_save_locs): Also apply register-state after parsing the FDE 2006-07-26 21:55:09 -06:00
Arun Sharma
527225e492 [x86-64] Make a best effort at validating pointers before dereferencing them.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 21:46:39 -06:00
Arun Sharma
4312719cbc [dwarf] Need to guard against multiple threads accessing the rs cache.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 21:44:38 -06:00
Arun Sharma
c5dc3c150a [dwarf] Allow return address column to differ from function to function.
Signed-off-by: Andrey Veskov <Andrey.Veskov@intel.com>
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 21:29:50 -06:00
Arun Sharma
60b7af702a (dwarf_find_save_locs): Add a comment.
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).
2006-07-26 21:25:37 -06:00
Arun Sharma
3dfde7a3f0 (dwarf_find_save_locs): put_unwind_info() is not needed in the cached case. 2006-07-26 21:23:30 -06:00
Arun Sharma
00db7f752a Implement a ip -> dwarf_reg_state cache.
Signed-off-by: Arun Sharma <arun.sharma@google.com>
2006-07-26 21:18:49 -06:00
David Mosberger-Tang
1a0af36731 Fix forgotten copyright year update. 2006-07-26 15:48:48 -06:00
David Mosberger-Tang
6a89d40236 Fix missed "tdep.h" -> "libunwind_i.h" conversions. 2006-07-26 15:44:23 -06:00
David Mosberger-Tang
8c94e12429 (_UPT_find_proc_info): Fix potential crash due to uninitialized pointer.
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..
2006-07-26 15:43:23 -06:00
David Mosberger-Tang
fd2fa63a6c Fix missed merge on setjmp_i.h and siglongjmp.c. 2006-07-26 15:21:52 -06:00
David Mosberger-Tang
69d85f7c14 Restore mi/Ldyn-remote.c. 2006-07-26 15:10:48 -06:00
David Mosberger-Tang
236e370dc5 Remove three Emacs backup-files which accidentially got checked into git. 2006-07-26 14:54:50 -06:00
David Mosberger-Tang
6daeeac60a Revert "Initial revision"
This reverts e6446885f4 commit.
2006-07-26 14:53:49 -06:00
David Mosberger-Tang
a369768c27 Revert "Initial revision"
This reverts 06d223e924 commit.
2006-07-26 14:47:44 -06:00
David Mosberger-Tang
ca69fee8bb Merge ../libunwind-v0.98
Conflicts:

	include/dwarf_i.h
	include/x86/jmpbuf.h
	include/x86_64/jmpbuf.h
	src/hppa/init.h
	src/mi/Gget_fpreg.c
	src/mi/Gset_fpreg.c
	src/mi/strerror.c
2006-07-25 21:41:43 -06:00
David Mosberger-Tang
af2503e223 Fix bug in libunwind-ptrace which can cause reading of random data.
(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.
2006-07-25 21:35:30 -06:00
David Mosberger-Tang
f176ad6fc6 Bring git v0.98.5 tree in sync with released v0.98.5.
Sadly, the conversion from Bitkeeper -> CVS -> git wasn't perfect.  Or
so it seems.
2006-07-25 21:32:28 -06:00
hp.com!davidm
36a0275014 Allow write-access to UNW_IA64_BSP and UNW_REG_SP.
(Logical change 1.303)
2005-05-20 15:32:18 +00:00
hp.com!davidm
cf2a44ca49 Use update_nat() instead of equivalent open code.
(Logical change 1.301)
2005-05-20 14:58:46 +00:00
hp.com!davidm
f5de64f9f7 If r1 has been saved in an ABI-specific frame
(such as an interrupt frame), access the saved
value.  Otherwise, pick it up from the unwind-info
for the matching IP.

(Logical change 1.300)
2005-05-20 14:50:54 +00:00
hp.com!davidm
399f120c96 Drop unused readonly variable.
(Logical change 1.299)
2005-05-20 14:13:01 +00:00
hp.com!davidm
3fa950e818 Remove early-out test when IP is zero.
(Logical change 1.298)
2005-05-20 13:35:32 +00:00
hp.com!davidm
19e3bf3ea6 (rbs_switch): Use rbs_get_base() to determine the size of the register
backing store.

(Logical change 1.297)
2005-05-20 13:13:07 +00:00
hp.com!davidm
9724ac492c (common_init): Use rbs_get_base() to determine size of register-backing store.
(Logical change 1.297)
2005-05-20 13:13:07 +00:00
hp.com!davidm
080f8423d9 Read sp and bsp via ia64_get() and then pass them to common_init().
(Logical change 1.296)
2005-05-20 12:47:59 +00:00
hp.com!davidm
50bbc1fe3d (set_as_arg): New function.
(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)
2005-05-20 12:47:59 +00:00
hp.com!davidm
84bd124a24 (inlined_uc_addr): Remove UNW_IA64_AR_BSP. We no longer need this ugly hack
since the initial BSP is now passed directly into common_init().

(Logical change 1.296)
2005-05-20 12:47:59 +00:00
hp.com!davidm
4992f1c936 (common_init): Take initial sp and bsp values as arguments instead of
reading them via ia64_get().

(Logical change 1.296)
2005-05-20 12:47:59 +00:00
hp.com!davidm
97b483dcaa Drop include of "mempool.h", which causes problems in the kernel, due to
a conflicting <linux/mempool.h>.
(SOS_MEMORY_SIZE): Move to libunwind_i.h.

(Logical change 1.295)
2005-05-20 11:28:16 +00:00
hp.com!davidm
1b63be3f89 (parse_dynamic): Make it a dummy-function of _U_dyn_op isn't defined, i.e.,
if libunwind-dynamic.h isn't in use (as is the case for the kernel at
	the moment).

(Logical change 1.295)
2005-05-20 11:28:16 +00:00
hp.com!davidm
7894f0edc0 (ia64_strloc): Move to Grbs.c.
(Logical change 1.295)
2005-05-20 11:28:16 +00:00
hp.com!davidm
96407911ee (ia64_strloc): Move here from Ginit.c so it can be shared with the kernel.
(Logical change 1.295)
2005-05-20 11:28:16 +00:00
hp.com!davidm
2e35dd035c Regenerate.
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
3e8a50255c Include from tdep-$(arch) directory after the normal incliude directory.
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
32385d36fd Include "tdep-ia64/rse.h" instead of "ia64/rse.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
1228462adc Include "rse.h" instead of "ia64/rse.h".
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)
2005-05-20 09:48:08 +00:00
hp.com!davidm
8e6f3c8485 Include "rse.h" instead of "ia64/rse.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
83820a78d1 Include "libunwind_i.h" instead of "tdep.h".
Include "tdep-ia64/rse.h" instead of "ia64/rse.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
67f90c24be Include "libunwind_i.h" instead of "tdep.h".
Include "elfxx.c" instead of "elf64.c".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
d9e100753f Include "libunwind_i.h" instead of "tdep.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
07b01ad205 Include "libunwind_i.h" instead of "tdep.h" and "internal.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
670dd57e82 Include "libunwind_i.h" instead of "libunwind.h" and a whole bunch of standard
header files.
Use lock_release instead of mutex_unlock/sigprocmask calls.

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
5724bee8c2 Include "libunwind_i.h" instead of "internal.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
19df6612fa Include "libunwind_i.h" instead of "internal.h" and "tdep.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
b7adf160ee Include "dwarf_i.h" instead of "dwarf.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
c027d98386 Don't include headers already included via unwind_i.h.
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
df3d6af467 Don't include <string.h>.
Include "libunwind_i.h" instead of "tdep.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
dda1a6d625 Don't include <string.h>.
Include "libunwind_i.h" instead of "internal.h" and "tdep.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
379fb069d2 Don't include <string.h>, <unistd.h>, <sys/types.h>.
Include "libunwind_i.h" instead of "tdep.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
9e8ba174e6 Don't include <string.h> and <stdlib.h>.
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
9fac7579ee Don't include <string.h> and "tdep.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
71acf1d00e Don't include <stdlib.h>.
Include "libunwind_i.h" instead of "tdep.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
03ba50ccaa Don't include <stdlib.h> and <string.h>.
Include "libunwind_i.h" instead of "tdep.h".

(Logical change 1.294)
2005-05-20 09:48:08 +00:00
hp.com!davidm
fa2871946a Don't include <assert.h> and <stddef.h>.
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-20 09:48:08 +00:00