From a0f647d7f34f22e2c6d79ac74769c758bf5b20fe Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Tue, 10 Mar 2020 16:24:38 -0700 Subject: 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 --- src/common/linux/elf_core_dump.h | 9 +++++---- 1 file 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 +#include #include #include @@ -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 -- cgit v1.2.1