Commit Graph

168 Commits

Author SHA1 Message Date
Martin Storsjo 5a546f99ec Support building libunwind as a DLL
Differential Revision: https://reviews.llvm.org/D40483

llvm-svn: 319300
2017-11-29 08:21:12 +00:00
Martin Storsjo d7fe2f7f60 [CMake] Use the variable from the right project in install-unwind
llvm-svn: 319299
2017-11-29 08:20:57 +00:00
Petr Hosek b74f98c4e4 [libunwind][CMake] Provide option to disable instalation of the library
This is useful in cases where we only build static library and
libunwind.a is combined with libc++abi.a into a single archive in which
case we don't want to have libunwind.a installed separately. The same
option is already provided by libcxx CMake build.

This change also adds the install-unwind target for consistency with the
libcxxabi and libcxx CMake build.

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

llvm-svn: 318569
2017-11-17 23:29:46 +00:00
Martin Storsjo e95d73958d Remove a FIXME about truncated section names
If the linker chose to store the full section name instead of truncating
it, this field doesn't contain a truncated name, but an offset into
the string table of the binary. The string table isn't loaded/mapped
into memory during runtime though, so it's not possible to read the
full section name, unless we try to locate the DLL/EXE on disk that
the HMODULE corresponds to and load that manually.

Due to this, lld now always prefers writing a truncated section name
for sections that will be mapped at runtime, even when debug info is
enabled.

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

llvm-svn: 318446
2017-11-16 19:36:48 +00:00
Martin Storsjo 3920189bcc [docs] Mention that dwarf unwinding should be supported on arm64/windows
This didn't require any further changes to libunwind as long as win64
in general is handled correctly.

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

llvm-svn: 318383
2017-11-16 07:16:36 +00:00
Martin Storsjo 7ed1188c27 Add ifdefs around ELF specific parts of UnwindRegisters*.S for arm
This allows using dwarf exceptions on MinGW/ARM.

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

llvm-svn: 317423
2017-11-04 21:01:31 +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
Dan Albert 9288938561 [libunwind] Don't use dl_iterate_phdr if __ANDROID_API__ < 21
Summary:
On ARM, dl_iterate_phdr is only implemented in the Android NDK version 21 or later:
https://android.googlesource.com/platform/prebuilts/ndk/+/dev/platform/sysroot/usr/include/link.h#55

Reviewers: thakis, danalbert

Reviewed By: danalbert

Subscribers: dtzWill, aemerson, srhines, kristof.beyls

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

llvm-svn: 317125
2017-11-01 21:26:06 +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
Peter Smith 7f6e910745 [libunwind] Always use unwind tables in tests
For many targets setting -fno-exceptions will prevent unwinding tables from
being generated for the test programs. As libunwind depends on the tables to
unwind the stack several tests will fail.

This change always adds -funwind-tables so that even when -fno-exceptions
is set unwind tables are generated.

fixes PR33858

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

llvm-svn: 316657
2017-10-26 12:02:03 +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
Martin Storsjo d3abd15d8c Add missing checks for register number
Most other cases that touch savedRegisters[reg] have got this check,
but these three seemed to lack it.

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

llvm-svn: 316415
2017-10-24 07:16:40 +00:00
Martin Storsjo ed4a317c55 Abstract rwlocks into a class, provide a SRW lock implementation for windows
This requires _WIN32_WINNT >= 0x0600.

If someone wants to spend effort on supporting earlier versions,
one can easily add another fallback implementation based on
critical sections, or try to load SRW lock functions dynamically.

This makes sure that the FDE cache is thread safe on windows.

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

llvm-svn: 316364
2017-10-23 19:29:36 +00:00
Martin Storsjo c5115b9e65 Make HIDDEN_DIRECTIVE a function-like macro. NFCI.
This avoids a hack for making it a no-op for windows.

Also explicitly check for _WIN32 instead of assuming it.

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

llvm-svn: 316300
2017-10-22 19:39:26 +00:00
Saleem Abdulrasool f7596ece76 GNU: do not read the FDE count if omitted
If there is no binary search table computed, the FDECount encoding is
DW_EH_PE_omit.  Do not attempt to read the FDECount in such a situation
as we will read an incorrect value.  binutils only writes out the
FDECount if the encoding is not DW_EH_PE_omit.

llvm-svn: 316224
2017-10-20 18:47:35 +00:00
Ed Maste 48652257bb libunwind: document tested FreeBSD configs and sort OS list
libunwind is known to work on FreeBSD i386, amd64 (x86_64) and arm64.
It is the unwinder provided by the base system on all of those
architectures.

While here sort the OS list.

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

llvm-svn: 315814
2017-10-14 17:04:04 +00:00
Martin Storsjo 210d9f43a3 Support DWARF unwinding on i386 windows
In practice, with code built with clang, there are still unresolved
issues with DW_CFA_GNU_args_size though.

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

llvm-svn: 315498
2017-10-11 20:06:18 +00:00
Martin Storsjo b03f480c8d [docs] Mention that linux/arm64 is supported with DWARF
llvm-svn: 315497
2017-10-11 20:06:07 +00:00
Martin Storsjo 30df03b57e [docs] Mention that SjLj works on any OS on the archs where supported by the compiler
Differential Revision: https://reviews.llvm.org/D38576

