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

33 commits

Author SHA1 Message Date
Keno Fischer 8afc33ce9f Add an option to have start_ip_offset be relative to start_ip
By default, the start_ip_offset in libunwind's table_entry struct is
relative to the unw_dyn_info_t's segbase. This presents a problem
for us in conjunction with using LLVM's MCJIT because it likes to
spread text sections and the corresponding eh_frame sections quite
far apart. This represents my attempt to support this use case in the
simplest manner that is backwards compatible, by adding a new format
kind (UNW_INFO_FORMAT_REMOTE_TABLE2) that indicates that the
`start_ip_offset` should be interpreted as relative to `start_ip`
rather than segbase.
2015-09-15 12:18:30 -07:00
Peter Wu 68a2910bae Check that the CIE is within the segment
Due to a bug in the gold linker[1], the .eh_frame and .eh_frame_hdr
sections contains garbage. When dwarf_extract_proc_info_from_fde tried
to look up the begin of the CIE subsection, it would underflow the
.eh_frame segment, resulting in a crash[2].

This patch avoids that crash by checking whether the CIE pointer is
located after the begin of the .eh_frame section. The variable "base"
was misused in various places as a boolean (decode as .debug_frame or
decode as .eh_frame). These instances have been renamed to
is_debug_frame where applicable.

Tested on Linux x86_64.

 [1]: https://sourceware.org/bugzilla/show_bug.cgi?id=17639
 [2]: http://lists.nongnu.org/archive/html/libunwind-devel/2014-11/msg00009.html

Signed-off-by: Peter Wu <peter@lekensteyn.nl>
2014-12-05 23:39:48 -08:00
Arun Sharma 781d5d5263 One time whitespace fixup.
for f in $(find src include -name '*.[ch]'); do
  expand -t 8 $f > $tmp; mv $tmp $f;
done
2014-09-27 09:47:23 -07:00
Matt Fischer eac65dc9b8 Add basic support for the QNX operating system
This change adds some special cases to allow libunwind to compile
for QNX.

* QNX's copy of <elf.h> and <link.h> reside in sys/ instead.  To deal
  with this, an AC_CHECK_HEADERS() was added to check for the files
  in both locations.
* Similarly, QNX does not have <endian.h>.  In cases where the file is
  not found, logic was added to refer to QNX-specific macros to determine
  endianness.
* The QCC compiler, which is a wrapper around GCC, cannot handle some
  standard GCC options.  Therefore, logic was added to check for QCC,
  and when it is found, to suppress the use of -lgcc, and to express the
  option -nostartfiles as -Wc,-nostartfiles instead, which is correctly
  passed on to the underlying GCC.
* Finally, the support file os-qnx.c was added, patterned after the existing
  os-*.c files.  Only local image lookup is currently supported (see the
  comments for more information), but this is sufficient for QNX, since
  ptrace is not supported there anyway, and that is the only case where the
  function is required to do remote image lookup.

