imgact_elf.h revision 279211
1117632Sharti/*- 2117632Sharti * Copyright (c) 1995-1996 S��ren Schmidt 3117632Sharti * All rights reserved. 4117632Sharti * 5117632Sharti * Redistribution and use in source and binary forms, with or without 6117632Sharti * modification, are permitted provided that the following conditions 7117632Sharti * are met: 8117632Sharti * 1. Redistributions of source code must retain the above copyright 9117632Sharti * notice, this list of conditions and the following disclaimer 10117632Sharti * in this position and unchanged. 11117632Sharti * 2. Redistributions in binary form must reproduce the above copyright 12117632Sharti * notice, this list of conditions and the following disclaimer in the 13117632Sharti * documentation and/or other materials provided with the distribution. 14117632Sharti * 3. The name of the author may not be used to endorse or promote products 15117632Sharti * derived from this software without specific prior written permission 16117632Sharti * 17117632Sharti * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18117632Sharti * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19117632Sharti * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20117632Sharti * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21117632Sharti * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22117632Sharti * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23117632Sharti * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24117632Sharti * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25117632Sharti * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26117632Sharti * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27117632Sharti * 28117632Sharti * $FreeBSD: stable/10/sys/sys/imgact_elf.h 279211 2015-02-23 18:38:41Z jhb $ 29117632Sharti */ 30117632Sharti 31117632Sharti#ifndef _SYS_IMGACT_ELF_H_ 32117632Sharti#define _SYS_IMGACT_ELF_H_ 33117632Sharti 34117632Sharti#include <machine/elf.h> 35117632Sharti 36117632Sharti#ifdef _KERNEL 37117632Sharti 38117632Sharti#define AUXARGS_ENTRY(pos, id, val) {suword(pos++, id); suword(pos++, val);} 39117632Sharti 40117632Shartistruct thread; 41117632Sharti 42117632Sharti/* 43117632Sharti * Structure used to pass infomation from the loader to the 44117632Sharti * stack fixup routine. 45117632Sharti */ 46117632Shartitypedef struct { 47117632Sharti Elf_Ssize execfd; 48117632Sharti Elf_Size phdr; 49117632Sharti Elf_Size phent; 50117632Sharti Elf_Size phnum; 51117632Sharti Elf_Size pagesz; 52117632Sharti Elf_Size base; 53117632Sharti Elf_Size flags; 54117632Sharti Elf_Size entry; 55117632Sharti} __ElfN(Auxargs); 56117632Sharti 57117632Shartitypedef struct { 58117632Sharti Elf_Note hdr; 59117632Sharti const char * vendor; 60117632Sharti int flags; 61117632Sharti boolean_t (*trans_osrel)(const Elf_Note *, int32_t *); 62117632Sharti#define BN_CAN_FETCH_OSREL 0x0001 /* Deprecated. */ 63117632Sharti#define BN_TRANSLATE_OSREL 0x0002 /* Use trans_osrel to fetch osrel */ 64117632Sharti /* after checking the image ABI specification, if needed. */ 65117632Sharti} Elf_Brandnote; 66117632Sharti 67117632Shartitypedef struct { 68117632Sharti int brand; 69117632Sharti int machine; 70117632Sharti const char *compat_3_brand; /* pre Binutils 2.10 method (FBSD 3) */ 71117632Sharti const char *emul_path; 72117632Sharti const char *interp_path; 73117632Sharti struct sysentvec *sysvec; 74117632Sharti const char *interp_newpath; 75117632Sharti int flags; 76117632Sharti Elf_Brandnote *brand_note; 77117632Sharti#define BI_CAN_EXEC_DYN 0x0001 78117632Sharti#define BI_BRAND_NOTE 0x0002 /* May have note.ABI-tag section. */ 79117632Sharti#define BI_BRAND_NOTE_MANDATORY 0x0004 /* Must have note.ABI-tag section. */ 80117632Sharti} __ElfN(Brandinfo); 81117632Sharti 82117632Sharti__ElfType(Auxargs); 83117632Sharti__ElfType(Brandinfo); 84117632Sharti 85117632Sharti#define MAX_BRANDS 8 86117632Sharti 87117632Shartiint __elfN(brand_inuse)(Elf_Brandinfo *entry); 88117632Shartiint __elfN(insert_brand_entry)(Elf_Brandinfo *entry); 89117632Shartiint __elfN(remove_brand_entry)(Elf_Brandinfo *entry); 90117632Shartiint __elfN(freebsd_fixup)(register_t **, struct image_params *); 91117632Shartiint __elfN(coredump)(struct thread *, struct vnode *, off_t, int); 92117632Shartisize_t __elfN(populate_note)(int, void *, void *, size_t, void **); 93117632Sharti 94117632Sharti/* Machine specific function to dump per-thread information. */ 95117632Shartivoid __elfN(dump_thread)(struct thread *, void *, size_t *); 96117632Sharti 97117632Shartiextern int __elfN(fallback_brand); 98117632Shartiextern Elf_Brandnote __elfN(freebsd_brandnote); 99117632Shartiextern Elf_Brandnote __elfN(kfreebsd_brandnote); 100117632Sharti#endif /* _KERNEL */ 101117632Sharti 102117632Sharti#endif /* !_SYS_IMGACT_ELF_H_ */ 103117632Sharti