138357Sjdp/*- 238357Sjdp * Copyright (c) 1998 John D. Polstra. 338357Sjdp * All rights reserved. 438357Sjdp * 538357Sjdp * Redistribution and use in source and binary forms, with or without 638357Sjdp * modification, are permitted provided that the following conditions 738357Sjdp * are met: 838357Sjdp * 1. Redistributions of source code must retain the above copyright 938357Sjdp * notice, this list of conditions and the following disclaimer. 1038357Sjdp * 2. Redistributions in binary form must reproduce the above copyright 1138357Sjdp * notice, this list of conditions and the following disclaimer in the 1238357Sjdp * documentation and/or other materials provided with the distribution. 1338357Sjdp * 1438357Sjdp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1538357Sjdp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1638357Sjdp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1738357Sjdp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1838357Sjdp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1938357Sjdp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2038357Sjdp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2138357Sjdp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2238357Sjdp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2338357Sjdp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2438357Sjdp * SUCH DAMAGE. 2538357Sjdp * 2650477Speter * $FreeBSD$ 2738357Sjdp */ 2838357Sjdp 2938357Sjdp#ifndef _SYS_ELF_GENERIC_H_ 30186667Sobrien#define _SYS_ELF_GENERIC_H_ 1 3138357Sjdp 3238357Sjdp#include <sys/cdefs.h> 3338357Sjdp 3438357Sjdp/* 3538357Sjdp * Definitions of generic ELF names which relieve applications from 3638357Sjdp * needing to know the word size. 3738357Sjdp */ 3838357Sjdp 3938357Sjdp#if __ELF_WORD_SIZE != 32 && __ELF_WORD_SIZE != 64 4038357Sjdp#error "__ELF_WORD_SIZE must be defined as 32 or 64" 4138357Sjdp#endif 4238357Sjdp 43186667Sobrien#define ELF_CLASS __CONCAT(ELFCLASS,__ELF_WORD_SIZE) 4439189Sjdp 4539189Sjdp#if BYTE_ORDER == LITTLE_ENDIAN 46186667Sobrien#define ELF_DATA ELFDATA2LSB 4739189Sjdp#elif BYTE_ORDER == BIG_ENDIAN 48186667Sobrien#define ELF_DATA ELFDATA2MSB 4939189Sjdp#else 5039189Sjdp#error "Unknown byte order" 5139189Sjdp#endif 5239189Sjdp 53186667Sobrien#define __elfN(x) __CONCAT(__CONCAT(__CONCAT(elf,__ELF_WORD_SIZE),_),x) 54186667Sobrien#define __ElfN(x) __CONCAT(__CONCAT(__CONCAT(Elf,__ELF_WORD_SIZE),_),x) 55186667Sobrien#define __ELFN(x) __CONCAT(__CONCAT(__CONCAT(ELF,__ELF_WORD_SIZE),_),x) 56186667Sobrien#define __ElfType(x) typedef __ElfN(x) __CONCAT(Elf_,x) 5738357Sjdp 5838357Sjdp__ElfType(Addr); 5938357Sjdp__ElfType(Half); 6038357Sjdp__ElfType(Off); 6138357Sjdp__ElfType(Sword); 6238357Sjdp__ElfType(Word); 6338357Sjdp__ElfType(Ehdr); 6438357Sjdp__ElfType(Shdr); 6538357Sjdp__ElfType(Phdr); 6638357Sjdp__ElfType(Dyn); 6738357Sjdp__ElfType(Rel); 6838357Sjdp__ElfType(Rela); 6938357Sjdp__ElfType(Sym); 70153515Skan__ElfType(Verdef); 71153515Skan__ElfType(Verdaux); 72153515Skan__ElfType(Verneed); 73153515Skan__ElfType(Vernaux); 74153515Skan__ElfType(Versym); 7538357Sjdp 76153504Smarcel/* Non-standard ELF types. */ 77153504Smarcel__ElfType(Hashelt); 78153504Smarcel__ElfType(Size); 79153504Smarcel__ElfType(Ssize); 80153504Smarcel 81186667Sobrien#define ELF_R_SYM __ELFN(R_SYM) 82186667Sobrien#define ELF_R_TYPE __ELFN(R_TYPE) 83186667Sobrien#define ELF_R_INFO __ELFN(R_INFO) 84186667Sobrien#define ELF_ST_BIND __ELFN(ST_BIND) 85186667Sobrien#define ELF_ST_TYPE __ELFN(ST_TYPE) 86186667Sobrien#define ELF_ST_INFO __ELFN(ST_INFO) 8738357Sjdp 8838357Sjdp#endif /* !_SYS_ELF_GENERIC_H_ */ 89