llvm-svn: 315090
2017-10-06 19:14:07 +00:00
Saleem Abdulrasool 5b93ea3b9f build: use POSITION_INDEPENDENT_CODE instead of -fPIC
Rather than hardcode the flag and check if the compiler supports it, use
the CMake property to get the right flag spelling for the compiler.
This makes it generally more portable.

llvm-svn: 314834
2017-10-03 20:22:26 +00:00
Martin Storsjo 3a213316e9 Add CMake support for building for MinGW
This section is similar to what already exists in libcxx and libcxxabi.

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

llvm-svn: 314716
2017-10-02 20:46:37 +00:00
Martin Storsjo cbb415128e Fix building on macOS after SVN r314492
That commit incorrectly expanded the assumption that defined(__APPLE__)
implies SjLj exception handling, which only is true within ARM
code sections.

llvm-svn: 314695
2017-10-02 18:14:06 +00:00
Martin Storsjo 59a5004984 SjLj: Fix building after SVN r314632
The code moved from Unwind_AppleExtras.cpp to Unwind-sjlj.c needed
a few minor modifications to build as C instead of C++.

llvm-svn: 314635
2017-10-01 20:22:40 +00:00
Saleem Abdulrasool 9ebbda838f SjLj: make the SjLj implementation more portable
This moves the definition of the internal helpers
`__Unwind_SjLj_GetTopOfFunctionStack` and
`__Unwind_SjLj_SetTopOfFunctionStack` into `Unwind-sjlj.c`.  These are
not extra functions specific to Apple, but rather are internal
implementation details of SjLj support in the LLVM libunwind
implementation.

This allows us to remove the internal header unwind_ext.h, as these
functions are not meant to be used as SPI either.  Because they are
static, they will be given implicit hidden visibility, but due to the
simplicity should get fully inlined into the actual use.

Use the C11 standard static TLS annotation (`_Thread_local`) if
possible, otherwise, use the Windows specific `__declspec(thread)` when
targeting Windows or the GNU `__thread` extension.  In theory, it should
be possible for this implementation to use a `pthread_setspecific` and
`pthread_getspecific` on platforms with pthreads or `SetFlsValue` and
`GetFlsValue` on Windows for non-static TLS.  However, static TLS tends
to be significantly faster, so we really should prefer that over the
dynamic TLS approach.  On Apple environments, when not building for the
loader (dyld), use the pre-allocated TLS slot in the loader rather than
the local static TLS variable.

Note that the un-threaded support of libunwind is still present as
before, however, it is unsafe to use in a threaded environment as the
cleanup stack may be mutated incorrectly due to lack of locking across
threads.  In the static TLS model, the lock is unneeded as each thread
of execution retains its own copy of the cleanup stack.

Take the opportunity to clean up the comment block, removing the iOS
specific note as the SjLj implementation can be used outside of the
context of iOS.  Convert the rest of the explanation to a doxygen style
comment block.

llvm-svn: 314632
2017-10-01 20:06:48 +00:00
Martin Storsjo c2ec6ce65c Skip building x86 parts of UnwindRegisters*.S when targeting SjLj
This extends SVN r314197 from the arm parts to the whole file.

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

llvm-svn: 314492
2017-09-29 06:09:09 +00:00
Martin Storsjo b51c49aa52 Skip building unused parts when targeting SJLJ
When SJLJ exceptions are used, those functions aren't used.

This fixes build failures on ARM with SJLJ enabled (e.g. on armv7/iOS)
when built using the CMake project files.

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

llvm-svn: 314197
2017-09-26 08:07:26 +00:00
Martin Storsjo 3b6ea6a4e2 Correct data types in the _Unwind_FunctionContext struct
This makes it match the definition used within llvm and in libgcc,
we previously got the wrong layout in 64 bit environments.

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

llvm-svn: 314196
2017-09-26 08:07:17 +00:00
John Baldwin d51d38f6f9 [libunwind] Partially revert r297174 to fix build on at least FreeBSD.
The changes in r297174 moved the #include of <link.h> on FreeBSD (and
probably other systems) inside of the open 'libunwind' namespace
causing various system-provided types such as pid_t to be declared in
this namespace rather than the global namespace.  Fix this by moving
the relevant declarations before the 'libunwind' namespace is opened,
but still using the cleaned up declarations from r297174.

Reviewed By: ed, compnerd

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

llvm-svn: 313920
2017-09-21 21:28:48 +00:00
Martin Storsjo dbf17cf048 Fix a typo in the documentation. NFC.
llvm-svn: 313470
2017-09-16 20:52:05 +00:00
Alex Lorenz 341317fda4 Revert r312240
The buildbots have shown that -Wstrict-prototypes behaves differently in GCC
and Clang so we should keep it disabled until Clang follows GCC's behaviour

llvm-svn: 312246
2017-08-31 15:51:23 +00:00
Alex Lorenz fbac1ae062 Build LLVM with -Wstrict-prototypes enabled
Clang 5 supports -Wstrict-prototypes. We should use it to catch any C
declarations that declare a non-prototype function.

