Commit Graph

66 Commits

Author SHA1 Message Date
Koakuma 2b9554b885 [libunwind] [sparc] Add SPARCv9 support
Adds libunwind support for SPARCv9 (aka sparc64). This is a rebase of @kettenis' patch D32450, which I created (with his permission) because the original review has become inactive.
The changes are of a cosmetic nature to make it fit better with the new code style, and to reuse the existing SPARCv8 code, whenever possible.

Please let me know if I posted this on the wrong place. Also, the summary of the original review is reproduced below:

> This adds unwinder support for 64-bit SPARC (aka SPARCv9). The implementation was done on OpenBSD/sparc64, so it takes StackGhost into account:
>
> https://www.usenix.org/legacy/publications/library/proceedings/sec01/full_papers/frantzen/frantzen_html/index.html
>
> Since StackGhost xor's return addresses with a random cookie before storing them on the stack, the unwinder has to do some extra work to recover those. This is done by introducing a new kRegisterInCFADecrypt "location" type that is used to implement the DW_CFA_GNU_window_save opcode. That implementation is SPARC-specific, but should work for 32-bit SPARC as well. DW_CFA_GNU_window_save is only ever generated on SPARC as far as I know.

Co-authored-by: Mark Kettenis
Reviewed By: #libunwind, thesamesam, MaskRay, Arfrever

Differential Revision: https://reviews.llvm.org/D116857
2022-02-05 13:08:26 -08:00
Sam James cd20e579df [unwind] fix build with GCC on PPC32
Originally reported downstream in Gentoo: https://bugs.gentoo.org/832140

```
/var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp:77:3: error: #error Architecture not supported
   77 | # error Architecture not supported
      |   ^~~~~
[...]
/var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp: In function ‘int __unw_init_local(unw_cursor_t*, unw_context_t*)’:
/var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp:80:57: error: ‘REGISTER_KIND’ was not declared in this scope
   80 |   new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor))
      |                                                         ^~~~~~~~~~~~~
[...]
```

PPC is actually a supported architecture, but GCC (tested with 11.2.0)
on powerpc32 seems to only define: `__PPC__, _ARCH_PPC, __PPC,
__powerpc` and //not// `__ppc__`.

