Commit Graph

32 Commits

Author SHA1 Message Date
Peter Zotov b0342a66a0 Make it possible to use libunwind without heap.
This patch allows to use libunwind on bare-metal systems that do not
include malloc/free by conditionally turning off nonessential
functionality that requires these functions.

The disabled functionality includes:

  * the .cfi_remember_state and .cfi_restore_state instructions;
  * the DWARF FDE cache.

The .cfi_{remember,restore}_state instructions don't seem to be used
by contemporary compilers. None of the LLVM backends emit it.

The DWARF FDE cache is bypassed if _LIBUNWIND_NO_HEAP is defined.
Specifically, entries are never added to it, so the search begins
and ends at the statically allocated, empty initial cache.

Such heap-less libunwind on a bare metal system is successfully used
in the ARTIQ project[1], and it is my hope that it will be useful
elsewhere.

[1]: http://m-labs.hk/artiq

Differential Revision: http://reviews.llvm.org/D11897

llvm-svn: 252452
2015-11-09 06:57:29 +00:00
Ed Maste 5f1896a1ab Add FreeBSD _Unwind_Ptr typedef
Differential Revision:	http://reviews.llvm.org/D13820

llvm-svn: 250541
2015-10-16 19:40:09 +00:00
Vasileios Kalintiris 8518eb54f3 unwind: Allow the building of libunwind for MIPS.
Summary:
Currently, libunwind doesn't support MIPS. However, with this patch
we do allow the library to build, and we warn the user about the lack of
support for MIPS. Also, the dummy unw_getcontext() implementation for MIPS just
traps on function entry in order to avoid any confusion with silent/weird
failures at runtime.

This allows us to test an LLVM-based toolchain without the dependency on a
GCC toolchain. Of course, C++ exception handling and other things that depend
on stack unwinding will not work until we add a proper implementation of the
stub functions.

Reviewers: compnerd, logan

Subscribers: dsanders, llvm-commits

Differential Revision: http://reviews.llvm.org/D13160

llvm-svn: 248673
2015-09-26 18:26:01 +00:00
Saleem Abdulrasool 520aaa2f7d unwind: cleanup -Wunused-parameter
Cleanup a number of `-Wunused-parameter` warnings.  NFC.

llvm-svn: 246528
2015-09-01 04:29:03 +00:00
Peter Zotov ce4c5c9849 [libunwind] Add support for OpenRISC 1000.
This patch makes no assumptions on ABI past the ABI defined in
the OpenRISC 1000 spec except that the DWARF register numbers will
be 0-31 for registers r0-r31, which is true for both gcc and
clang at the moment.

llvm-svn: 246413
2015-08-31 05:26:37 +00:00
Peter Zotov 43ad01462a [libunwind] Remove unused includes.
llvm-svn: 246143
2015-08-27 06:58:31 +00:00
Saleem Abdulrasool fddd0e66de unwind: fix invalid memory access
Fix out-of-bounds array access when setting arm float registers.

Patch by Leandro Graciá Gil!

llvm-svn: 245665
2015-08-21 03:21:31 +00:00
Ed Maste ef766a7e70 Enable zero-cost exceptions on non-Apple arm64 platforms
Use the canonical __aarch64__ predefined macro for 64-bit ARM. Apple-
specific cases are left as __arm64__. Also add an #error for unsupported
architectures to catch this sort of case in the future.

Differential Revision: http://reviews.llvm.org/D12005

llvm-svn: 244893
2015-08-13 14:21:03 +00:00
Ed Maste 76050da17e Correct sense of unwind return address register range assertion
I encountered this on FreeBSD/arm64, and then found the same issue was
reported by Daniil Troshkov.

llvm-svn: 244892
2015-08-13 13:45:45 +00:00
Tanya Lattner d93178de50 Revert test commit.
llvm-svn: 244297
2015-08-06 23:31:37 +00:00
Tanya Lattner 901f3c7bc0 Test commit
llvm-svn: 244296
2015-08-06 23:30:28 +00:00
Renato Golin 14c3c4bb85 [ARM/Unwind] Fix wrong usage of write-back on register save
The register save routine in libunwind was using write-back addressing
mode to r0 for thumb, when that was not only different from the ARM
version and more importantly the register restore, but also saving the
wrong address.

Patch by Manuel Freiberger.

Fixes PR24331.

llvm-svn: 244237
2015-08-06 18:15:17 +00:00
Tanya Lattner c1452f80cf Update to new lists.llvm.org
llvm-svn: 244005
2015-08-05 04:01:47 +00:00
Renato Golin 57cb9919c5 [libunwind] Flip order of extern "C" and attribute(visibility)
GCC doesn't seems to like having the attribute before extern, but
Clang accepts it either way. This patch makes it compile on both.

llvm-svn: 243147
2015-07-24 19:29:05 +00:00
Logan Chien ff8fbf9f90 unwind: Fix libc++abi and libgcc build.
To build libc++abi without libunwind, we should make sure that all
function calls to _Unwind_{Get,Set}{GR,IP}() are inlined as function
calls to _Unwind_VRS_{Get,Set}().  Otherwise, libc++abi.so will fail to
link since libgcc does not provide these symbol at all.

This commit fixes the problem by providing both the inlined version and
exported version.

