aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Forney <mforney@mforney.org>2020-03-10 16:24:38 -0700
committerMike Frysinger <vapier@chromium.org>2020-03-10 23:31:09 +0000
commita0f647d7f34f22e2c6d79ac74769c758bf5b20fe (patch)
treefe8465cd615bb3f6a72dbb4ea079fe77c130983b
parentUse standard header locations for poll.h and signal.h (diff)
downloadbreakpad-a0f647d7f34f22e2c6d79ac74769c758bf5b20fe.tar.xz
Use ULONG_MAX instead of __WORDSIZE to determine ELF class
__WORDSIZE is an internal libc definition. Instead, we can use ULONG_MAX from limits.h, whose value corresponds to the machine's native word size. Bug: google-breakpad:631 Change-Id: If69caf578286d678585d1510c01562b969b5061f Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2097352 Reviewed-by: Mike Frysinger <vapier@chromium.org>
-rw-r--r--src/common/linux/elf_core_dump.h9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/common/linux/elf_core_dump.h b/src/common/linux/elf_core_dump.h
index d03c7a88..6e153745 100644
--- a/src/common/linux/elf_core_dump.h
+++ b/src/common/linux/elf_core_dump.h
@@ -34,6 +34,7 @@
#define COMMON_LINUX_ELF_CORE_DUMP_H_
#include <elf.h>
+#include <limits.h>
#include <link.h>
#include <stddef.h>
@@ -45,18 +46,18 @@ namespace google_breakpad {
// provides methods for accessing program headers and the note section.
class ElfCoreDump {
public:
- // ELF types based on the value of __WORDSIZE.
+ // ELF types based on the native word size.
typedef ElfW(Ehdr) Ehdr;
typedef ElfW(Nhdr) Nhdr;
typedef ElfW(Phdr) Phdr;
typedef ElfW(Word) Word;
typedef ElfW(Addr) Addr;
-#if __WORDSIZE == 32
+#if ULONG_MAX == 0xffffffff
static const int kClass = ELFCLASS32;
-#elif __WORDSIZE == 64
+#elif ULONG_MAX == 0xffffffffffffffff
static const int kClass = ELFCLASS64;
#else
-#error "Unsupported __WORDSIZE for ElfCoreDump."
+#error "Unsupported word size for ElfCoreDump."
#endif
// A class encapsulating the note content in a core dump, which provides