diff options
author | Jordan Rupprecht <rupprecht@google.com> | 2018-06-29 20:41:50 +0000 |
---|---|---|
committer | Jordan Rupprecht <rupprecht@google.com> | 2018-06-29 20:41:50 +0000 |
commit | c3b91e16890db2f95bbe757ff40464d486203fef (patch) | |
tree | 257f74730e5e2d574bc9209a410aff127d599f2a /libunwind | |
parent | fde14ead389e2118314f3fb09987c0ce93dc70c9 (diff) |
Introduce a separate preprocessor macro, _LIBUNWIND_USE_DLADDR, for directly 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
Diffstat (limited to 'libunwind')
-rw-r--r-- | libunwind/src/AddressSpace.hpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libunwind/src/AddressSpace.hpp b/libunwind/src/AddressSpace.hpp index 32ff1f3d104..e3a7e40befe 100644 --- a/libunwind/src/AddressSpace.hpp +++ b/libunwind/src/AddressSpace.hpp @@ -18,7 +18,15 @@ #include <stdlib.h> #include <string.h> -#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32) +#ifndef _LIBUNWIND_USE_DLADDR + #if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32) + #define _LIBUNWIND_USE_DLADDR 1 + #else + #define _LIBUNWIND_USE_DLADDR 0 + #endif +#endif + +#if _LIBUNWIND_USE_DLADDR #include <dlfcn.h> #endif @@ -576,7 +584,7 @@ inline bool LocalAddressSpace::findOtherFDE(pint_t targetAddr, pint_t &fde) { inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf, size_t bufLen, unw_word_t *offset) { -#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32) +#if _LIBUNWIND_USE_DLADDR Dl_info dyldInfo; if (dladdr((void *)addr, &dyldInfo)) { if (dyldInfo.dli_sname != NULL) { |