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 <vapier@chromium.org>
This commit is contained in:
parent
2633712387
commit
23e6fbf571
3 changed files with 11 additions and 20 deletions
|
@ -109,17 +109,6 @@ typedef struct {
|
||||||
} Elf64_Dyn;
|
} Elf64_Dyn;
|
||||||
|
|
||||||
|
|
||||||
// __WORDSIZE is GLibc-specific and used by Google Breakpad on Linux.
|
|
||||||
#ifndef __WORDSIZE
|
|
||||||
#if defined(__i386__) || defined(__ARM_EABI__) || defined(__mips__)
|
|
||||||
#define __WORDSIZE 32
|
|
||||||
#elif defined(__x86_64__) || defined(__aarch64__)
|
|
||||||
#define __WORDSIZE 64
|
|
||||||
#else
|
|
||||||
#error "Unsupported Android CPU ABI"
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// The Android headers don't always define this constant.
|
// The Android headers don't always define this constant.
|
||||||
#ifndef EM_X86_64
|
#ifndef EM_X86_64
|
||||||
#define EM_X86_64 62
|
#define EM_X86_64 62
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
// Although most of this code can deal with arbitrary ELF files of
|
// Although most of this code can deal with arbitrary ELF files of
|
||||||
// either word size, the public ElfReader interface only examines
|
// either word size, the public ElfReader interface only examines
|
||||||
// files loaded into the current address space, which must all match
|
// files loaded into the current address space, which must all match
|
||||||
// __WORDSIZE. This code cannot handle ELF files with a non-native
|
// the machine's native word size. This code cannot handle ELF files
|
||||||
// byte ordering.
|
// with a non-native byte ordering.
|
||||||
//
|
//
|
||||||
// TODO(chatham): It would be nice if we could accomplish this task
|
// 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.
|
// without using malloc(), so we could use it as the process is dying.
|
||||||
|
@ -30,12 +30,13 @@
|
||||||
#define _GNU_SOURCE // needed for pread()
|
#define _GNU_SOURCE // needed for pread()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/mman.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/mman.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -1053,9 +1054,9 @@ ElfReader::~ElfReader() {
|
||||||
|
|
||||||
|
|
||||||
// The only word-size specific part of this file is IsNativeElfFile().
|
// The only word-size specific part of this file is IsNativeElfFile().
|
||||||
#if __WORDSIZE == 32
|
#if ULONG_MAX == 0xffffffff
|
||||||
#define NATIVE_ELF_ARCH Elf32
|
#define NATIVE_ELF_ARCH Elf32
|
||||||
#elif __WORDSIZE == 64
|
#elif ULONG_MAX == 0xffffffffffffffff
|
||||||
#define NATIVE_ELF_ARCH Elf64
|
#define NATIVE_ELF_ARCH Elf64
|
||||||
#else
|
#else
|
||||||
#error "Invalid word size"
|
#error "Invalid word size"
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
|
|
||||||
#include <elf.h>
|
#include <elf.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
#include <link.h>
|
#include <link.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -54,7 +55,7 @@
|
||||||
#include "third_party/lss/linux_syscall_support.h"
|
#include "third_party/lss/linux_syscall_support.h"
|
||||||
#include "tools/linux/md2core/minidump_memory_range.h"
|
#include "tools/linux/md2core/minidump_memory_range.h"
|
||||||
|
|
||||||
#if __WORDSIZE == 64
|
#if ULONG_MAX == 0xffffffffffffffff
|
||||||
#define ELF_CLASS ELFCLASS64
|
#define ELF_CLASS ELFCLASS64
|
||||||
#else
|
#else
|
||||||
#define ELF_CLASS ELFCLASS32
|
#define ELF_CLASS ELFCLASS32
|
||||||
|
|
Loading…
Reference in a new issue