rdar://33705313

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

llvm-svn: 312240
2017-08-31 13:23:24 +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
Petr Hosek 7ec1a56baf [CMake] Allow overriding lib dir suffix independently from LLVM
This matches the options already supported by libc++ and libc++abi.

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

llvm-svn: 310327
2017-08-08 00:37:59 +00:00
Jonathan Roelofs 2cfff07a42 Partial fix for PR33858
https://reviews.llvm.org/D35848

llvm-svn: 309147
2017-07-26 18:13:57 +00:00
Momchil Velikov 81806c5d4d [libunwind] Handle .ARM.exidx tables without sentinel last entry
UnwindCursor<A, R>::getInfoFromEHABISection assumes the last
entry in the index table never corresponds to a real function.
Indeed, GNU ld always inserts an EXIDX_CANTUNWIND entry,
containing the end of the .text section. However, the EHABI specification
(http://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf)
does not seem to contain text that requires the presence of a sentinel entry.
In that sense the libunwind implementation isn't compliant with the specification.

This patch makes getInfoFromEHABISection examine the last entry in the index
table if upper_bound returns the end iterator.

Fixes https://bugs.llvm.org/show_bug.cgi?id=31091

Differential revision: https://reviews.llvm.org/D35265

llvm-svn: 308871
2017-07-24 09:19:32 +00:00
Hans Wennborg 050b2cd1df Bump docs version to 6.0
llvm-svn: 308465
2017-07-19 13:49:39 +00:00
Petr Hosek 4158131512 [CMake] Set library dir to be LLVM's intermediate output dir
This matches the behavior of libc++abi and libc++ and ensures that
we get a working toolchain when building libunwind as part of LLVM.

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

llvm-svn: 308380
2017-07-18 21:30:18 +00:00
Petr Hosek 8bb0f6ec88 [libunwind][CMake] Add install path variable to allow overriding the destination
This is going to be used by the runtime build in the multi-target
setup to allow using different install prefix for each target.

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

llvm-svn: 307606
2017-07-11 01:12:09 +00:00
Jonathan Roelofs 6e50d93afc Add a test harness
Mostly cargo-culted from libcxxabi, since the unwinder was forked from there in
the first place. There may still be cruft that's only applicable to libcxxabi,
but that can be addressed in-tree.

https://reviews.llvm.org/D35038

llvm-svn: 307266
2017-07-06 15:20:12 +00:00
Nico Weber 205519b97e [libunwind] Add _LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS
It's useful to be able to disable visibility annotations entirely; for
example, if we're building libunwind static to include in another library,
and we don't want any libunwind functions getting exported out of that
library.

https://reviews.llvm.org/D34637
Patch from Thomas Anderson <thomasanderson@chromium.org>!

llvm-svn: 306442
2017-06-27 18:37:06 +00:00
Marshall Clow 04ff3b15fa Change -1LL to -1ULL to silence a gcc warning about left shifting a negative value. Fixes https://bugs.llvm.org/show_bug.cgi?id=33358
llvm-svn: 305924
2017-06-21 16:02:53 +00:00
Manoj Gupta 2cbfd2506a [libunwind] Fix executable stack directive on Linux.
Summary:
Disable executable stack on Linux. Also remove redundant Android check
as it is covered by Android.

Reviewers: phosek, compnerd, rs, rmaprath, EricWF, krytarowski

Reviewed By: krytarowski

Subscribers: srhines, llvm-commits, krytarowski

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

llvm-svn: 303206
2017-05-16 20:18:57 +00:00
Petr Hosek 9ad496b2c8 [CMake][libunwind] Fix the -target and -gcc-toolchain flag handling
CMake has the problem with the single dash variant because of the
space, so use the double dash with equal sign version. The compile
flag handling had a typo which caused these flag not to be properly
include. We also don't have to pass the target triple when checking
for compiler-rt since that flag is already included in compile flags
now.

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

llvm-svn: 300419
2017-04-16 06:08:44 +00:00
Petr Hosek 57d49236cc Reland "[CMake][libunwind] Use -nodefaultlibs for CMake checks"
This is a reland of commit r299796.

Turned out that we need gcc_s or compiler-rt on ARM when checking
the support for -funwind-tables which creates a dependency on
__aeabi_unwind_cpp_pr0 symbol that's provided by the compiler
runtime.

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

llvm-svn: 300020
2017-04-12 02:28:07 +00:00
Petr Hosek df82d93562 Revert "[CMake][libunwind] Use -nodefaultlibs for CMake checks"
This reverts commit r299796.

llvm-svn: 299798
2017-04-07 20:24:22 +00:00
Petr Hosek 3dc83e5e31 [CMake][libunwind] Use -nodefaultlibs for CMake checks
Since libunwind is built with -nodefaultlibs, we should be using this
option even for CMake checks to avoid any inconsistency and also to
avoid dependency on a working C++ standard library just for the setting
up the build itself. The implementation is largely similar to the one
used by libc++.

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

llvm-svn: 299796
2017-04-07 20:10:29 +00:00