Path: blob/main/contrib/elftoolchain/libelf/_libelf_config.h
39478 views
/*-1* Copyright (c) 2008-2011 Joseph Koshy2* All rights reserved.3*4* Redistribution and use in source and binary forms, with or without5* modification, are permitted provided that the following conditions6* are met:7* 1. Redistributions of source code must retain the above copyright8* notice, this list of conditions and the following disclaimer.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12*13* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND14* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE15* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE16* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE17* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS19* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)20* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT21* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY22* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF23* SUCH DAMAGE.24*25* $Id: _libelf_config.h 3764 2019-06-28 21:44:46Z emaste $26*/2728#if defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__)2930/*31* Define LIBELF_{ARCH,BYTEORDER,CLASS} based on the machine architecture.32* See also: <machine/elf.h> on FreeBSD.33*/3435#if defined(__amd64__)3637#define LIBELF_ARCH EM_X86_6438#define LIBELF_BYTEORDER ELFDATA2LSB39#define LIBELF_CLASS ELFCLASS644041#elif defined(__aarch64__)4243#define LIBELF_ARCH EM_AARCH6444#define LIBELF_BYTEORDER ELFDATA2LSB45#define LIBELF_CLASS ELFCLASS644647#elif defined(__arm__)4849#define LIBELF_ARCH EM_ARM50#if defined(__ARMEB__) /* Big-endian ARM. */51#define LIBELF_BYTEORDER ELFDATA2MSB52#else53#define LIBELF_BYTEORDER ELFDATA2LSB54#endif55#define LIBELF_CLASS ELFCLASS325657#elif defined(__i386__)5859#define LIBELF_ARCH EM_38660#define LIBELF_BYTEORDER ELFDATA2LSB61#define LIBELF_CLASS ELFCLASS326263#elif defined(__ia64__)6465#define LIBELF_ARCH EM_IA_6466#define LIBELF_BYTEORDER ELFDATA2LSB67#define LIBELF_CLASS ELFCLASS646869#elif defined(__mips__)7071#define LIBELF_ARCH EM_MIPS72#if defined(__MIPSEB__)73#define LIBELF_BYTEORDER ELFDATA2MSB74#else75#define LIBELF_BYTEORDER ELFDATA2LSB76#endif77#define LIBELF_CLASS ELFCLASS327879#elif defined(__powerpc64__)8081#define LIBELF_ARCH EM_PPC6482#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__83#define LIBELF_BYTEORDER ELFDATA2LSB84#else85#define LIBELF_BYTEORDER ELFDATA2MSB86#endif87#define LIBELF_CLASS ELFCLASS648889#elif defined(__powerpc__)9091#define LIBELF_ARCH EM_PPC92#define LIBELF_BYTEORDER ELFDATA2MSB93#define LIBELF_CLASS ELFCLASS329495#elif defined(__riscv) && (__riscv_xlen == 64)9697#define LIBELF_ARCH EM_RISCV98#define LIBELF_BYTEORDER ELFDATA2LSB99#define LIBELF_CLASS ELFCLASS64100101#elif defined(__riscv64)102103#define LIBELF_ARCH EM_RISCV104#define LIBELF_BYTEORDER ELFDATA2LSB105#define LIBELF_CLASS ELFCLASS64106107#elif defined(__loongarch64)108109#define LIBELF_ARCH EM_LOONGARCH110#define LIBELF_BYTEORDER ELFDATA2LSB111#define LIBELF_CLASS ELFCLASS64112113#elif defined(__sparc__)114115#define LIBELF_ARCH EM_SPARCV9116#define LIBELF_BYTEORDER ELFDATA2MSB117#define LIBELF_CLASS ELFCLASS64118119#else120#error Unknown architecture.121#endif122#endif /* defined(__APPLE__) || defined(__DragonFly__) || defined(__FreeBSD__) */123124/*125* Definitions for Minix3.126*/127#ifdef __minix128129#define LIBELF_ARCH EM_386130#define LIBELF_BYTEORDER ELFDATA2LSB131#define LIBELF_CLASS ELFCLASS32132133#endif /* __minix */134135#ifdef __NetBSD__136137#include <machine/elf_machdep.h>138139#if !defined(ARCH_ELFSIZE)140#error ARCH_ELFSIZE is not defined.141#endif142143#if ARCH_ELFSIZE == 32144#define LIBELF_ARCH ELF32_MACHDEP_ID145#define LIBELF_BYTEORDER ELF32_MACHDEP_ENDIANNESS146#define LIBELF_CLASS ELFCLASS32147#define Elf_Note Elf32_Nhdr148#else149#define LIBELF_ARCH ELF64_MACHDEP_ID150#define LIBELF_BYTEORDER ELF64_MACHDEP_ENDIANNESS151#define LIBELF_CLASS ELFCLASS64152#define Elf_Note Elf64_Nhdr153#endif154155#endif /* __NetBSD__ */156157#if defined(__OpenBSD__)158159#include <machine/exec.h>160161#define LIBELF_ARCH ELF_TARG_MACH162#define LIBELF_BYTEORDER ELF_TARG_DATA163#define LIBELF_CLASS ELF_TARG_CLASS164165#endif166167/*168* GNU & Linux compatibility.169*170* `__linux__' is defined in an environment runs the Linux kernel and glibc.171* `__GNU__' is defined in an environment runs a GNU kernel (Hurd) and glibc.172* `__GLIBC__' is defined for an environment that runs glibc over a non-GNU173* kernel such as GNU/kFreeBSD.174*/175176#if defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)177178#if defined(__linux__)179180#include "native-elf-format.h"181182#define LIBELF_CLASS ELFTC_CLASS183#define LIBELF_ARCH ELFTC_ARCH184#define LIBELF_BYTEORDER ELFTC_BYTEORDER185186#endif /* defined(__linux__) */187188#if LIBELF_CLASS == ELFCLASS32189#define Elf_Note Elf32_Nhdr190#elif LIBELF_CLASS == ELFCLASS64191#define Elf_Note Elf64_Nhdr192#else193#error LIBELF_CLASS needs to be one of ELFCLASS32 or ELFCLASS64194#endif195196#endif /* defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) */197198199