131a53cd0SKonstantin Belousov /*- 2ebf5747bSPedro F. Giffuni * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3ebf5747bSPedro F. Giffuni * 431a53cd0SKonstantin Belousov * Copyright (c) 1996-1997 John D. Polstra. 531a53cd0SKonstantin Belousov * All rights reserved. 631a53cd0SKonstantin Belousov * 731a53cd0SKonstantin Belousov * Redistribution and use in source and binary forms, with or without 831a53cd0SKonstantin Belousov * modification, are permitted provided that the following conditions 931a53cd0SKonstantin Belousov * are met: 1031a53cd0SKonstantin Belousov * 1. Redistributions of source code must retain the above copyright 1131a53cd0SKonstantin Belousov * notice, this list of conditions and the following disclaimer. 1231a53cd0SKonstantin Belousov * 2. Redistributions in binary form must reproduce the above copyright 1331a53cd0SKonstantin Belousov * notice, this list of conditions and the following disclaimer in the 1431a53cd0SKonstantin Belousov * documentation and/or other materials provided with the distribution. 1531a53cd0SKonstantin Belousov * 1631a53cd0SKonstantin Belousov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1731a53cd0SKonstantin Belousov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1831a53cd0SKonstantin Belousov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1931a53cd0SKonstantin Belousov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2031a53cd0SKonstantin Belousov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2131a53cd0SKonstantin Belousov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2231a53cd0SKonstantin Belousov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2331a53cd0SKonstantin Belousov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2431a53cd0SKonstantin Belousov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2531a53cd0SKonstantin Belousov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2631a53cd0SKonstantin Belousov * SUCH DAMAGE. 2731a53cd0SKonstantin Belousov * 2831a53cd0SKonstantin Belousov * $FreeBSD$ 2931a53cd0SKonstantin Belousov */ 3031a53cd0SKonstantin Belousov 3131a53cd0SKonstantin Belousov #ifndef _MACHINE_ELF_H_ 3231a53cd0SKonstantin Belousov #define _MACHINE_ELF_H_ 1 3331a53cd0SKonstantin Belousov 3431a53cd0SKonstantin Belousov #if defined(__i386__) || defined(_MACHINE_ELF_WANT_32BIT) 35*82914538SKonstantin Belousov /* ELF definitions for the i386 architecture. */ 3631a53cd0SKonstantin Belousov #include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */ 3731a53cd0SKonstantin Belousov #if defined(__ELF_WORD_SIZE) && __ELF_WORD_SIZE == 64 38*82914538SKonstantin Belousov /* Definitions common to all 64 bit architectures. */ 39*82914538SKonstantin Belousov #include <sys/elf64.h> 4031a53cd0SKonstantin Belousov #endif 4131a53cd0SKonstantin Belousov 4231a53cd0SKonstantin Belousov #ifndef __ELF_WORD_SIZE 4331a53cd0SKonstantin Belousov #define __ELF_WORD_SIZE 32 /* Used by <sys/elf_generic.h> */ 4431a53cd0SKonstantin Belousov #endif 4531a53cd0SKonstantin Belousov 4631a53cd0SKonstantin Belousov #include <sys/elf_generic.h> 4731a53cd0SKonstantin Belousov 4831a53cd0SKonstantin Belousov #define ELF_ARCH EM_386 4931a53cd0SKonstantin Belousov 5031a53cd0SKonstantin Belousov #define ELF_MACHINE_OK(x) ((x) == EM_386 || (x) == EM_486) 5131a53cd0SKonstantin Belousov 5231a53cd0SKonstantin Belousov /* 5331a53cd0SKonstantin Belousov * Auxiliary vector entries for passing information to the interpreter. 5431a53cd0SKonstantin Belousov * 5531a53cd0SKonstantin Belousov * The i386 supplement to the SVR4 ABI specification names this "auxv_t", 5631a53cd0SKonstantin Belousov * but POSIX lays claim to all symbols ending with "_t". 5731a53cd0SKonstantin Belousov */ 5831a53cd0SKonstantin Belousov 5931a53cd0SKonstantin Belousov typedef struct { /* Auxiliary vector entry on initial stack */ 6031a53cd0SKonstantin Belousov int a_type; /* Entry type. */ 6131a53cd0SKonstantin Belousov union { 6231a53cd0SKonstantin Belousov long a_val; /* Integer value. */ 6331a53cd0SKonstantin Belousov void *a_ptr; /* Address. */ 6431a53cd0SKonstantin Belousov void (*a_fcn)(void); /* Function pointer (not used). */ 6531a53cd0SKonstantin Belousov } a_un; 6631a53cd0SKonstantin Belousov } Elf32_Auxinfo; 6731a53cd0SKonstantin Belousov 6831a53cd0SKonstantin Belousov #if __ELF_WORD_SIZE == 64 6931a53cd0SKonstantin Belousov /* Fake for amd64 loader support */ 7031a53cd0SKonstantin Belousov typedef struct { 7131a53cd0SKonstantin Belousov int fake; 7231a53cd0SKonstantin Belousov } Elf64_Auxinfo; 7331a53cd0SKonstantin Belousov #endif 7431a53cd0SKonstantin Belousov 7531a53cd0SKonstantin Belousov __ElfType(Auxinfo); 7631a53cd0SKonstantin Belousov 7731a53cd0SKonstantin Belousov /* 7831a53cd0SKonstantin Belousov * Relocation types. 7931a53cd0SKonstantin Belousov */ 8031a53cd0SKonstantin Belousov 8131a53cd0SKonstantin Belousov #define R_386_COUNT 38 /* Count of defined relocation types. */ 8231a53cd0SKonstantin Belousov 8331a53cd0SKonstantin Belousov /* Define "machine" characteristics */ 8431a53cd0SKonstantin Belousov #define ELF_TARG_CLASS ELFCLASS32 8531a53cd0SKonstantin Belousov #define ELF_TARG_DATA ELFDATA2LSB 8631a53cd0SKonstantin Belousov #define ELF_TARG_MACH EM_386 8731a53cd0SKonstantin Belousov #define ELF_TARG_VER 1 8831a53cd0SKonstantin Belousov 895f00525dSKonstantin Belousov #define ET_DYN_LOAD_ADDR 0x00002000 9031a53cd0SKonstantin Belousov 9131a53cd0SKonstantin Belousov #elif defined(__amd64__) 9231a53cd0SKonstantin Belousov 9331a53cd0SKonstantin Belousov /* 9431a53cd0SKonstantin Belousov * ELF definitions for the AMD64 architecture. 9531a53cd0SKonstantin Belousov */ 9631a53cd0SKonstantin Belousov 9731a53cd0SKonstantin Belousov #ifndef __ELF_WORD_SIZE 9831a53cd0SKonstantin Belousov #define __ELF_WORD_SIZE 64 /* Used by <sys/elf_generic.h> */ 9931a53cd0SKonstantin Belousov #endif 10031a53cd0SKonstantin Belousov #include <sys/elf32.h> /* Definitions common to all 32 bit architectures. */ 10131a53cd0SKonstantin Belousov #include <sys/elf64.h> /* Definitions common to all 64 bit architectures. */ 10231a53cd0SKonstantin Belousov #include <sys/elf_generic.h> 10331a53cd0SKonstantin Belousov 10431a53cd0SKonstantin Belousov #define ELF_ARCH EM_X86_64 10531a53cd0SKonstantin Belousov #define ELF_ARCH32 EM_386 10631a53cd0SKonstantin Belousov 10731a53cd0SKonstantin Belousov #define ELF_MACHINE_OK(x) ((x) == EM_X86_64) 10831a53cd0SKonstantin Belousov 10931a53cd0SKonstantin Belousov /* 11031a53cd0SKonstantin Belousov * Auxiliary vector entries for passing information to the interpreter. 11131a53cd0SKonstantin Belousov * 11231a53cd0SKonstantin Belousov * The i386 supplement to the SVR4 ABI specification names this "auxv_t", 11331a53cd0SKonstantin Belousov * but POSIX lays claim to all symbols ending with "_t". 11431a53cd0SKonstantin Belousov */ 11531a53cd0SKonstantin Belousov typedef struct { /* Auxiliary vector entry on initial stack */ 11631a53cd0SKonstantin Belousov int a_type; /* Entry type. */ 11731a53cd0SKonstantin Belousov union { 11831a53cd0SKonstantin Belousov int a_val; /* Integer value. */ 11931a53cd0SKonstantin Belousov } a_un; 12031a53cd0SKonstantin Belousov } Elf32_Auxinfo; 12131a53cd0SKonstantin Belousov 12231a53cd0SKonstantin Belousov typedef struct { /* Auxiliary vector entry on initial stack */ 12331a53cd0SKonstantin Belousov long a_type; /* Entry type. */ 12431a53cd0SKonstantin Belousov union { 12531a53cd0SKonstantin Belousov long a_val; /* Integer value. */ 12631a53cd0SKonstantin Belousov void *a_ptr; /* Address. */ 12731a53cd0SKonstantin Belousov void (*a_fcn)(void); /* Function pointer (not used). */ 12831a53cd0SKonstantin Belousov } a_un; 12931a53cd0SKonstantin Belousov } Elf64_Auxinfo; 13031a53cd0SKonstantin Belousov 13131a53cd0SKonstantin Belousov __ElfType(Auxinfo); 13231a53cd0SKonstantin Belousov 13331a53cd0SKonstantin Belousov /* 13431a53cd0SKonstantin Belousov * Relocation types. 13531a53cd0SKonstantin Belousov */ 13631a53cd0SKonstantin Belousov 13731a53cd0SKonstantin Belousov #define R_X86_64_COUNT 24 /* Count of defined relocation types. */ 13831a53cd0SKonstantin Belousov 13931a53cd0SKonstantin Belousov /* Define "machine" characteristics */ 14031a53cd0SKonstantin Belousov #if __ELF_WORD_SIZE == 32 14131a53cd0SKonstantin Belousov #define ELF_TARG_CLASS ELFCLASS32 14231a53cd0SKonstantin Belousov #else 14331a53cd0SKonstantin Belousov #define ELF_TARG_CLASS ELFCLASS64 14431a53cd0SKonstantin Belousov #endif 14531a53cd0SKonstantin Belousov #define ELF_TARG_DATA ELFDATA2LSB 14631a53cd0SKonstantin Belousov #define ELF_TARG_MACH EM_X86_64 14731a53cd0SKonstantin Belousov #define ELF_TARG_VER 1 14831a53cd0SKonstantin Belousov 14931a53cd0SKonstantin Belousov #if __ELF_WORD_SIZE == 32 1505f00525dSKonstantin Belousov #define ET_DYN_LOAD_ADDR 0x00002000 15131a53cd0SKonstantin Belousov #else 15231a53cd0SKonstantin Belousov #define ET_DYN_LOAD_ADDR 0x01021000 15331a53cd0SKonstantin Belousov #endif 15431a53cd0SKonstantin Belousov 15531a53cd0SKonstantin Belousov #endif /* __i386__, __amd64__ */ 15631a53cd0SKonstantin Belousov 15731a53cd0SKonstantin Belousov #endif /* !_MACHINE_ELF_H_ */ 158