elf.h revision 325810
1239268Sgonzo/*- 2239268Sgonzo * Copyright (c) 1996-1997 John D. Polstra. 3239268Sgonzo * All rights reserved. 4239268Sgonzo * 5239268Sgonzo * Redistribution and use in source and binary forms, with or without 6239268Sgonzo * modification, are permitted provided that the following conditions 7239268Sgonzo * are met: 8239268Sgonzo * 1. Redistributions of source code must retain the above copyright 9239268Sgonzo * notice, this list of conditions and the following disclaimer. 10239268Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 11239268Sgonzo * notice, this list of conditions and the following disclaimer in the 12239268Sgonzo * documentation and/or other materials provided with the distribution. 13239268Sgonzo * 14239268Sgonzo * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15239268Sgonzo * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16239268Sgonzo * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17239268Sgonzo * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18239268Sgonzo * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19239268Sgonzo * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20239268Sgonzo * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21239268Sgonzo * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22239268Sgonzo * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23239268Sgonzo * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24239268Sgonzo * SUCH DAMAGE. 25239268Sgonzo * 26239268Sgonzo * $FreeBSD: stable/11/sys/riscv/include/elf.h 325810 2017-11-14 16:03:07Z jhb $ 27239268Sgonzo */ 28239268Sgonzo 29239268Sgonzo#ifndef _MACHINE_ELF_H_ 30239268Sgonzo#define _MACHINE_ELF_H_ 31239268Sgonzo 32244914Sgonzo/* 33244914Sgonzo * ELF definitions for the RISC-V architecture. 34244914Sgonzo */ 35244914Sgonzo 36244914Sgonzo#include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */ 37244914Sgonzo#include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */ 38244914Sgonzo 39244914Sgonzo#define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */ 40244919Sandrew#include <sys/elf_generic.h> 41244919Sandrew 42244919Sandrew/* 43244919Sandrew * Auxiliary vector entries for passing information to the interpreter. 44244919Sandrew */ 45244919Sandrew 46244919Sandrewtypedef struct { /* Auxiliary vector entry on initial stack */ 47244914Sgonzo int a_type; /* Entry type. */ 48244914Sgonzo union { 49244919Sandrew int a_val; /* Integer value. */ 50244914Sgonzo } a_un; 51244914Sgonzo} Elf32_Auxinfo; 52244914Sgonzo 53244914Sgonzotypedef struct { /* Auxiliary vector entry on initial stack */ 54244914Sgonzo long a_type; /* Entry type. */ 55244914Sgonzo union { 56244914Sgonzo long a_val; /* Integer value. */ 57244914Sgonzo void *a_ptr; /* Address. */ 58244914Sgonzo void (*a_fcn)(void); /* Function pointer (not used). */ 59244914Sgonzo } a_un; 60244914Sgonzo} Elf64_Auxinfo; 61244914Sgonzo 62244914Sgonzo__ElfType(Auxinfo); 63244914Sgonzo 64244914Sgonzo#define ELF_ARCH EM_RISCV 65265446Sian 66265446Sian#define ELF_MACHINE_OK(x) ((x) == (ELF_ARCH)) 67265446Sian 68265446Sian/* Values for a_type. */ 69265446Sian#define AT_NULL 0 /* Terminates the vector. */ 70265446Sian#define AT_IGNORE 1 /* Ignored entry. */ 71265446Sian#define AT_EXECFD 2 /* File descriptor of program to load. */ 72265446Sian#define AT_PHDR 3 /* Program header of program already loaded. */ 73244914Sgonzo#define AT_PHENT 4 /* Size of each program header entry. */ 74244914Sgonzo#define AT_PHNUM 5 /* Number of program header entries. */ 75244914Sgonzo#define AT_PAGESZ 6 /* Page size in bytes. */ 76244914Sgonzo#define AT_BASE 7 /* Interpreter's base address. */ 77244914Sgonzo#define AT_FLAGS 8 /* Flags (unused). */ 78244914Sgonzo#define AT_ENTRY 9 /* Where interpreter should transfer control. */ 79244914Sgonzo#define AT_NOTELF 10 /* Program is not ELF ?? */ 80244914Sgonzo#define AT_UID 11 /* Real uid. */ 81244914Sgonzo#define AT_EUID 12 /* Effective uid. */ 82244914Sgonzo#define AT_GID 13 /* Real gid. */ 83244914Sgonzo#define AT_EGID 14 /* Effective gid. */ 84244914Sgonzo#define AT_EXECPATH 15 /* Path to the executable. */ 85244914Sgonzo#define AT_CANARY 16 /* Canary for SSP */ 86244914Sgonzo#define AT_CANARYLEN 17 /* Length of the canary. */ 87244914Sgonzo#define AT_OSRELDATE 18 /* OSRELDATE. */ 88244914Sgonzo#define AT_NCPUS 19 /* Number of CPUs. */ 89244914Sgonzo#define AT_PAGESIZES 20 /* Pagesizes. */ 90244914Sgonzo#define AT_PAGESIZESLEN 21 /* Number of pagesizes. */ 91244914Sgonzo#define AT_TIMEKEEP 22 /* Pointer to timehands. */ 92244914Sgonzo#define AT_STACKPROT 23 /* Initial stack protection. */ 93244914Sgonzo#define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ 94244914Sgonzo#define AT_HWCAP 25 /* CPU feature flags. */ 95244914Sgonzo#define AT_HWCAP2 26 /* CPU feature flags 2. */ 96244914Sgonzo 97244914Sgonzo#define AT_COUNT 27 /* Count of defined aux entry types. */ 98244914Sgonzo 99244914Sgonzo/* Define "machine" characteristics */ 100244914Sgonzo#define ELF_TARG_CLASS ELFCLASS64 101244914Sgonzo#define ELF_TARG_DATA ELFDATA2LSB 102244914Sgonzo#define ELF_TARG_MACH EM_RISCV 103244914Sgonzo#define ELF_TARG_VER 1 104244914Sgonzo 105244914Sgonzo/* TODO: set correct value */ 106244914Sgonzo#define ET_DYN_LOAD_ADDR 0x100000 107244914Sgonzo 108244914Sgonzo#endif /* !_MACHINE_ELF_H_ */ 109244914Sgonzo