Commit Graph

29 Commits

Author SHA1 Message Date
Martin Storsjo d27bec4854 Don't define unw_fpreg_t to uint64_t for __ARM_DWARF_EH__
The existing typedef of unw_fpreg_t to uint64_t might work and be
correct for the ARM_EHABI case, but for dwarf, some cases in e.g.
DwarfInstructions.hpp convert between double and unw_fpreg_t.

When converting implicitly between double and unw_fpreg_t (uint64_t),
the values get interpreted as integers and converted to float and vice
versa, while the correct thing would be to keep the same bit pattern.

Avoid the whole issue by using the same definition of unw_fpreg_t
as all other architectures, when using dwarf unwinding on ARM.

Change assembler functions to take a void pointer instead of
unw_fpreg_t pointer, to avoid having a different mangled symbol name
depending on the actual value of this typedef.

Differential Revision: https://reviews.llvm.org/D57001

llvm-svn: 352461
2019-01-29 09:00:32 +00:00
Chandler Carruth 57b08b0944 Update more file headers across all of the LLVM projects in the monorepo
to reflect the new license. These used slightly different spellings that
defeated my regular expressions.

We understand that people may be surprised that we're moving the header
entirely to discuss the new license. We checked this carefully with the
Foundation's lawyer and we believe this is the correct approach.

Essentially, all code in the project is now made available by the LLVM
project under our new license, so you will see that the license headers
include that license only. Some of our contributors have contributed
code under our old license, and accordingly, we have retained a copy of
our old license notice in the top-level files in each project and
repository.

llvm-svn: 351648
2019-01-19 10:56:40 +00:00
Daniel Cederman 17121adfa6 [Sparc] Add Sparc V8 support
Summary:
Adds the register class implementation for Sparc.
Adds support for DW_CFA_GNU_window_save.
Adds save and restore context functionality.

Adds getArch() function to each Registers_ class to be able to separate
between DW_CFA_AARCH64_negate_ra_state and DW_CFA_GNU_window_save which
are both represented by the same constant.

On Sparc the return address is the address of the call instruction, so
an offset needs to be added when returning to skip the call instruction
and its delay slot. If the function returns a struct it is also necessary
to skip one extra instruction on Sparc V8.

Reviewers: jyknight, mclow.lists, mstorsjo, compnerd

Reviewed By: jyknight, compnerd

Subscribers: jgorbe, mgorny, christof, llvm-commits, fedor.sergeev, JDevlieghere, ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D55763

llvm-svn: 351044
2019-01-14 10:15:20 +00:00
Jorge Gorbe Moya 8d530b777d Revert "[Sparc] Add Sparc V8 support"
This reverts commit r350705.

llvm-svn: 350787
2019-01-10 01:08:31 +00:00
Daniel Cederman b2be18f42d [Sparc] Add Sparc V8 support
Summary:
Adds the register class implementation for Sparc.
Adds support for DW_CFA_GNU_window_save.
Adds save and restore context functionality.

On Sparc the return address is the address of the call instruction,
so an offset needs to be added when returning to skip the call instruction
and its delay slot. If the function returns a struct it is also necessary
to skip one extra instruction.

Reviewers: jyknight, mclow.lists, mstorsjo, compnerd

Reviewed By: compnerd

Subscribers: fedor.sergeev, JDevlieghere, ldionne, libcxx-commits

Differential Revision: https://reviews.llvm.org/D55763

llvm-svn: 350705
2019-01-09 12:06:05 +00:00
Luke Cheeseman e1a819e82d [AArch64][libunwind] Unwinding support for return address signing
- Follow up to revision r342895
- gcc would not build libunwind with the earlier patch as the autia1716
  instruction wasn't allowed to be assembled for pre armv8.3a targets
- The autia1716 instruction lives in the hint space encodings so is a valid
  instruction for all armv8a targets
- To work around this I have swapped out the autia1716 instruction for the hint
  instruction

Differential Revision: https://reviews.llvm.org/D55700

llvm-svn: 349140
2018-12-14 11:30:12 +00:00
Luke Cheeseman 3bdf34f20e Reverting r342895
- The used builtins do not compile for pre arm v8.3a targets with gcc

llvm-svn: 342901
2018-09-24 16:36:33 +00:00
Luke Cheeseman 8284b19c76 [AArch64] Unwinding support for return address signing
- When return address signing is enabled, the LR may be signed on function entry
- When an exception is thrown the return address is inspected used to unwind the call stack
- Before this happens, the return address must be correctly authenticated to avoid causing an abort by dereferencing the signed pointer

Differential Revision: https://reviews.llvm.org/D51432

llvm-svn: 342895
2018-09-24 15:55:35 +00:00
whitequark 4f9c59f863 [OR1K] Add the EPCR special-purpose register to register state.
This makes it possible to unwind hardware exception stack frames,
which necessarily save every register and so need an extra column
for storing the return address. CFI for the exception handler could
then look as follows:

.globl exception_vector
exception_vector:
    .cfi_startproc
    .cfi_signal_frame
    .cfi_return_column 32
    l.addi  r1, r1, -0x100
    .cfi_def_cfa_offset 0x100
    l.sw    0x00(r1), r2
    .cfi_offset 2, 0x00-0x100
    l.sw    0x04(r1), r3
    .cfi_offset 3, 0x04-0x100
    l.sw    0x08(r1), r4
    .cfi_offset 4, 0x08-0x100
    l.mfspr r3, r0, SPR_EPCR_BASE
    l.sw    0x78(r1), r3
    .cfi_offset 32, 0x78-0x100
    l.jal   exception_handler
     l.nop
    l.lwz   r2, 0x00(r1)
    l.lwz   r3, 0x04(r1)
    l.lwz   r4, 0x08(r1)
    l.jr    r9
     l.nop
    .cfi_endproc

This register could, of course, also be accessed by the trace
callback or personality function, if so desired.

llvm-svn: 332513
2018-05-16 19:09:48 +00:00
John Baldwin c3f240f7dc [libunwind][MIPS] Support MIPS floating-point registers for hard-float ABIs.
Summary:
For MIPS ABIs with 64-bit floating point registers including newabi
and O32 with 64-bit floating point registers, just save and restore the
32 floating-point registers as doubles.

For O32 MIPS with 32-bit floating-point registers, save and restore the
individual floating-point registers as "plain" registers.  These registers
are encoded as floats rather than doubles, but the DWARF unwinder
assumes that floating-point registers are stored as doubles when reading
them from memory (via AddressSpace::getDouble()).  Treating the
registers as "normal" registers instead causes the DWARF unwinder to
fetch them from memory as a 32-bit register.  This does mean that for
O32 with 32-bit floating-point registers unw_get_fpreg() and
unw_set_fpreg() do not work.  One would have to use unw_get_reg()
and unw_set_reg() instead.  However, DWARF unwinding works
correctly as the DWARF CFI emits records for individual 32-bit
floating-point registers even when they are treated as doubles stored
in paired registers.  If the lack of unw_get/set_fpreg() becomes a pressing
need in the future for O32 MIPS we could add in special handling to
make it work.

Reviewers: sdardis, compnerd

Reviewed By: sdardis

Differential Revision: https://reviews.llvm.org/D41968

llvm-svn: 332414
2018-05-15 22:44:56 +00:00
Martin Storsjo 89e636c87c [PPC64] Added vector registers.
The Registers_ppc64 class needed a couple of changes, both to accommodate the
new registers as well as to handle the overlaps of VS register set
without wasting space.

The save/restore code of V and VS registers was added.
As VS registers depend on the VMX extension, they are processed only if
VMX support is detected (_ARCH_PWR8 for now).

Patch by Leandro Lupori!

Differential Revision: https://reviews.llvm.org/D41906

llvm-svn: 322596
2018-01-16 20:54:10 +00:00
Martin Storsjo 7c907061aa Reland [PPC64] Port to ppc64le - initial version
Initial working version of libunwind for PowerPC 64. Tested on
little-endian ppc64 host only.
Based on the existing PowerPC 32 code.

It supports:

- context save/restore (unw_getcontext, unw_init_local, unw_resume)
- read/write from/to saved registers
- backtrace (unw_step)

Patch by Leandro Lupori!

Differential Revision: https://reviews.llvm.org/D41386

Now builds with LIBUNWIND_ENABLE_CROSS_UNWINDING=ON should
work.

llvm-svn: 321680
2018-01-02 22:11:30 +00:00
Tim Shen f5d150037a Revert `rL321667: [PPC64] Port to ppc64le - initial version`
Differential Revision: https://reviews.llvm.org/D41386

llvm-svn: 321678
2018-01-02 22:04:03 +00:00
Martin Storsjo 0aa55fdbba [PPC64] Port to ppc64le - initial version
Initial working version of libunwind for PowerPC 64. Tested on
little-endian ppc64 host only.
Based on the existing PowerPC 32 code.

It supports:

- context save/restore (unw_getcontext, unw_init_local, unw_resume)
- read/write from/to saved registers
- backtrace (unw_step)

Patch by Leandro Lupori!

Differential Revision: https://reviews.llvm.org/D41386

llvm-svn: 321667
2018-01-02 20:10:54 +00:00
John Baldwin dfbbbdf8cd [libunwind][MIPS]: Add support for unwinding in O32 and N64 processes.
This supports the soft-float ABI only and has been tested with both clang
and gcc on FreeBSD.

Reviewed By: sdardis, compnerd

Differential Revision: https://reviews.llvm.org/D38110

llvm-svn: 320528
2017-12-12 21:43:36 +00:00
Martin Storsjo 6a3ed9bfd0 Fix building for ARM with dwarf exception handling
The previous definition of _LIBUNWIND_HIGHEST_DWARF_REGISTER seems
to be a copy of the ARM64 value (introduced in SVN r276128); since
the code actually hasn't compiled properly for arm in dwarf mode
before, this hasn't actually been used. Set it to the correct value
based on the UNW_ARM_* enum values.

