1
0
Fork 0
mirror of https://github.com/tobast/libunwind-eh_elf.git synced 2024-09-29 18:09:29 +02:00
Commit graph

75 commits

Author SHA1 Message Date
Lassi Tuura
a9dce3c06e During the stack unwinding process, the return address points to
the instruction after the call for a normal frame. libunwind uses
IP-1 to lookup unwind information. However, this is not necessary for
interrupted frames such as signal frames (or interrupt frames) in
the kernel context.

This patch handles both cases correctly.

Based on work by Mark Wielaard <mwielaard@redhat.com>
2010-04-24 19:16:09 -07:00
Paul Pluzhnikov
84d4150668 Allow caller to block signals.
Greetings,

We use libunwind just for stack traces (I suspect many others do as well).

The use pattern is:

GetStackTrace(void** result, int max_depth)
{
...
  unw_getcontext(&uc);
  unw_init_local(&cursor, &uc);

  while (n < max_depth) {
    if (unw_get_reg(&cursor, UNW_REG_IP, (unw_word_t *) &ip) < 0) {
      break;
    }
    result[n++] = ip;
    if (unw_step(&cursor) <= 0) {
      break;
    }
  }

Given this usage, it is quite convenient for us to block signals (or
prevent signal handlers from re-entering libunwind by other means) at the
"top level", which makes most of the sigprocmask calls performed by
libunwind itself unneccessary.

The second patch in this series adds a configure option which removes most
of the sigprocmask calls.

Attached patch is a preliminary for it -- consolidating all of the
"sigprocmask; mutex_lock;" sequences into lock_acquire and "mutex_unlock;
sigprocmask;" sequences into lock_release.

Thanks,
--
Paul Pluzhnikov

commit 402d15b123d54a7669db7cf17a76dd315094e472
Author: Paul Pluzhnikov <ppluzhnikov@google.com>
Date:   Mon Sep 21 10:18:28 2009 -0700

    Replace "sigprocmask + mutext_lock" with a single lock_acquire.
    Likewise, replace "mutext_unlock + sigprocmask" with lock_release.
2009-09-25 09:35:31 -07: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
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
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
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
19df6612fa Include "libunwind_i.h" instead of "internal.h" and "tdep.h".
(Logical change 1.294)
2005-05-20 09:48:08 +00:00
mostang.com!davidm
06d223e924 Initial revision 2005-05-03 09:13:17 +00:00
mostang.com!davidm
411331eecb Delete: src/hppa/Lget_reg.c
}(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
ca02ad1708 Delete: src/hppa/Lget_proc_name.c
}(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
181bddfba0 Delete: src/hppa/Gget_reg.c
}(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
f45210852c Delete: src/hppa/Gget_proc_name.c
}(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
b267dfc8c9 Adjust for sigset_t to intrmask_t renaming.
}(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
dc89a17613 Adjust for sigset_t to intrmask_t renaming.
2004/12/02 00:40:45-08:00 mostang.com!davidm
Add copyright notice.
Provide canonical DWARF-based implementation.

2004/11/30 23:38:42-08:00 mostang.com!davidm
Rename: src/hppa/global.c -> src/hppa/Gglobal.c

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
93599dc278 (unw_init_local): Implement it based on the DWARF unwinder.
(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
0f27732d35 (unw_get_proc_info): Implement it based on dwarf_make_proc_info().
(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
9c025efac2 (_UI_siglongjmp_cont): Provide dummy implementation.
(_UI_longjmp_cont): Likewise.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
mostang.com!davidm
04fde4a63b (Logical change 1.290) 2005-05-03 09:13:17 +00:00
hp.com!davidm
e6446885f4 Initial revision 2005-05-03 09:13:17 +00:00
hp.com!davidm
0dec41725c Fix missing NELEMS -> ARRAY_SIZE adjustment.
2004/12/02 00:40:45-08:00 mostang.com!davidm

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
7b17187a39 Define ucontext_t, sigcontext_t, and strct rt_sigframe offsets and
pray they never change.

2004/12/02 00:40:45-08:00 mostang.com!davidm

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
a04f52279d Add include of "offsets.h".
(unw_step): Improve debug output.  Implement signal-frame fall-back
	code.

2004/12/02 00:40:45-08:00 mostang.com!davidm
(update_frame_state): Remove.
(unw_step): Implement it based on DWARF unwinder.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
f9b8ba0d47 (unw_resume): Reject attempts to resume execution at IP 0.
2004/12/02 18:37:47-08:00 hp.com!davidm
(my_rt_sigreturn): New function.

2004/12/02 00:40:45-08:00 mostang.com!davidm

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
39ec1bd6dc (unw_is_signal_frame): Always return 0 for NULL IP.
2004/12/02 18:37:47-08:00 hp.com!davidm
(unw_is_signal_frame): Implement it.

2004/12/02 00:40:45-08:00 mostang.com!davidm

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
68edb681d8 (uc_addr): Adjust for Debian/sarge header-file changes.
(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)
2005-05-03 09:13:17 +00:00
hp.com!davidm
5b0507c432 (tdep_access_reg): Handle UNW_HPPA_IP, UNW_HPPA_CFA, UNW_HPPA_SP,
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)
2005-05-03 09:13:17 +00:00
hp.com!davidm
7e0192f53a (setcontext): Declare.
2004/12/02 00:40:45-08:00 mostang.com!davidm
Delete accessor macros which have been replaced by their DWARF
equivalent.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
e8b25005e7 (common_init): Initialize UNW_HPPA_IP based on save-location for
UNW_HPPA_RP.

2004/12/02 00:40:45-08:00 mostang.com!davidm
(common_init): Provide a minimally working implementation.

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
75fb20d67d (SPILL): Adjust for Debian/sarge changes in the ucontext_t structure.
2004/12/02 00:40:45-08:00 mostang.com!davidm

(Logical change 1.290)
2005-05-03 09:13:17 +00:00
hp.com!davidm
5b20c6e082 (Logical change 1.290) 2005-05-03 09:13:17 +00:00
homeip.net!davidm
c8b59eefb1 Rename: src/hppa/tables-hppa.c -> src/hppa/tables.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
39803ee0b7 Rename: src/hppa/tables-hppa.c -> src/hppa/tables.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
3c9026e270 Rename: src/hppa/siglongjmp-hppa.S -> src/hppa/siglongjmp.S
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
b2d7a09be2 Rename: src/hppa/siglongjmp-hppa.S -> src/hppa/siglongjmp.S
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
33e369b82f Rename: src/hppa/global-hppa.c -> src/hppa/global.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
4b6be8edd7 Rename: src/hppa/global-hppa.c -> src/hppa/global.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
08743d8661 Rename: src/hppa/get_accessors-hppa.c -> src/hppa/get_accessors.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
b249ecb413 Rename: src/hppa/get_accessors-hppa.c -> src/hppa/get_accessors.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
13ded384e2 Rename: src/hppa/Gstep-hppa.c -> src/hppa/Gstep.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
a2deab56db Rename: src/hppa/Gstep-hppa.c -> src/hppa/Gstep.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
7c14420d32 Rename: src/hppa/Gregs-hppa.c -> src/hppa/Gregs.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
fd40db490a Rename: src/hppa/Gregs-hppa.c -> src/hppa/Gregs.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
c5f84f785a Rename: src/hppa/Ginit_local-hppa.c -> src/hppa/Ginit_local.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
e15e32e468 Rename: src/hppa/Ginit_local-hppa.c -> src/hppa/Ginit_local.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
d0a684cb2f Rename: src/hppa/Ginit-hppa.c -> src/hppa/Ginit.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
3eb5704c20 Rename: src/hppa/Ginit-hppa.c -> src/hppa/Ginit.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
99e437825c Rename: src/hppa/Gget_reg-hppa.c -> src/hppa/Gget_reg.c
}(Logical change 1.241)
2004-08-17 15:34:28 +00:00
homeip.net!davidm
88c8ac795c Rename: src/hppa/Gget_reg-hppa.c -> src/hppa/Gget_reg.c
(Logical change 1.241)
2004-08-17 15:34:28 +00:00