elf.h revision 84783
1193323Sed/*- 2193323Sed * Copyright (c) 1996-1997 John D. Polstra. 3193323Sed * All rights reserved. 4193323Sed * 5193323Sed * Redistribution and use in source and binary forms, with or without 6193323Sed * modification, are permitted provided that the following conditions 7193323Sed * are met: 8193323Sed * 1. Redistributions of source code must retain the above copyright 9193323Sed * notice, this list of conditions and the following disclaimer. 10193323Sed * 2. Redistributions in binary form must reproduce the above copyright 11193323Sed * notice, this list of conditions and the following disclaimer in the 12193323Sed * documentation and/or other materials provided with the distribution. 13193323Sed * 14193323Sed * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15193323Sed * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16193323Sed * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17193323Sed * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18193323Sed * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19193323Sed * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20193323Sed * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21224145Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22224145Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23224145Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24193323Sed * SUCH DAMAGE. 25193323Sed * 26193323Sed * $FreeBSD: head/sys/i386/include/elf.h 84783 2001-10-10 23:06:54Z ps $ 27193323Sed */ 28193323Sed 29193323Sed#ifndef _MACHINE_ELF_H_ 30193323Sed#define _MACHINE_ELF_H_ 1 31193323Sed 32193323Sed/* 33193323Sed * ELF definitions for the i386 architecture. 34193323Sed */ 35193323Sed 36193323Sed#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */ 37193323Sed 38218893Sdim#define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */ 39193323Sed#include <sys/elf_generic.h> 40193323Sed 41193323Sed#define ELF_ARCH EM_386 42193323Sed 43193323Sed#define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486) 44193323Sed 45193323Sed/* 46218893Sdim * Auxiliary vector entries for passing information to the interpreter. 47193323Sed * 48193323Sed * The i386 supplement to the SVR4 ABI specification names this "auxv_t", 49193323Sed * but POSIX lays claim to all symbols ending with "_t". 50193323Sed */ 51193323Sed 52193323Sedtypedef struct { /* Auxiliary vector entry on initial stack */ 53193323Sed int a_type; /* Entry type. */ 54193323Sed union { 55193323Sed long a_val; /* Integer value. */ 56193323Sed void *a_ptr; /* Address. */ 57193323Sed void (*a_fcn)(void); /* Function pointer (not used). */ 58193323Sed } a_un; 59193323Sed} Elf32_Auxinfo; 60193323Sed 61193323Sed__ElfType(Auxinfo); 62193323Sed 63193323Sed/* 64218893Sdim * Types of dynamic symbol hash table bucket and chain elements. 65218893Sdim * 66218893Sdim * This is inconsistent among 64 bit architectures, so a machine dependent 67224145Sdim * typedef is required. 68193323Sed */ 69193323Sed 70193323Sedtypedef Elf32_Off Elf32_Hashelt; 71193323Sed 72193323Sed__ElfType(Hashelt); 73193323Sed 74193323Sed/* Values for a_type. */ 75218893Sdim#define AT_NULL 0 /* Terminates the vector. */ 76193323Sed#define AT_IGNORE 1 /* Ignored entry. */ 77193323Sed#define AT_EXECFD 2 /* File descriptor of program to load. */ 78193323Sed#define AT_PHDR 3 /* Program header of program already loaded. */ 79193323Sed#define AT_PHENT 4 /* Size of each program header entry. */ 80193323Sed#define AT_PHNUM 5 /* Number of program header entries. */ 81193323Sed#define AT_PAGESZ 6 /* Page size in bytes. */ 82193323Sed#define AT_BASE 7 /* Interpreter's base address. */ 83193323Sed#define AT_FLAGS 8 /* Flags (unused for i386). */ 84193323Sed#define AT_ENTRY 9 /* Where interpreter should transfer control. */ 85193323Sed 86193323Sed/* 87193323Sed * The following non-standard values are used for passing information 88218893Sdim * from John Polstra's testbed program to the dynamic linker. These 89218893Sdim * are expected to go away soon. 90218893Sdim * 91218893Sdim * Unfortunately, these overlap the Linux non-standard values, so they 92193323Sed * must not be used in the same context. 93193323Sed */ 94193323Sed#define AT_BRK 10 /* Starting point for sbrk and brk. */ 95193323Sed#define AT_DEBUG 11 /* Debugging level. */ 96193323Sed 97193323Sed/* 98193323Sed * The following non-standard values are used in Linux ELF binaries. 99193323Sed */ 100218893Sdim#define AT_NOTELF 10 /* Program is not ELF ?? */ 101218893Sdim#define AT_UID 11 /* Real uid. */ 102193323Sed#define AT_EUID 12 /* Effective uid. */ 103193323Sed#define AT_GID 13 /* Real gid. */ 104193323Sed#define AT_EGID 14 /* Effective gid. */ 105193323Sed 106193323Sed#define AT_COUNT 15 /* Count of defined aux entry types. */ 107193323Sed 108193323Sed/* 109193323Sed * Relocation types. 110193323Sed */ 111193323Sed 112193323Sed#define R_386_NONE 0 /* No relocation. */ 113210299Sed#define R_386_32 1 /* Add symbol value. */ 114210299Sed#define R_386_PC32 2 /* Add PC-relative symbol value. */ 115210299Sed#define R_386_GOT32 3 /* Add PC-relative GOT offset. */ 116210299Sed#define R_386_PLT32 4 /* Add PC-relative PLT offset. */ 117210299Sed#define R_386_COPY 5 /* Copy data from shared object. */ 118210299Sed#define R_386_GLOB_DAT 6 /* Set GOT entry to data address. */ 119218893Sdim#define R_386_JMP_SLOT 7 /* Set GOT entry to code address. */ 120193323Sed#define R_386_RELATIVE 8 /* Add load address of shared object. */ 121193323Sed#define R_386_GOTOFF 9 /* Add GOT-relative symbol address. */ 122193323Sed#define R_386_GOTPC 10 /* Add PC-relative GOT table address. */ 123208599Srdivacky 124208599Srdivacky#define R_386_COUNT 11 /* Count of defined relocation types. */ 125193323Sed 126193323Sed/* Define "machine" characteristics */ 127193323Sed#define ELF_TARG_CLASS ELFCLASS32 128193323Sed#define ELF_TARG_DATA ELFDATA2LSB 129208599Srdivacky#define ELF_TARG_MACH EM_386 130208599Srdivacky#define ELF_TARG_VER 1 131218893Sdim 132207618Srdivacky#ifdef _KERNEL 133207618Srdivacky 134207618Srdivacky/* 135207618Srdivacky * On the i386 we load the dynamic linker where a userland call 136207618Srdivacky * to mmap(0, ...) would put it. The rationale behind this 137207618Srdivacky * calculation is that it leaves room for the heap to grow to 138193323Sed * its maximum allowed size. 139193323Sed */ 140218893Sdim#define ELF_RTLD_ADDR(vmspace) \ 141193323Sed (round_page((vm_offset_t)(vmspace)->vm_daddr + maxdsiz)) 142193323Sed 143193323Sed#endif /* _KERNEL */ 144193323Sed#endif /* !_MACHINE_ELF_H_ */ 145193323Sed