1*58a2b000SEvgeniy Ivanov /* $NetBSD: loadfile.h,v 1.12 2010/08/25 16:30:01 christos Exp $ */ 2*58a2b000SEvgeniy Ivanov 3*58a2b000SEvgeniy Ivanov /*- 4*58a2b000SEvgeniy Ivanov * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. 5*58a2b000SEvgeniy Ivanov * All rights reserved. 6*58a2b000SEvgeniy Ivanov * 7*58a2b000SEvgeniy Ivanov * This code is derived from software contributed to The NetBSD Foundation 8*58a2b000SEvgeniy Ivanov * by Christos Zoulas. 9*58a2b000SEvgeniy Ivanov * 10*58a2b000SEvgeniy Ivanov * Redistribution and use in source and binary forms, with or without 11*58a2b000SEvgeniy Ivanov * modification, are permitted provided that the following conditions 12*58a2b000SEvgeniy Ivanov * are met: 13*58a2b000SEvgeniy Ivanov * 1. Redistributions of source code must retain the above copyright 14*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer. 15*58a2b000SEvgeniy Ivanov * 2. Redistributions in binary form must reproduce the above copyright 16*58a2b000SEvgeniy Ivanov * notice, this list of conditions and the following disclaimer in the 17*58a2b000SEvgeniy Ivanov * documentation and/or other materials provided with the distribution. 18*58a2b000SEvgeniy Ivanov * 19*58a2b000SEvgeniy Ivanov * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20*58a2b000SEvgeniy Ivanov * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21*58a2b000SEvgeniy Ivanov * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*58a2b000SEvgeniy Ivanov * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23*58a2b000SEvgeniy Ivanov * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24*58a2b000SEvgeniy Ivanov * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25*58a2b000SEvgeniy Ivanov * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*58a2b000SEvgeniy Ivanov * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27*58a2b000SEvgeniy Ivanov * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28*58a2b000SEvgeniy Ivanov * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29*58a2b000SEvgeniy Ivanov * POSSIBILITY OF SUCH DAMAGE. 30*58a2b000SEvgeniy Ivanov */ 31*58a2b000SEvgeniy Ivanov 32*58a2b000SEvgeniy Ivanov /* 33*58a2b000SEvgeniy Ivanov * Array indices in the u_long position array 34*58a2b000SEvgeniy Ivanov */ 35*58a2b000SEvgeniy Ivanov #define MARK_START 0 36*58a2b000SEvgeniy Ivanov #define MARK_ENTRY 1 37*58a2b000SEvgeniy Ivanov #define MARK_DATA 2 38*58a2b000SEvgeniy Ivanov #define MARK_NSYM 3 39*58a2b000SEvgeniy Ivanov #define MARK_SYM 4 40*58a2b000SEvgeniy Ivanov #define MARK_END 5 41*58a2b000SEvgeniy Ivanov #define MARK_MAX 6 42*58a2b000SEvgeniy Ivanov 43*58a2b000SEvgeniy Ivanov /* 44*58a2b000SEvgeniy Ivanov * Bit flags for sections to load 45*58a2b000SEvgeniy Ivanov */ 46*58a2b000SEvgeniy Ivanov #define LOAD_TEXT 0x0001 47*58a2b000SEvgeniy Ivanov #define LOAD_TEXTA 0x0002 48*58a2b000SEvgeniy Ivanov #define LOAD_DATA 0x0004 49*58a2b000SEvgeniy Ivanov #define LOAD_BSS 0x0008 50*58a2b000SEvgeniy Ivanov #define LOAD_SYM 0x0010 51*58a2b000SEvgeniy Ivanov #define LOAD_HDR 0x0020 52*58a2b000SEvgeniy Ivanov #define LOAD_NOTE 0x0040 53*58a2b000SEvgeniy Ivanov #define LOAD_ALL 0x007f 54*58a2b000SEvgeniy Ivanov #define LOAD_MINIMAL 0x002f 55*58a2b000SEvgeniy Ivanov #define LOAD_BACKWARDS 0x0050 56*58a2b000SEvgeniy Ivanov 57*58a2b000SEvgeniy Ivanov #define COUNT_TEXT 0x0100 58*58a2b000SEvgeniy Ivanov #define COUNT_TEXTA 0x0200 59*58a2b000SEvgeniy Ivanov #define COUNT_DATA 0x0400 60*58a2b000SEvgeniy Ivanov #define COUNT_BSS 0x0800 61*58a2b000SEvgeniy Ivanov #define COUNT_SYM 0x1000 62*58a2b000SEvgeniy Ivanov #define COUNT_HDR 0x2000 63*58a2b000SEvgeniy Ivanov #define COUNT_ALL 0x3f00 64*58a2b000SEvgeniy Ivanov 65*58a2b000SEvgeniy Ivanov int loadfile(const char *, u_long *, int); 66*58a2b000SEvgeniy Ivanov int fdloadfile(int fd, u_long *, int); 67*58a2b000SEvgeniy Ivanov 68*58a2b000SEvgeniy Ivanov #ifndef MACHINE_LOADFILE_MACHDEP 69*58a2b000SEvgeniy Ivanov #define MACHINE_LOADFILE_MACHDEP "machine/loadfile_machdep.h" 70*58a2b000SEvgeniy Ivanov #endif 71*58a2b000SEvgeniy Ivanov #include MACHINE_LOADFILE_MACHDEP 72*58a2b000SEvgeniy Ivanov 73*58a2b000SEvgeniy Ivanov #ifdef BOOT_ECOFF 74*58a2b000SEvgeniy Ivanov #include <sys/exec_ecoff.h> 75*58a2b000SEvgeniy Ivanov int loadfile_coff(int, struct ecoff_exechdr *, u_long *, int); 76*58a2b000SEvgeniy Ivanov #endif 77*58a2b000SEvgeniy Ivanov 78*58a2b000SEvgeniy Ivanov #if defined(BOOT_ELF32) || defined(BOOT_ELF64) 79*58a2b000SEvgeniy Ivanov #include <sys/exec_elf.h> 80*58a2b000SEvgeniy Ivanov #ifdef BOOT_ELF32 81*58a2b000SEvgeniy Ivanov int loadfile_elf32(int, Elf32_Ehdr *, u_long *, int); 82*58a2b000SEvgeniy Ivanov #endif 83*58a2b000SEvgeniy Ivanov #ifdef BOOT_ELF64 84*58a2b000SEvgeniy Ivanov int loadfile_elf64(int, Elf64_Ehdr *, u_long *, int); 85*58a2b000SEvgeniy Ivanov #endif 86*58a2b000SEvgeniy Ivanov #endif /* BOOT_ELF32 || BOOT_ELF64 */ 87*58a2b000SEvgeniy Ivanov 88*58a2b000SEvgeniy Ivanov #ifdef BOOT_AOUT 89*58a2b000SEvgeniy Ivanov #include <sys/exec_aout.h> 90*58a2b000SEvgeniy Ivanov int loadfile_aout(int, struct exec *, u_long *, int); 91*58a2b000SEvgeniy Ivanov #endif 92*58a2b000SEvgeniy Ivanov 93*58a2b000SEvgeniy Ivanov extern uint32_t netbsd_version; 94*58a2b000SEvgeniy Ivanov extern u_int netbsd_elf_class; 95