Change-Id: Ie7934f94a7317bdde59335f2acd4c3a97c0384c1
2013-05-13 10:50:17 -05:00
Tommi Rantala 890e23eb9d Prefer NULL over zero 2012-09-28 14:51:21 +03:00
Tommi Rantala fce25d74c9 Eliminate one heap allocation in dwarf_find_debug_frame()
Allocate `tab' from stack in dwarf_find_debug_frame(), as it's only a
few members and we only need it locally in the function.
2012-09-04 14:58:37 +03:00
Tommi Rantala 90d7baea35 Remove free() NULL pointer checks in load_debug_frame() error path
Just pass potentially NULL pointers to free() in the error path in
load_debug_frame(). Saved 40 bytes of code in libunwind.so on ARM -O2
thumb build at the expense of slightly slower execution.
2012-09-04 14:58:24 +03:00
Arun Sharma 43e5ee28c0 Demote the debug level to reduce verbosity 2012-03-25 17:44:53 -07:00
Arun Sharma 786882ff8c Remove unused variable segbase 2011-11-12 10:02:09 -08:00
Ken Werner 1e644990c9 Only declare the start/end variables in case CONFIG_DEBUG_FRAME is defined.
Prevents compiler warnings about unused variables.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-11-12 09:47:12 -08:00
Arun Sharma d20df8b318 Fix up the breakage when host != target 2011-10-31 22:33:47 -07:00
Ken Werner 059676cb00 Prevent the use of struct dl_phdr_info outside of dl_iterate_phdr
Since the dl_iterate_phdr is required for local unwinding only the use of
struct dl_phdr_info can be eliminated in case libunwind gets compiled for
remote unwinding. This enhances libunwinds portability to targets that
don't provide any dl_iterate_phdr functionality.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-29 17:12:43 -07:00
Ken Werner 0fed502a81 UNW_REMOTE_ONLY fixes
Exclude <link.h> because it is only required for local unwinding when
iterating over the program headers.

Have the following DWARF related functions available in case of
UNW_REMOTE_ONLY because they are used by libunwind-ptrace:
  dwarf_find_debug_frame
  locate_debug_info
  find_binary_for_address
  load_debug_frame
  debug_frame_tab_new
  debug_frame_tab_append
  debug_frame_tab_shrink
  debug_frame_tab_compare

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-10-29 17:12:43 -07:00
Ken Werner 0b9f591823 Make the dwarf dl_iterate_phdr callback available within libunwind.
Rename the dwarf dl_iterate_phdr callback routine and the callback_data
structure to dwarf_callback and dwarf_callback_data. Make it available
within libunwind by declaring the two at the dwarf.h header file.

Signed-off-by: Ken Werner <ken.werner@linaro.org>
2011-08-15 20:12:54 +02:00
Arun Sharma 46e10c5abe Support .debug_frame based unwinding in _UPTi_find_unwind_table()
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-26 19:25:41 -07:00
Arun Sharma 546463d1e7 Factor out and export dwarf_find_debug_frame() function
Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-26 19:21:30 -07:00
Arun Sharma b115ab645a Ignore separate debug files which contain a .gnu_debuglink section.
Current implementation fails to find separate debug symbols when
.gnu_debuglink is set to the same name of the target ELF basename
(e.g. "libc.so.6" for /lib/libc.so.6). This patch fixes this by ignoring
separate debug files that contain a .gnu_debuglink section.

It also fixes a small typo in a related Debug() line.

Signed-off-by: Andris Zeila <andris.zeila@accenture.com>
2010-05-15 11:57:35 -07:00
Lassi Tuura 250382c56d Use wider format when printing addresses in debug format. 2010-04-24 17:18:19 -07:00
Arun Sharma 491d576529 Fix compiler warnings on x86_64 2009-10-16 14:01:50 -07:00
Paul Pluzhnikov b56375e76a Reduce stack use and apply CONFIG_DEBUG_FRAME to more code.
Currently, libunwind allocates several PATH_MAX entries on stack, while
trying to find a binary via /proc/.../maps.

However stack space may be at premium (especially when sigaltstack is used),
and PATH_MAX on Linux is 4096, while SIGSTKSZ is only 8192 on x86.

Attached patch eliminates multiple PATH_MAX stack allocations, and simplifies
code in maps_next, at the cost of being unable to do anything if we can't
mmap one page. It appears to me that under such low-memory conditions,
libunwind will fail shortly elsewhere anyway.

This patch also disables more of debug_frame-handling code when
CONFIG_DEBUG_FRAME is undefined.

Tested on Linux/x86_64 with and without CONFIG_DEBUG_FRAME, no regressions.
2009-10-07 12:51:03 -07:00
Paul Pluzhnikov fc2934aade Make the remaining sigprocmask calls conditional on --enable-block-signals 2009-09-29 23:14:50 -07:00
Arun Sharma 9607c6407c Fixup CONFIG_DEBUG_FRAME support. 2009-03-17 19:08:58 -07:00
Arun Sharma a2c27a4ab7 Make .debug_frame support optional.
Because these code paths use malloc and stdio, they could
cause deadlocks when we try to unwind stack from inside malloc.
2009-03-16 21:21:58 -07: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
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
mostang.com!davidm 1f5ac0f5bd Adjust for sigset_t to intrmask_t renaming.
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)
2005-05-03 09:13:17 +00:00
com[davidm]!marky 271f706944 dwarf: fix local & remote table lookup
(Logical change 1.256)
2004-08-24 08:19:00 +00:00
homeip.net!davidm e9045e3cca Add include of dwarf_i.h now that we need dwarf_reads32().
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)
2004-08-19 12:26:11 +00:00
mostang.com!davidm 8241bb15a8 (struct table_entry): Move declrataion outside of !UNW_REMOTE_ONLY
bracket so the file compiles for UNW_REMOTE_ONLY, too.

(Logical change 1.224)
2004-05-05 01:54:53 +00:00
mostang.com!davidm d3fad3af12 (dwarf_find_proc_info): Mask signal-delivery during dl_iterate_phdr().
(Logical change 1.203)
2004-04-01 08:09:28 +00:00
hp.com!davidm 21595821bf (dwarf_search_unwind_table): Declare as PROTECTED, not HIDDEN.
(Logical change 1.162)
2004-01-30 00:01:24 +00:00
hp.com!davidm eb51b4294a (Logical change 1.145) 2003-12-20 11:43:08 +00:00
hp.com!davidm 0bbb2fab68 Initial revision 2003-12-20 11:38:49 +00:00