This instead uses `__powerpc__` which should be around on PPC32
and PPC64 (but we check it after PPC64, so it's fine).

Signed-off-by: Sam James <sam@gentoo.org>
Differential Revision: https://reviews.llvm.org/D118320
2022-01-27 23:05:11 +01:00
John Ericson 914fffc7f2 [libunwind][cmake] Create `LIBUNWIND_INSTALL_INCLUDE_DIR` CACHE PATH
This is created on analogy with the other CACHE PATHs in this package,
and other `*_INSTALL_INCLUDE_DIR` in other packages.

The branching is adjusted to deduplicate some existing code, and
likewise avoid having to define this new variable more than once.

This will be used for D99484.

Reviewed By: #libunwind, compnerd

Differential Revision: https://reviews.llvm.org/D116873
2022-01-10 21:31:52 +00:00
PoYao Chang 1c4867e6fc [libunwind] Provide a way to conveniently install libunwind headers
This adds a CMake option (defaults to OFF to not be intrusive) to activate
2 new targets `install-unwind-headers` and `install-unwind-headers-stripped`.
So, for example:

  cmake -S runtimes -B build -G Ninja \
    -DLLVM_ENABLE_RUNTIMES='libunwind' \
    -DLIBUNWIND_INSTALL_HEADERS=ON

And then, `ninja -C build install-unwind` would install headers in addition
to good ol' dylibs and archives, i.e., targets `install-unwind*` `DEPENDS`
on `install-unwind-headers*`. On the other hand,
`ninja -C build install-unwind-headers` gives you headers only.

Differential Revision: https://reviews.llvm.org/D115535
2021-12-16 13:32:40 -05:00
Ties Stuij e6d0b851f8 [ARM][libunwind] add PACBTI-M support for libunwind
This patch implements the following:

- Emit PACBTI-M build attributes in libunwind asm files

- Authenticate LR in DWARF32 using PACBTI

Use Armv8.1-M.Main PACBTI extension to authenticate the return address
(stored in the LR register) before moving it to the PC (IP) register.

The AUTG instruction is used with the candidate return address, the CFA,
and the authentication code that is retrieved from the saved
pseudo-register RA_AUTH_CODE.

- Authenticate LR in EHABI using PACBTI

Authenticate the contents of the LR register using Armv8.1-M.Main PACBTI
extension.

A new frame unwinding instruction is introduced (0xb4). This
instruction pops out of the stack the return address authentication
code, which is then used in conjunction with the SP and the next-to-be
instruction pointer to perform authentication.

This authentication code is popped into a new register,
UNW_ARM_PSEUDO_PAC, which is a pseudo-register.

This patch is part of a series that adds support for the PACBTI-M extension of
the Armv8.1-M architecture, as detailed here:

https://community.arm.com/arm-community-blogs/b/architectures-and-processors-blog/posts/armv8-1-m-pointer-authentication-and-branch-target-identification-extension

The PACBTI-M specification can be found in the Armv8-M Architecture Reference
Manual:

https://developer.arm.com/documentation/ddi0553/latest

The following people contributed to this patch:

- Momchil Velikov
- Victor Campos
- Ties Stuij

Reviewed By: #libunwind, danielkiss, mstorsjo

Differential Revision: https://reviews.llvm.org/D112430
2021-12-08 09:44:45 +00:00
Louis Dionne eb8650a757 [runtimes][NFC] Remove filenames at the top of the license notice
We've stopped doing it in libc++ for a while now because these names
would end up rotting as we move things around and copy/paste stuff.
This cleans up all the existing files so as to stop the spreading
as people copy-paste headers around.
2021-11-17 16:30:52 -05:00
Daniel Kiss f5b997e6b7 [Unwind] Harmonise exception class for EHABI spec.
EHABI defines the exception class as char[8] instead of uint64_t [1].
For ABI compatibility the ABI the definition needs to be updated.

[1] https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst#82language-independent-unwinding-types-and-functions

Reviewed By: manojgupta, MaskRay, #libunwind

Differential Revision: https://reviews.llvm.org/D109047
2021-09-02 11:31:03 +02:00
Fangrui Song 9ae9dd3fcf [libunwind] Add UNW_AARCH64_* beside UNW_ARM64_*
The original libunwind project defines UNW_AARCH64_* instead of UNW_ARM64_*.
Rename the enum members to match. This allows some applications with simple
`unw_init_local` usage to migrate to llvm-project libunwind.

Note: the canonical names of `UNW_ARM_D{0..31}` are now `UNW_AARCH64_V{0..31}`,
to match the original libunwind.

UNW_ARM64_* are kept for now for compatibility. Some may be unneeded and can be
cleaned up in the future.

Reviewed By: #libunwind, compnerd

Differential Revision: https://reviews.llvm.org/D107996
2021-08-20 14:26:27 -07:00
Daniel Kiss db126ae243 [Arm][Unwind][libc++abi] Add _Unwind_ForcedUnwind to EHABI.
_Unwind_ForcedUnwind is not mandated by the EHABI but for compatibilty
reasons adding so the interface to higher layers would be the same.
Dropping EHABI specific _Unwind_Stop_Fn definition since it is not defined by EHABI.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D89570
2021-08-11 10:15:53 +02:00
Daniel Kiss 9ed1c7e496 [Unwind] Split unwind.h
Moving Itanium and ArmEHABI specific implementations to dedicated files.
This is a NFC patch.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D106461
2021-08-11 10:15:51 +02:00
Kamlesh Kumar b17d46430f [libunwind] This adds support in libunwind for rv32 hard float
and soft-float for both rv32 and rv64.

Differential Revision: https://reviews.llvm.org/D80690
2021-03-02 06:58:24 +05:30
Marco Vanotti 78eabcaa48 [libunwind] Add support for PC reg column in arm64
This change adds support for the dwarf PC register column in arm64, allowing
CFI directives to make use of it.

As of the last revision of the DWARF for ARM 64-bit architecture[0], the pc
register has been added as a valir register, with number 32.

This allows libunwinder to restore both pc and lr, which is useful
for stack switches and signal contexts.

[0]:
f52e1ad3f8/aadwarf64/aadwarf64.rst

Reviewed By: phosek, #libunwind

Differential Revision: https://reviews.llvm.org/D96901
2021-02-17 17:42:19 -08:00
Kazushi (Jam) Marukawa 3cbd476c54 [VE] Support VE in libunwind
Modify libunwind to support SjLj exception handling routines for VE.
In order to do that, we need to implement not only SjLj exception
handling routines but also a Registers_ve class.  This implementation
of Registers_ve is incomplete.  We will work on it later when we need
backtrace in libunwind.

Reviewed By: #libunwind, compnerd

Differential Revision: https://reviews.llvm.org/D94591
2021-01-17 15:35:02 +09:00
Ryan Prichard c82deed676 [libunwind] Unwind through aarch64/Linux sigreturn frame
An AArch64 sigreturn trampoline frame can't currently be described
in a DWARF .eh_frame section, because the AArch64 DWARF spec currently
doesn't define a constant for the PC register. (PC and LR may need to
be restored to different values.)

Instead, use the same technique as libgcc or github.com/libunwind and
detect the sigreturn frame by looking for the sigreturn instructions:

    mov x8, #0x8b
    svc #0x0

