From 23e6fbf571a6638ce9642fc1f50baf1af0f54268 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Mon, 16 Mar 2020 23:08:02 -0700 Subject: Use ULONG_MAX instead of __WORDSIZE to determine native ELF architecture __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. This allows us to remove the fallback definition of __WORDSIZE in the Android compatibility headers. Bug: google-breakpad:631 Change-Id: I7b9e6f3b2121f78ccad9e32bf26acac518aefd8f Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/2107100 Reviewed-by: Mike Frysinger --- src/common/dwarf/elf_reader.cc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/common/dwarf') diff --git a/src/common/dwarf/elf_reader.cc b/src/common/dwarf/elf_reader.cc index 4135a51a..7dc46fd2 100644 --- a/src/common/dwarf/elf_reader.cc +++ b/src/common/dwarf/elf_reader.cc @@ -20,8 +20,8 @@ // Although most of this code can deal with arbitrary ELF files of // either word size, the public ElfReader interface only examines // files loaded into the current address space, which must all match -// __WORDSIZE. This code cannot handle ELF files with a non-native -// byte ordering. +// the machine's native word size. This code cannot handle ELF files +// with a non-native byte ordering. // // TODO(chatham): It would be nice if we could accomplish this task // without using malloc(), so we could use it as the process is dying. @@ -30,12 +30,13 @@ #define _GNU_SOURCE // needed for pread() #endif -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include #include #include @@ -1053,9 +1054,9 @@ ElfReader::~ElfReader() { // The only word-size specific part of this file is IsNativeElfFile(). -#if __WORDSIZE == 32 +#if ULONG_MAX == 0xffffffff #define NATIVE_ELF_ARCH Elf32 -#elif __WORDSIZE == 64 +#elif ULONG_MAX == 0xffffffffffffffff #define NATIVE_ELF_ARCH Elf64 #else #error "Invalid word size" -- cgit v1.2.1