summaryrefslogtreecommitdiffstats
path: root/libunwind/src/AddressSpace.hpp
Commit message (Collapse)AuthorAgeFilesLines
* [libunwind] Emit dependent libraries only when detected by CMakeMichał Górny2019-12-011-1/+1
| | | | | | | | | | | | | | | | | | | 996e62eef75 added Linux-specific dependent libraries to libunwind sources. As a result, building libunwind with modern LLD on *BSD started failing due to trying to link libdl. Instead, add those libraries only if they were detected by CMake. While technically we could create a long list of systems that need -ldl and -lpthread, maintaining a duplicate list makes little sense when CMake needs to detect it for non-LLD systems anyway. Remove existing system exceptions since they should be covered by the CMake check anyway. Remove -D_LIBUNWIND_HAS_COMMENT_LIB_PRAGMA since it is no longer explicitly needed, if we make the library-specific defines dependent on presence of this pragma support. Differential Revision: https://reviews.llvm.org/D70868
* [libunwind] [Windows] Add a log message if EnumProcessModules failsMartin Storsjö2019-10-311-1/+5
| | | | Differential Revision: https://reviews.llvm.org/D69504
* [libunwind][Android] Fix findUnwindSections for ARM EHABI BionicRyan Prichard2019-10-181-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Fix the arm_section_length count. The meaning of the arm_section_length field changed from num-of-elements to num-of-bytes when the dl_unwind_find_exidx special case was removed (D30306 and D30681). The special case was restored in D39468, but that patch didn't account for the change in arm_section_length's meaning. That patch worked when it was applied to the NDK's fork of libunwind, because it never removed the special case in the first place, and the special case is probably disabled in the Android platform's copy of libunwind, because __ANDROID_API__ is greater than 21. Turn the dl_unwind_find_exidx special case on unconditionally for Bionic. Bionic's dl_unwind_find_exidx is much faster than using dl_iterate_phdr. (e.g. Bionic stores exidx info on an internal soinfo object.) Reviewers: thomasanderson, srhines, danalbert, ed, keith.walker.arm, mclow.lists, compnerd Reviewed By: srhines, danalbert Subscribers: srhines, kristof.beyls, christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D68972 llvm-svn: 375275
* [libunwind][Android] Improve workaround for PIE zero-dlpi_addr bugRyan Prichard2019-10-161-23/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The workaround added in https://reviews.llvm.org/rL299575 appears to be working around a bug in Android JB 4.1.x and 4.2.x (API 16 and 17). Starting in API 16, Android added support for PIE binaries, but the dynamic linker failed to initialize dlpi_addr to the address that the executable was loaded at. The bug was fixed in Android JB 4.3.x (API 18). Improve the true load bias calculation: * The code was assuming that the first segment would be the PT_PHDR segment. I think it's better to be explicit and search for PT_PHDR. (It will be almost as fast in practice.) * It's more correct to use p_vaddr rather than p_offset. If a PIE executable is linked with a non-zero image base (e.g. lld's -Wl,--image-base=xxxx), then we must use p_vaddr here. The "phdr->p_vaddr < image_base" condition seems unnecessary and maybe slightly wrong. If the OS were to load a binary at an address smaller than a vaddr in the binary, we would still want to do this workaround. The workaround is safe when the linker bug isn't present, because it should calculate an image_base equal to dlpi_addr. Note that with API 21 and up, this workaround should never activate for dynamically-linked objects, because non-PIE executables aren't allowed. Consolidate the fix into a single block of code that calculates the true image base, and make it clear that the fix no longer applies after API 18. See https://github.com/android/ndk/issues/505 for details. Reviewers: mclow.lists, srhines, danalbert, compnerd Reviewed By: compnerd Subscribers: srhines, krytarowski, christof, libcxx-commits Tags: #libc Differential Revision: https://reviews.llvm.org/D68971 llvm-svn: 374969
* Unwind: avoid warning about unused typedefSaleem Abdulrasool2019-09-201-3/+3
| | | | | | | | | | | | | | | Move the definition of Elf_Addr typedef to the only place it is used, to avoid: ``` llvm-project/libunwind/src/AddressSpace.hpp:501:28: warning: unused typedef 'Elf_Addr' [-Wunused-local-typedef] ``` when compiling for Android with _LIBUNWIND_ARM_EHABI defined and _LIBUNWIND_SUPPORT_DWARF_UNWIND not defined. Patch by Joel Klinghed! llvm-svn: 372427
* [runtimes] Don't depend on libpthread on AndroidYi Kong2019-07-221-1/+1
| | | | | | | | | | r362048 added support for ELF dependent libraries, but broke Android build since Android does not have libpthread. Remove the dependency on the Android build. Differential Revision: https://reviews.llvm.org/D65098 llvm-svn: 366734
* [runtimes] Check if pragma comment(lib, ...) is supported firstPetr Hosek2019-05-301-1/+1
| | | | | | | | | This fixes the issue introduced by r362048 where we always use pragma comment(lib, ...) for dependent libraries when the compiler is Clang, but older Clang versions don't support this pragma so we need to check first if it's supported before using it. llvm-svn: 362055
* [runtimes] Support ELF dependent libraries featurePetr Hosek2019-05-301-0/+3
| | | | | | | | | | | | | | | | | | | As of r360984, LLD supports dependent libraries feature for ELF. libunwind, libc++abi and libc++ have library dependencies: libdl librt and libpthread, which means that when libunwind and libc++ are being statically linked (using -static-libstdc++ flag), user has to manually specify -ldl -lpthread which is onerous. This change includes the lib pragma to specify the library dependencies directly in the source that uses those libraries. This doesn't make any difference when using linkers that don't support dependent libraries. However, when using LLD that has dependent libraries feature, users no longer have to manually specifying library dependencies when using static linking, linker will pick the library automatically. Differential Revision: https://reviews.llvm.org/D62090 llvm-svn: 362048
* [libunwind] Remove the remote unwinding supportPetr Hosek2019-02-021-132/+0
| | | | | | | | | | 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
* [libunwind] Don't abort if encoutering invalid .eh_frame_hdrPetr Hosek2019-01-241-3/+3
| | | | | | | | | | | | | | | Recent Linux kernel release has introduced a bug as part of the ORC rollout where the vDSO has a valid .eh_frame section, but it's missing the .eh_frame_hdr section and GNU_EH_FRAME segment has zero size. This causes libunwind to abort which breaks programs that use libunwind. The other unwinder implementation (libgcc, non-gnu) instead silently bail out unless being compiled as debug. This change modifies libunwind to use the same strategy. Differential Revision: https://reviews.llvm.org/D57081 llvm-svn: 352016
* Silence warnings about unused parametersMartin Storsjo2019-01-221-0/+7
| | | | | | Differential Revision: https://reviews.llvm.org/D56984 llvm-svn: 351888
* Update more file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | | 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
* [AddressSpace] Use the macro to set hidden visibility on LocalAddressSpace.Charles Davis2018-08-311-1/+1
| | | | | | | | | | | | | | Summary: That attribute has no effect on Windows anyway--classes are hidden by default. Reviewers: mstorsjo, rnk Subscribers: christof, cfe-commits Differential Revision: https://reviews.llvm.org/D51509 llvm-svn: 341210
* Add support for SEH unwinding on Windows.Charles Davis2018-08-301-1/+5
| | | | | | | | | | | | | | | | | | | | | 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
* Introduce a separate preprocessor macro, _LIBUNWIND_USE_DLADDR, for directly ↵Jordan Rupprecht2018-06-291-2/+10
| | | | | | | | | | | | controlling a dependency on dladdr(). This will allow us to use libunwind without adding a libdl dependency. Reviewers: saugustine Subscribers: christof, chrib, cfe-commits, echristo Differential Revision: https://reviews.llvm.org/D48733 llvm-svn: 336014
* [libunwind][MIPS]: Add support for unwinding in N32 processes.John Baldwin2018-02-271-1/+16
| | | | | | | | | | | | | | | | | | | | | | | 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
* Reland [PPC64] Port to ppc64le - initial versionMartin Storsjo2018-01-021-0/+7
| | | | | | | | | | | | | | | | | | | | | 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
* Revert `rL321667: [PPC64] Port to ppc64le - initial version`Tim Shen2018-01-021-7/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D41386 llvm-svn: 321678
* [PPC64] Port to ppc64le - initial versionMartin Storsjo2018-01-021-0/+7
| | | | | | | | | | | | | | | | | | 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
* There is no portable format string for printing `uintptr_t` values.Chandler Carruth2017-12-271-6/+6
| | | | | | | | | Instead, cast them to `void *` which has a portable format string syntax of `%p`. This fixes a -Wformat error when building libunwind. llvm-svn: 321469
* [libunwind] Add proper support for DWARF unwind on bare metal.whitequark2017-12-251-0/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Right now, ARM EHABI unwind on bare metal expects to find the symbols __exidx_start and __exidx_end defined, and uses those to locate the EH tables. However, DWARF unwind on bare metal expects to find dl_iterate_phdr, which, although possible to provide, is inconvenient and mildly absurd. This commit provides feature parity with ARM EHABI unwind by looking for symbols __eh_frame_start, __eh_frame_end, __eh_frame_hdr_start and __eh_frame_hdr_end, denoting the start and end of the sections with corresponding names. As far as I know, there is no de jure or de facto ABI providing any such names, so I chose the obvious ones. The .eh_frame_hdr support is optional for maximum flexibility and possible space savings (e.g. if libunwind is only used to provide backtraces when a device crashes, providing the .eh_frame_hdr, which is an index for rapid access to EH tables, would be a waste.) The support for .eh_frame_hdr/DWARF index in the first place is conditional on defined(_LIBUNWIND_SUPPORT_DWARF_INDEX), although right now config.h will always define this macro. The support for DWARF unwind on bare metal has been validated within the ARTIQ environment[1]. [1]: https://m-labs.hk/artiq/ llvm-svn: 321445
* Remove a FIXME about truncated section namesMartin Storsjo2017-11-161-2/+0
| | | | | | | | | | | | | | | | | 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
* [libunwind] Don't use dl_iterate_phdr if __ANDROID_API__ < 21Dan Albert2017-11-011-0/+8
| | | | | | | | | | | | | | | | 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
* Add support for dwarf unwinding on windows on x86_64Martin Storsjo2017-10-271-8/+3
| | | | | | | | | | | | | | | 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
* Support DWARF unwinding on i386 windowsMartin Storsjo2017-10-111-2/+44
| | | | | | | | | 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
* [libunwind] Partially revert r297174 to fix build on at least FreeBSD.John Baldwin2017-09-211-69/+69
| | | | | | | | | | | | | | | 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
* Change -1LL to -1ULL to silence a gcc warning about left shifting a negative ↵Marshall Clow2017-06-211-3/+3
| | | | | | value. Fixes https://bugs.llvm.org/show_bug.cgi?id=33358 llvm-svn: 305924
* Fix unused typedef. Follow up to r299575.Ivan Krasin2017-04-061-1/+1
| | | | llvm-svn: 299666
* AddressSpace: fix DWARF based unwinding handling on AndroidSaleem Abdulrasool2017-04-051-2/+5
| | | | | | | It is possible that there are no program headers in the module. Do not attempt to dereference nullptr as a program header. llvm-svn: 299591
* Fix invalid memory access on android x86Saleem Abdulrasool2017-04-051-0/+17
| | | | | | | | | | On certain versions of android x86, the main module `app_process` is not built as PIE. When accessing the PT_GNU_EH_FRAME_HDR in such a scenario, the `dlpi_addr` is 0, but the virtual address is not relocated. Manually rebase the address to avoid an invalid memory access. llvm-svn: 299575
* [libunwind] Clean up macro usage.Ranjeet Singh2017-03-311-14/+14
| | | | | | | | Convention in libunwind is to use !defined(FOOT) not !FOO. Differential Revision: https://reviews.llvm.org/D31078 llvm-svn: 299225
* Tidy up the way we include EHHeaderParser.hpp.Ed Schouten2017-03-071-4/+1
| | | | | | | Other source files in the source tree tend to include this header file unconditionally. It also parses perfectly fine on ARM EHABI systems. llvm-svn: 297175
* Improve readability and correctness of the OS specific libunwind bits.Ed Schouten2017-03-071-26/+25
| | | | | | | | | | | | | | | | | | | | | | | All of the access to __exidx_*, dl_iterate_phdr(), etc. is specific to the findUnwindSections() function. Right now all of the includes and declarations related to them are scattered throughout the source file. For example, for <link.h>, we have a full list of operating systems guarding the #include, even though the code that uses dl_iterate_phdr() miraculously doesn't use the same list. Change the code so that findUnwindSections() is preceded by a block of #ifdefs that share the same structure as the function itself. First comes all of the macOS specific bits, followed by bare-metal ARM, followed by ELF EHABI + DWARF. This actually allows us to build a copy of libunwind without any specific ifdefs for NetBSD, CloudABI, etc. It likely also unbreaks the build of libunwind on FreeBSD/armv6, though I can't confirm. Reviewed by: compnerd Differential Revision: https://reviews.llvm.org/D30696 llvm-svn: 297174
* Let arm_section_length store the number of bytes.Ed Schouten2017-03-071-8/+3
| | | | | | | | | | | | | | | | Exception section data that we extract for DWARF gets stored as the offset and the number of bytes. For ARM exception info, we seem to deviate from this by storing the number of entries. Attempt to make this more consistent. By storing the number of bytes, we can get rid of the EHTEntry structure declared in AddressSpace.hpp. In UnwindCursor.hpp we already have another structure declared for the same purpose. Reviewed by: Keith Walker Differential Revision: https://reviews.llvm.org/D30681 llvm-svn: 297149
* Drop the dependency on dl_unwind_find_exidx().Ed Schouten2017-03-051-31/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While porting libunwind over to CloudABI for ARMv6, I observed that this source file doesn't build, as it depends on dl_unwind_find_exidx(), which CloudABI's C library was lacking. After I added that function, I still needed to patch up libunwind to define _Unwind_Ptr. Taking a step back, I wonder why we need to make use of this function anyway. The unwinder already has some nice code to use dl_iterate_phdr() to scan for a PT_GNU_EH_FRAME header. The dl_unwind_find_exidx() does the same thing, except matching PT_ARM_EXIDX instead. We could also do that ourselves. This change gets rid of the dl_unwind_find_exidx() call and extends the dl_iterate_phdr() loop. This approach has the advantage of getting rid of some of those OS-specific #ifdefs. This now means that if an operating system only provides dl_iterate_phdr(), it gets support for unwinding on all architectures. There is no need to add more stuff, just to get ARMv6 support. This change is identical to r295944, except that it now adds the necessary code to do bounds checking on PT_LOAD. The previous version of this change lacked this, which didn't cause any problems on CloudABI, but did break the Linux build bots. This is why I reverted it in r295948. Differential Revision: https://reviews.llvm.org/D30306 llvm-svn: 296991
* Revert r295944.Ed Schouten2017-02-231-28/+33
| | | | | | | | | | | | Even though the change works perfectly fine on CloudABI, it fails to work on the libcxx-libcxxabi-libunwind-arm-linux-noexceptions build bot. Looking at the code, this may be attributed to the fact that the code doesn't take the PT_LOAD addresses into consideration. I will rework this change to fix that and send out an updated version for review in the nearby future. llvm-svn: 295948
* Drop the dependency on dl_unwind_find_exidx().Ed Schouten2017-02-231-33/+28
| | | | | | | | | | | | | | | | | | | | | | | | | While porting libunwind over to CloudABI for ARMv6, I observed that this source file doesn't build, as it depends on dl_unwind_find_exidx(), which CloudABI's C library was lacking. After I added that function, I still needed to patch up libunwind to define _Unwind_Ptr. Taking a step back, I wonder why we need to make use of this function anyway. The unwinder already has some nice code to use dl_iterate_phdr() to scan for a PT_GNU_EH_FRAME header. The dl_unwind_find_exidx() does the same thing, except matching PT_ARM_EXIDX instead. We could also do that ourselves. This change gets rid of the dl_unwind_find_exidx() call and extends the dl_iterate_phdr() loop. In addition to making the code a bit shorter, it has the advantage of getting rid of some of those OS-specific #ifdefs. This now means that if an operating system only provides dl_iterate_phdr(), it gets support for unwinding on all architectures. There is no need to add more stuff, just to get ARMv6 support. Differential Revision: https://reviews.llvm.org/D28082 llvm-svn: 295944
* rename OtherAddressSpace to RemoteAddressSpace; NFCSaleem Abdulrasool2017-01-211-16/+17
| | | | llvm-svn: 292719
* fix _dyld_find_unwind_sections() for pre-10.7. Patch by Jeremy SequoiaNick Kledzik2016-10-311-16/+22
| | | | llvm-svn: 285636
* [libunwind] Add support for FuchsiaPetr Hosek2016-10-231-2/+2
| | | | | | | | Fuchsia is a new operating system which uses libunwind as unwinder. Differential Revision: https://reviews.llvm.org/D25899 llvm-svn: 284951
* libunwind: Add OpenBSD case for _Unwind_Ptr typedefEd Maste2016-09-281-1/+1
| | | | | | Patch by Mark Kettenis llvm-svn: 282599
* consistently add \n to log and trace messagesEd Maste2016-08-301-1/+1
| | | | | | | | | | Previously most messages included a newline in the string, but a few of them were missing. Fix these and simplify by just adding the newline in the _LIBUNWIND_LOG macro itself. Differential Revision: https://reviews.llvm.org/D24026 llvm-svn: 280103
* libunwind: Use conventional DWARF capitalization in comments and errorsEd Maste2016-07-191-1/+1
| | | | llvm-svn: 275996
* Introduce NetBSD supportKamil Rytarowski2016-02-061-2/+3
| | | | | | Current FreeBSD and NetBSD code is compatible. llvm-svn: 260001
* Add FreeBSD _Unwind_Ptr typedefEd Maste2015-10-161-1/+5
| | | | | | Differential Revision: http://reviews.llvm.org/D13820 llvm-svn: 250541
* libunwind: Introduce __libunwind_config.h.Logan Chien2015-07-191-4/+4
| | | | | | | Introduce __libunwind_config.h to avoid cross repository circular dependency with libcxxabi. llvm-svn: 242642
* Fix libunwind to build on FreeBSDViktor Kutuzov2015-05-061-2/+9
| | | | | | Differential Revision: http://reviews.llvm.org/D9272 llvm-svn: 236585
* Make the .eh_frame_hdr code work on FreeBSD as well.Ed Schouten2015-04-291-1/+8
| | | | | | | | | | | | | | | 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
* unwind: move src/Unwind, include/, and test/ unwind contentSaleem Abdulrasool2015-04-241-0/+579
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
OpenPOWER on IntegriCloud