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