If a sigreturn frame is detected, libunwind restores all the GPRs by
assuming that sp points at an rt_sigframe Linux kernel struct. This
behavior is a fallback mode that is only used if there is no ordinary
unwind info for sigreturn.

If libunwind can't find unwind info for a PC, it assumes that the PC is
readable, and would crash if it isn't. This could happen if:
 - The PC points at a function compiled without unwind info, and which
   is part of an execute-only mapping (e.g. using -Wl,--execute-only).
 - The PC is invalid and happens to point to unreadable or unmapped
   memory.

In the tests, ignore a failed dladdr call so that the tests can run on
user-mode qemu for AArch64, which uses a stack-allocated trampoline
instead of a vDSO.

Reviewed By: danielkiss, compnerd, #libunwind

Differential Revision: https://reviews.llvm.org/D90898
2021-01-13 16:38:36 -08:00
Martin Storsjö 542db87f1a [libunwind] Ensure enough alignment for unw_cursor_t for SEH build configurations
When built in SEH mode, UnwindCursor contains a CONTEXT struct,
which is aligned to 16 bytes in most configurations, causing the
whole UnwindCursor object to have 16 byte alignment.

This fixes backtraces using _Unwind_Backtrace on x86_64 mingw,
where an unw_cursor_t allocated on the stack was misaligned before.

This is an ABI break for this struct for this configuration, but very
few callers call libunwind directly (and even fewer directly allocate
an unw_cursor_t anyway).

Differential Revision: https://reviews.llvm.org/D86102
2020-08-22 22:48:57 +03:00
Brian Cain 9107594f37 [libunwind] add hexagon support 2020-04-10 04:24:10 -05:00
Saleem Abdulrasool 14798b4465 unwind: rename `__personality_routine` to `_Unwind_Personality_Fn`
This patch renames `__personality_routine` to `_Unwind_Personality_Fn`
in `unwind.h`. Both `unwind.h` from clang and GCC headers use this name
instead of `__personality_routine`. With this patch one is also able to
build libc++abi with libunwind support on Windows.

Patch by Markus Böck!
2020-02-10 08:52:31 -08:00
Sam Elliott ce3d1c6d61 [libunwind][RISCV] Add 64-bit RISC-V support
Summary:
Add unwinding support for 64-bit RISC-V.

This is from the FreeBSD implementation with the following minor
changes:

- Renamed and renumbered DWARF registers to match the RISC-V ABI [1]
- Use the ABI mneumonics in getRegisterName() instead of the exact
   register names
- Include checks for __riscv_xlen == 64 to facilitate adding the 32-bit
   ABI in the future.

[1] https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md

Patch by Mitchell Horne (mhorne)

Reviewers: lenary, luismarques, compnerd, phosek

Reviewed By: lenary, luismarques

Subscribers: arichardson, sameer.abuasal, abidh, asb, aprantl, krytarowski, simoncook, kito-cheng, christof, shiva0217, rogfer01, rkruppe, PkmX, psnobl, benna, lenary, s.egerton, luismarques, emaste, cfe-commits

Differential Revision: https://reviews.llvm.org/D68362
2019-12-16 16:36:56 +00:00
Louis Dionne 2b0da3d63e [NFC] Correct outdated links to the Itanium C++ ABI documentation
Those are now hosted on GitHub.

rdar://problem/36557462

llvm-svn: 358191
2019-04-11 16:37:07 +00:00
Petr Hosek 368c02e3ec [libunwind] Remove the remote unwinding support
This is unfinished, unused and incomplete. This could be brought back in
the future if there's a desire to build a more complete implementation,
but at the moment it's just bitrotting.

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

llvm-svn: 352965
2019-02-02 20:54:03 +00:00
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
Martin Storsjo 09cf6374c1 [SEH] Add initial support for AArch64
This doesn't yet implement inspecting the .pdata/.xdata to find the
LSDA pointer (in UnwindCursor::getInfoFromSEH), but normal C++
exception handling seems to run just fine without it. (The only
place I can see where it's even referenced is in
unwind_phase2_forced, and I can't find a codepath where libcxxabi
would end up calling that.)

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

llvm-svn: 349532
2018-12-18 20:05:59 +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
Martin Storsjo a2646444d2 Fix existing code for SEH on ARM to compile correctly
Even though SEH for ARM is incomplete, make what code already exists
at least compile correctly.

The _LIBUNWIND_CURSOR_SIZE wasn't correct.

ARM (and AArch64) have a DISPATCHER_CONTEXT field named TargetPc
instead of TargetIp.

For the libunwind.h UNW_* constants, there is no UNW_ARM_PC, only
UNW_ARM_IP.

Don't use 'r' as loop variable when 'r' already is a Registers_arm
member.

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

