Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schouten <ed@nuxi.nl>2017-03-07 21:15:52 +0300
committerEd Schouten <ed@nuxi.nl>2017-03-07 21:15:52 +0300
commit3e29e7415e89c197a3d86544f0c33252d1e23639 (patch)
tree499e04930b50f7e59b043f8abb68377fcf0d80b2 /libunwind
parenta404d1436e5bd65a0e4ce20d6b09591b6f012f71 (diff)
Improve readability and correctness of the OS specific libunwind bits.
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
Diffstat (limited to 'libunwind')
-rw-r--r--libunwind/src/AddressSpace.hpp51
1 files changed, 25 insertions, 26 deletions
diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp
index b15eb5c60be5..23eb9334833b 100644
--- a/libunwind/src/AddressSpace.hpp
+++ b/libunwind/src/AddressSpace.hpp
@@ -34,32 +34,6 @@ namespace libunwind {
#include "dwarf2.h"
#include "Registers.hpp"
-#if _LIBUNWIND_ARM_EHABI
-#if defined(_LIBUNWIND_IS_BAREMETAL)
-// When statically linked on bare-metal, the symbols for the EH table are looked
-// up without going through the dynamic loader.
-extern char __exidx_start;
-extern char __exidx_end;
-#else
-#include <link.h>
-#endif // !defined(_LIBUNWIND_IS_BAREMETAL)
-#endif // _LIBUNWIND_ARM_EHABI
-
-#if defined(__CloudABI__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
- defined(__linux__) || defined(__NetBSD__)
-#if _LIBUNWIND_SUPPORT_DWARF_UNWIND && _LIBUNWIND_SUPPORT_DWARF_INDEX
-#include <link.h>
-// Macro for machine-independent access to the ELF program headers. This
-// macro is not available on some systems (e.g., FreeBSD). On these
-// systems the data structures are just called Elf_XXX. Define ElfW()
-// locally.
-#if !defined(ElfW)
-#define ElfW(type) Elf_##type
-#endif
-#include "EHHeaderParser.hpp"
-#endif
-#endif
-
namespace libunwind {
/// Used by findUnwindSections() to return info about needed sections.
@@ -291,6 +265,7 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding,
}
#ifdef __APPLE__
+
struct dyld_unwind_sections
{
const struct mach_header* mh;
@@ -336,6 +311,30 @@ LocalAddressSpace::getEncodedP(pint_t &addr, pint_t end, uint8_t encoding,
return true;
}
#endif
+
+#elif _LIBUNWIND_ARM_EHABI && defined(_LIBUNWIND_IS_BAREMETAL)
+
+// When statically linked on bare-metal, the symbols for the EH table are looked
+// up without going through the dynamic loader.
+extern char __exidx_start;
+extern char __exidx_end;
+
+#elif _LIBUNWIND_ARM_EHABI || _LIBUNWIND_SUPPORT_DWARF_UNWIND
+
+// ELF-based systems may use dl_iterate_phdr() to access sections
+// containing unwinding information. The ElfW() macro for pointer-size
+// independent ELF header traversal is not provided by <link.h> on some
+// systems (e.g., FreeBSD). On these systems the data structures are
+// just called Elf_XXX. Define ElfW() locally.
+#include <link.h>
+#if !defined(ElfW)
+#define ElfW(type) Elf_##type
+#endif
+
+#if _LIBUNWIND_SUPPORT_DWARF_UNWIND
+#include "EHHeaderParser.hpp"
+#endif
+
#endif
inline bool LocalAddressSpace::findUnwindSections(pint_t targetAddr,