exec_elf64.c revision 1.5
11.5Schristos/* $NetBSD: exec_elf64.c,v 1.5 2014/03/07 01:34:29 christos Exp $ */ 21.1Scgd 31.1Scgd/* 41.1Scgd * Copyright (c) 1996 Christopher G. Demetriou 51.1Scgd * All rights reserved. 61.1Scgd * 71.1Scgd * Redistribution and use in source and binary forms, with or without 81.1Scgd * modification, are permitted provided that the following conditions 91.1Scgd * are met: 101.1Scgd * 1. Redistributions of source code must retain the above copyright 111.1Scgd * notice, this list of conditions and the following disclaimer. 121.1Scgd * 2. Redistributions in binary form must reproduce the above copyright 131.1Scgd * notice, this list of conditions and the following disclaimer in the 141.1Scgd * documentation and/or other materials provided with the distribution. 151.1Scgd * 3. All advertising materials mentioning features or use of this software 161.1Scgd * must display the following acknowledgement: 171.1Scgd * This product includes software developed by Christopher G. Demetriou 181.1Scgd * for the NetBSD Project. 191.1Scgd * 4. The name of the author may not be used to endorse or promote products 201.1Scgd * derived from this software without specific prior written permission 211.1Scgd * 221.1Scgd * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 231.1Scgd * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 241.1Scgd * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 251.1Scgd * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 261.1Scgd * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 271.1Scgd * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 281.1Scgd * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 291.1Scgd * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 301.1Scgd * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 311.1Scgd * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 321.1Scgd */ 331.2Slukem 341.2Slukem#include <sys/cdefs.h> 351.5Schristos__KERNEL_RCSID(0, "$NetBSD: exec_elf64.c,v 1.5 2014/03/07 01:34:29 christos Exp $"); 361.1Scgd 371.1Scgd#define ELFSIZE 64 381.1Scgd 391.3Sad#include "exec_elf.c" 401.3Sad 411.3Sad#include <sys/module.h> 421.3Sad 431.3Sad#define ELF64_AUXSIZE (howmany(ELF_AUX_ENTRIES * sizeof(Aux64Info), \ 441.3Sad sizeof(Elf64_Addr)) + MAXPATHLEN + ALIGN(1)) 451.3Sad 461.3Sad#ifdef COREDUMP 471.3Sad#define DEP "coredump" 481.3Sad#else 491.3Sad#define DEP NULL 501.3Sad#endif 511.3Sad 521.4SchristosMODULE(MODULE_CLASS_EXEC, exec_elf64, DEP); 531.3Sad 541.3Sadstatic struct execsw exec_elf64_execsw[] = { 551.3Sad /* Native Elf64 */ 561.5Schristos { 571.5Schristos .es_hdrsz = sizeof (Elf64_Ehdr), 581.5Schristos .es_makecmds = exec_elf64_makecmds, 591.5Schristos .u = { 601.5Schristos .elf_probe_func = netbsd_elf64_probe, 611.5Schristos }, 621.5Schristos .es_emul = &emul_netbsd, 631.5Schristos .es_prio = EXECSW_PRIO_ANY, 641.5Schristos .es_arglen = ELF64_AUXSIZE, 651.5Schristos .es_copyargs = elf64_copyargs, 661.5Schristos .es_setregs = NULL, 671.5Schristos .es_coredump = coredump_elf64, 681.5Schristos .es_setup_stack = exec_setup_stack, 691.5Schristos }, 701.3Sad#if EXEC_ELF_NOTELESS 711.3Sad /* Generic Elf64 -- run at NetBSD Elf64 */ 721.5Schristos { 731.5Schristos .es_hdrsz = sizeof (Elf64_Ehdr), 741.5Schristos .es_makecmds = exec_elf64_makecmds, 751.5Schristos .u = { 761.5Schristos .elf_probe_func = NULL, 771.5Schristos }, 781.5Schristos .es_emul = &emul_netbsd, 791.5Schristos .es_prio = EXECSW_PRIO_ANY, 801.5Schristos .es_arglen = ELF64_AUXSIZE, 811.5Schristos .es_copyargs = elf64_copyargs, 821.5Schristos .es_setregs = NULL, 831.5Schristos .es_coredump = coredump_elf64, 841.5Schristos .es_setup_stack = exec_setup_stack, 851.5Schristos }, 861.3Sad#endif 871.3Sad}; 881.3Sad 891.3Sadstatic int 901.3Sadexec_elf64_modcmd(modcmd_t cmd, void *arg) 911.3Sad{ 921.3Sad 931.3Sad switch (cmd) { 941.3Sad case MODULE_CMD_INIT: 951.3Sad return exec_add(exec_elf64_execsw, 961.3Sad __arraycount(exec_elf64_execsw)); 971.3Sad 981.3Sad case MODULE_CMD_FINI: 991.3Sad return exec_remove(exec_elf64_execsw, 1001.3Sad __arraycount(exec_elf64_execsw)); 1011.3Sad 1021.3Sad default: 1031.3Sad return ENOTTY; 1041.3Sad } 1051.3Sad} 106