The iwmmx control variables have to be made mutable, since they are
touched from within getRegister (which previously wasn't const), and
getRegister is used on a const Registers object in DwarfInstructions.hpp.

Differential Revision: https://reviews.llvm.org/D39251

llvm-svn: 317192
2017-11-02 08:16:16 +00:00
Martin Storsjo c18d5c05cb Change unw_word_t to always have the same size as the pointer size
This matches the original libunwind API. This also unifies the
type between ARM EHABI and the other configurations, and allows
getting rid of a number of casts in log messages.

The cursor size updates for ppc and or1k are untested, but
unw_proc_info_t shrinks by 4 uint64_t units on i386 at least.

Differential Revision: https://reviews.llvm.org/D39365

llvm-svn: 316942
2017-10-30 19:06:34 +00:00
Martin Storsjo 66bb841f64 Add support for dwarf unwinding on windows on x86_64
Clang doesn't currently support building for windows/x86_64 with
dwarf by setting command line parameters, but if manually modified
to use dwarf, we can make libunwind work in this configuration
as well.

Also include i386 in the docs when adding this as a supported
configuration; libunwind already works for i386 windows, but
can fail due to an issue unrelated to windows itself.

Differential Revision: https://reviews.llvm.org/D38819

llvm-svn: 316747
2017-10-27 08:11:36 +00:00
Ranjeet Singh 5808011bd9 [libunwind] Clean up macro usage.
Convention in libunwind is to use !defined(FOOT) not !FOO.

Differential Revision: https://reviews.llvm.org/D31078

llvm-svn: 299225
2017-03-31 15:28:06 +00:00
Saleem Abdulrasool b64d3273a3 X86: swap EBP, ESP on !APPLE
Restore the `libunwind.h` enumeration values back to the inverted
values.  This diverges from the DWARF definition of the register values.
However, this allows our header to be compatible with other unwind
implementations (e.g. HP, GNU Savannah, GCC).

The register IDs are only swapped in the header and need to be unswapped
when accessing the unwind register file.  The flipped EBP and ESP only
applies on non-Apple x86 targets.

When optimizations were enabled, EBP and ESP would no longer be
equivalent.  As a result, the incorrect access on Linux would manifest
as a failure to unwind the stack.  We can now unwind the stack with and
without FPO on Linux x86.

Resolves PR30879!

llvm-svn: 292723
2017-01-21 16:22:59 +00:00
Marshall Clow cee23446e1 Add support for old versions of MacOS to libunwind. Fixes PR22203. Thanks to Jeremy for the bug report and the patch.
llvm-svn: 285845
2016-11-02 17:56:05 +00:00
Ed Schouten 47ca99b372 Also use the proper register numbers on CloudABI.
Without this change applied, unw_step() fails to obtain the next frame
properly.

llvm-svn: 282589
2016-09-28 13:51:23 +00:00
Ed Maste b0abba5c32 libunwind: fix X86 register numbers for FreeBSD/i386
For historical reasons i386 has ebp and esp swapped in the eh_frame
register numbering on at least Darwin.  That is:

                 Darwin      FreeBSD
        Reg #    eh_frame    eh_frame    DWARF
        =====    ========    ========    =====
          4        ebp         esp        esp
          5        esp         ebp        ebp

Although the UNW_X86_* constants are not intended to be coupled with
DWARF / eh_frame numbering they are currently conflated in libunwind.

Differential Revision:	https://reviews.llvm.org/D22508

llvm-svn: 280099
2016-08-30 15:10:08 +00:00
Ed Maste e8a15cef9d libunwind: correct 'libuwind' typo
There were several instances of libuwind (missing an "n"), dating to
the initial import of libunwind.

llvm-svn: 280086
2016-08-30 13:08:21 +00:00
Ed Maste c073b1bac9 libunwind: Use conventional DWARF capitalization in comments and errors
llvm-svn: 275996
2016-07-19 17:15:50 +00:00
Asiri Rathnayake 54387eef07 Introduce a native-only unwinder build.
Currently libunwind is built to support cross-unwinding [1] by default, which
requires the buffers unw_context_t and unw_cursor_t to be large enough to hold
the vritual register set (VRS) of any supported architecture. This is not
desirable for some platforms where the stack usage of the unwinder needs
to be kept to a minimum (e.g. bare-metal targets). The current patch introduces
a native-only (-DLIBUNWIND_ENABLE_CROSS_UNWINDING=OFF) unwinder variant that
adopts strict sizes for the buffers unw_context_t and unw_cursor_t depending
on the target architecture.

[1] http://www.nongnu.org/libunwind/man/libunwind(3).html#section_4

Change-Id: I380fff9a56c16a0fc520e3b1d8454a34b4a48373
llvm-svn: 270692
2016-05-25 12:36:34 +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
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
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