llvm-svn: 341217
2018-08-31 14:56:55 +00:00
Charles Davis a7e3a6d802 Add support for SEH unwinding on Windows.
Summary:
I've tested this implementation on x86-64 to ensure that it works. All
`libc++abi` tests pass, as do all `libc++` exception-related tests. ARM
still remains to be implemented (@compnerd?).

Special thanks to KJK::Hyperion for his excellent series of articles on
how EH works on x86-64 Windows. (Seriously, check it out. It's awesome.)

I'm actually not sure if this should go in as is. I particularly don't
like that I duplicated the UnwindCursor class for this special case.

Reviewers: mstorsjo, rnk, compnerd, smeenai, javed.absar

Subscribers: mgorny, kristof.beyls, christof, chrib, cfe-commits, compnerd, llvm-commits

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

llvm-svn: 341125
2018-08-30 21:29:00 +00:00
Charles Davis b006dafbef Remove unneeded preprocessor condition.
llvm-svn: 339259
2018-08-08 15:18:22 +00:00
Charles Davis 06acf1f638 [libunwind][include] Add SEH declarations to <unwind.h>.
Summary:
Make the `_Unwind_Exception` struct correct under SEH. Add a
declaration of `_GCC_specific_handler()`, which is used by SEH versions
of Itanium personality handlers to do common setup. Roughly corresponds
to Clang's D50380.

Reviewers: mstorsjo, rnk, compnerd, smeenai

Subscribers: christof, chrib, cfe-commits, llvm-commits

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

llvm-svn: 339258
2018-08-08 15:18:20 +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
John Baldwin 0594aee52f [libunwind][MIPS]: Add support for unwinding in N32 processes.
Summary:
N32 uses the same register context as N64.  However, N32 requires one
change to properly fetch addresses from registers stored in memory.
Since N32 is an ILP32 platform, getP() only fetches the first 32-bits
of a stored register.  For a big-endian platform this fetches the
upper 32-bits which will be zero.  To fix this, add a new
getRegister() method to AddressSpace which is responsible for
extracting the address stored in a register in memory.  This matches
getP() for all current ABIs except for N32 where it reads the 64-bit
register and returns the low 32-bits as an address.  The
DwarfInstructions::getSavedRegister() method uses
AddressSpace::getRegister() instead of AddressSpace::getP().

Reviewers: sdardis, compnerd

Reviewed By: sdardis

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

llvm-svn: 326250
2018-02-27 21:24:02 +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
John Baldwin 40bab37551 [libunwind][MIPS]: Rename Registers_mips_n64 to Registers_mips_newabi.
This is in preparation for adding support for N32 unwinding which reuses
the newabi register class.

Reviewed By: compnerd

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

llvm-svn: 322093
2018-01-09 17:07:18 +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 d9e8909261 Restore arch specific lastDwarfRegNum in builds without _LIBUNWIND_IS_NATIVE_ONLY
This restores the previous behaviour of the Registers_* classes
after SVN r316745.

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

llvm-svn: 316843
2017-10-28 20:19:49 +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
Martin Storsjo 62dd9d20d5 Express Registers_*::lastDwarfReg using _LIBUNWIND_HIGHEST_DWARF_REGISTER
This avoids having to keep the same information duplicated in multiple
places.

Adjust _LIBUNWIND_HIGHEST_DWARF_REGISTER to actually have the value
of the highest used register and only use the value
_LIBUNWIND_HIGHEST_DWARF_REGISTER + 1 (kMaxRegisterNumber + 1) for
allocating the savedRegisters array.

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

llvm-svn: 316745
2017-10-27 07:59:01 +00:00
Martin Storsjo dd45ea16f3 Fix the context/cursor size for ARM with WMMX enabled
This was missed in SVN r274744 when the WMMX part was made optional;
when made optional, some struct fields were reordered, which caused
the total struct size to grow due to padding/alignment.

llvm-svn: 316559
2017-10-25 08:07:19 +00:00
Saleem Abdulrasool f8774f1d73 ARM: explicitly specify the 8-byte alignment
It seems that GCC interprets `__attribute__((__aligned__))` as 8-byte
alignment on ARM, but clang does not.  Explicitly specify the
double-word alignment value to ensure that the structure is properly
aligned.

llvm-svn: 311574
2017-08-23 16:50:27 +00:00
Saleem Abdulrasool 5b389f1cf7 unwind: explicitly align `_Unwind_Control_Block`
The C++ ABI requires that the exception object is double-word aligned.
The alignment attribute was applied to the `_Unwind_Exception` type
which is used on non-EHABI targets.  On EHABI, the exception object type
is `_Unwind_Control_Block`.  Apply the explicit maximal alignment on the
type to ensure that the allocation has the correct alignment.

Resolves PR33858!

llvm-svn: 311562
2017-08-23 15:33:45 +00:00