summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Edin <henrik.edin@mongodb.com>2017-12-20 14:52:52 -0500
committerHenrik Edin <henrik.edin@mongodb.com>2017-12-29 12:33:02 -0500
commit85fa19c04ca0059b8aa5689028d1e7d799c19483 (patch)
tree22fe2547664110860231fd353e34fe2cde3a17ae
parent5fdcba0afa6307853a0aa6d7f62d9fdb2cc5c3da (diff)
downloadmongo-85fa19c04ca0059b8aa5689028d1e7d799c19483.tar.gz
SERVER-32390 Fix stacktrace_posix when compiling with the Android NDK
-rw-r--r--src/mongo/util/stacktrace_posix.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/mongo/util/stacktrace_posix.cpp b/src/mongo/util/stacktrace_posix.cpp
index 53ab85f56f3..010bb039e95 100644
--- a/src/mongo/util/stacktrace_posix.cpp
+++ b/src/mongo/util/stacktrace_posix.cpp
@@ -358,15 +358,29 @@ void processLoadSegment(const dl_phdr_info& info, const ElfW(Phdr) & phdr, BSONO
return;
}
+#if defined(__ELF_NATIVE_CLASS)
+#define ARCH_BITS __ELF_NATIVE_CLASS
+#else //__ELF_NATIVE_CLASS
+#if defined(__aarch64__)
+#define ARCH_BITS 64
+#elif defined(__arm__)
+#define ARCH_BITS 32
+#else
+#error Unknown target architecture.
+#endif //__aarch64__
+#endif //__ELF_NATIVE_CLASS
+
#define MKELFCLASS(N) _MKELFCLASS(N)
#define _MKELFCLASS(N) ELFCLASS##N
- if (eHeader.e_ident[EI_CLASS] != MKELFCLASS(__ELF_NATIVE_CLASS)) {
+ if (eHeader.e_ident[EI_CLASS] != MKELFCLASS(ARCH_BITS)) {
warning() << "Expected elf file class of " << quotedFileName << " to be "
- << MKELFCLASS(__ELF_NATIVE_CLASS) << "(" << __ELF_NATIVE_CLASS
- << "-bit), but found " << int(eHeader.e_ident[4]);
+ << MKELFCLASS(ARCH_BITS) << "(" << ARCH_BITS << "-bit), but found "
+ << int(eHeader.e_ident[4]);
return;
}
+#undef ARCH_BITS
+
if (eHeader.e_ident[EI_VERSION] != EV_CURRENT) {
warning() << "Wrong ELF version in " << quotedFileName << ". Expected " << EV_CURRENT
<< " but found " << int(eHeader.e_ident[EI_VERSION]);