llvm-svn: 243073
2015-07-24 00:16:48 +00:00
Hans Wennborg 483d4ed212 Update version to 3.8.0svn
llvm-svn: 242942
2015-07-22 21:36:42 +00:00
Logan Chien 5191fe9509 libunwind: Introduce __libunwind_config.h.
Introduce __libunwind_config.h to avoid cross repository circular
dependency with libcxxabi.

llvm-svn: 242642
2015-07-19 15:23:10 +00:00
Logan Chien 549d405877 Fix unw_getcontext() return value on AArch64.
unw_getcontext() should return UNW_ESUCCESS on success.  Therefore, the
assembly for AArch64 is incorrect because "ldr x0, #0" is a PC-relative
load instead of an immediate value load.

llvm-svn: 240648
2015-06-25 15:12:46 +00:00
Logan Chien aa938fa6b6 Avoid C99 for-declaration statement in C files. (NFC)
To compile libunwind with gcc/g++ 4.9, it is required to avoid the
for-declaration statement from C99.

llvm-svn: 240609
2015-06-25 00:05:24 +00:00
Logan Chien b08cf1cfd2 Code cleanup: Reindent statements.
llvm-svn: 238656
2015-05-30 14:00:39 +00:00
Logan Chien 7fab97f364 libunwind: Fix unw_step() for ARM EHABI.
This commit fixes the unw_step() for ARM EHABI.  However, this commit
also changes the implementation details for ARM EHABI.

The first change is that the personality function should call
__gnu_unwind_frame() for default (or de facto) frame unwinding based on
the ARM-defined unwind opcode.  The function __gnu_unwind_frame() will
in turn calls unw_step() which actually unwinds the frame.

The second change is that the implementation _Unwind_Backtrace() should
no longer calls unw_step() to unwind the frame; since according to ARM
EHABI, the personality function should unwind the frame for us.

Special thanks to Anton for helpful suggestion on the initial version of
this patch.

llvm-svn: 238560
2015-05-29 15:33:38 +00:00
Logan Chien c6ec96f9be Code cleanup: Remove duplicated line.
llvm-svn: 237542
2015-05-17 13:49:18 +00:00
Saleem Abdulrasool 5ccb0b5f87 unwind: permit building against libstdc++
Include algorithm early as otherwise you get a number of particularly unhelpful
messages about failed static assertions.  This fixes compilation on Linux with
gcc.

llvm-svn: 237002
2015-05-11 16:35:13 +00:00
Anton Korobeynikov 398ae2dee1 Add ARC config
llvm-svn: 236935
2015-05-09 20:56:15 +00:00
Saleem Abdulrasool 0c809e87be unwind: add a .clang-format
This just copies the default clang-format from the LLVM project.  Many
developers use clang-format to ensure that the code is appropriately formatted,
and this commit should also test the git-svn bridge.

llvm-svn: 236767
2015-05-07 19:50:18 +00:00
Viktor Kutuzov 66f711d185 Fix libunwind to build on FreeBSD
Differential Revision: http://reviews.llvm.org/D9272

llvm-svn: 236585
2015-05-06 10:32:28 +00:00
Ed Schouten 8fd97a3ade Make the .eh_frame_hdr code work on FreeBSD as well.
We currently only include <link.h> on CloudABI and Linux. We can enable
it on FreeBSD as well, as it also supports the dl_iterate_phdr()
function that's provided by <link.h>.

FreeBSD, however, does not provide the ElfW() macro. Instead, the
host-specific ELF datastructures are named just Elf_XXX in addition to
the host-independent Elf32_XXX and Elf64_XXX types.

Differential Revision:	http://reviews.llvm.org/D8169
Approved by:	emaste

llvm-svn: 236154
2015-04-29 20:43:44 +00:00
Saleem Abdulrasool 93174d9542 unwind: remove inclusion of private_typeinfo.h
This include is not currently used.  It is intended for type info based
switching, which is part of the EHABI specification.  However, the unwinder does
not currently support this functionality. This backwards dependency into
libc++abi is currently causing a buildbot failure, remove it until we have a
better solution.

llvm-svn: 235893
2015-04-27 16:51:52 +00:00
Saleem Abdulrasool ea9c4fc75d unwind: clean up warnings from the build
Now thta the build is split, clean up some of the warnings in the build:
  cc1: warning: command line option '-nostdinc++' is valid for C++/ObjC++ but not for C
  cc1: warning: command line option '-fno-rtti' is valid for C++/ObjC++ but not for C

Append the C++ specific flags specifically to the C++ sources.  Avoids the
spurious warnings due to invalid flags being passed during the compilation of
C++ sources.

llvm-svn: 235797
2015-04-25 02:06:15 +00:00
Saleem Abdulrasool c5d132b336 libunwind: add new build logic
This replicates most of the build infrastructure from libc++abi ported to
libunwind.  This allows building libunwind without requiring libc++abi.

llvm-svn: 235795
2015-04-25 01:46:35 +00:00
Saleem Abdulrasool a211afa448 unwind: remove libc++abi tests
These are related to libc++abi's personality routine and not core unwinding.
These have been restored in libc++abi, and are no longer needed here.

llvm-svn: 235766
2015-04-24 20:21:43 +00:00
Saleem Abdulrasool b1b1911777 unwind: move src/Unwind, include/, and test/ unwind content
This moves the majority of the unwind sources into the new project layout for
libunwind.  This was previously discussed on llvmdev at [1].  This is a
purely movement related change, with the build infrastructure currently still
residing in the libc++abi repository.

[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-January/081507.html

llvm-svn: 235758
2015-04-24 19:39:17 +00:00