1*433d6423SLionel Sambuc /*- 2*433d6423SLionel Sambuc * Copyright (c) 1998 John D. Polstra. 3*433d6423SLionel Sambuc * All rights reserved. 4*433d6423SLionel Sambuc * 5*433d6423SLionel Sambuc * Redistribution and use in source and binary forms, with or without 6*433d6423SLionel Sambuc * modification, are permitted provided that the following conditions 7*433d6423SLionel Sambuc * are met: 8*433d6423SLionel Sambuc * 1. Redistributions of source code must retain the above copyright 9*433d6423SLionel Sambuc * notice, this list of conditions and the following disclaimer. 10*433d6423SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 11*433d6423SLionel Sambuc * notice, this list of conditions and the following disclaimer in the 12*433d6423SLionel Sambuc * documentation and/or other materials provided with the distribution. 13*433d6423SLionel Sambuc * 14*433d6423SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15*433d6423SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16*433d6423SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*433d6423SLionel Sambuc * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18*433d6423SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*433d6423SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20*433d6423SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21*433d6423SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22*433d6423SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23*433d6423SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24*433d6423SLionel Sambuc * SUCH DAMAGE. 25*433d6423SLionel Sambuc * 26*433d6423SLionel Sambuc * $FreeBSD$ 27*433d6423SLionel Sambuc */ 28*433d6423SLionel Sambuc 29*433d6423SLionel Sambuc #ifndef _SYS_ELF_GENERIC_H_ 30*433d6423SLionel Sambuc #define _SYS_ELF_GENERIC_H_ 1 31*433d6423SLionel Sambuc 32*433d6423SLionel Sambuc #include <sys/cdefs.h> 33*433d6423SLionel Sambuc 34*433d6423SLionel Sambuc /* 35*433d6423SLionel Sambuc * Definitions of generic ELF names which relieve applications from 36*433d6423SLionel Sambuc * needing to know the word size. 37*433d6423SLionel Sambuc */ 38*433d6423SLionel Sambuc 39*433d6423SLionel Sambuc #if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64 40*433d6423SLionel Sambuc #error "__ELF_WORD_SIZE must be defined as 32 or 64" 41*433d6423SLionel Sambuc #endif 42*433d6423SLionel Sambuc 43*433d6423SLionel Sambuc #define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) 44*433d6423SLionel Sambuc 45*433d6423SLionel Sambuc #if BYTE_ORDER == LITTLE_ENDIAN 46*433d6423SLionel Sambuc #define ELF_DATA ELFDATA2LSB 47*433d6423SLionel Sambuc #elif BYTE_ORDER == BIG_ENDIAN 48*433d6423SLionel Sambuc #define ELF_DATA ELFDATA2MSB 49*433d6423SLionel Sambuc #else 50*433d6423SLionel Sambuc #error "Unknown byte order" 51*433d6423SLionel Sambuc #endif 52*433d6423SLionel Sambuc 53*433d6423SLionel Sambuc #define CONCAT(x,y) __CONCAT(x,y) 54*433d6423SLionel Sambuc #define __elfN(x) CONCAT(CONCAT(CONCAT(elf,__ELF_WORD_SIZE),_),x) 55*433d6423SLionel Sambuc #define __ElfN(x) CONCAT(CONCAT(CONCAT(Elf,__ELF_WORD_SIZE),_),x) 56*433d6423SLionel Sambuc #define __ELFN(x) CONCAT(CONCAT(CONCAT(ELF,__ELF_WORD_SIZE),_),x) 57*433d6423SLionel Sambuc #define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) 58*433d6423SLionel Sambuc 59*433d6423SLionel Sambuc __ElfType(Addr); 60*433d6423SLionel Sambuc __ElfType(Half); 61*433d6423SLionel Sambuc __ElfType(Off); 62*433d6423SLionel Sambuc __ElfType(Sword); 63*433d6423SLionel Sambuc __ElfType(Word); 64*433d6423SLionel Sambuc __ElfType(Ehdr); 65*433d6423SLionel Sambuc __ElfType(Shdr); 66*433d6423SLionel Sambuc __ElfType(Nhdr); 67*433d6423SLionel Sambuc __ElfType(Phdr); 68*433d6423SLionel Sambuc __ElfType(Dyn); 69*433d6423SLionel Sambuc __ElfType(Rel); 70*433d6423SLionel Sambuc __ElfType(Rela); 71*433d6423SLionel Sambuc __ElfType(Sym); 72*433d6423SLionel Sambuc __ElfType(Verdef); 73*433d6423SLionel Sambuc __ElfType(Verdaux); 74*433d6423SLionel Sambuc __ElfType(Verneed); 75*433d6423SLionel Sambuc __ElfType(Vernaux); 76*433d6423SLionel Sambuc __ElfType(Versym); 77*433d6423SLionel Sambuc 78*433d6423SLionel Sambuc /* Non-standard ELF types. */ 79*433d6423SLionel Sambuc __ElfType(Hashelt); 80*433d6423SLionel Sambuc __ElfType(Size); 81*433d6423SLionel Sambuc __ElfType(Ssize); 82*433d6423SLionel Sambuc 83*433d6423SLionel Sambuc #define ELF_R_SYM __ELFN(R_SYM) 84*433d6423SLionel Sambuc #define ELF_R_TYPE __ELFN(R_TYPE) 85*433d6423SLionel Sambuc #define ELF_R_INFO __ELFN(R_INFO) 86*433d6423SLionel Sambuc #define ELF_ST_BIND __ELFN(ST_BIND) 87*433d6423SLionel Sambuc #define ELF_ST_TYPE __ELFN(ST_TYPE) 88*433d6423SLionel Sambuc #define ELF_ST_INFO __ELFN(ST_INFO) 89*433d6423SLionel Sambuc 90*433d6423SLionel Sambuc #endif /* !_SYS_ELF_GENERIC_H_ */ 91