1c2c65e21Sny155746 /* 2c2c65e21Sny155746 * CDDL HEADER START 3c2c65e21Sny155746 * 4c2c65e21Sny155746 * The contents of this file are subject to the terms of the 5c2c65e21Sny155746 * Common Development and Distribution License (the "License"). 6c2c65e21Sny155746 * You may not use this file except in compliance with the License. 7c2c65e21Sny155746 * 8c2c65e21Sny155746 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9c2c65e21Sny155746 * or http://www.opensolaris.org/os/licensing. 10c2c65e21Sny155746 * See the License for the specific language governing permissions 11c2c65e21Sny155746 * and limitations under the License. 12c2c65e21Sny155746 * 13c2c65e21Sny155746 * When distributing Covered Code, include this CDDL HEADER in each 14c2c65e21Sny155746 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15c2c65e21Sny155746 * If applicable, add the following below this CDDL HEADER, with the 16c2c65e21Sny155746 * fields enclosed by brackets "[]" replaced with your own identifying 17c2c65e21Sny155746 * information: Portions Copyright [yyyy] [name of copyright owner] 18c2c65e21Sny155746 * 19c2c65e21Sny155746 * CDDL HEADER END 20c2c65e21Sny155746 */ 21c2c65e21Sny155746 /* 22c2c65e21Sny155746 * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23c2c65e21Sny155746 * Use is subject to license terms. 24c2c65e21Sny155746 */ 25c2c65e21Sny155746 26c2c65e21Sny155746 #ifndef _ELF_READ_H 27c2c65e21Sny155746 #define _ELF_READ_H 28c2c65e21Sny155746 29c2c65e21Sny155746 #define BUFSZ 128 30c2c65e21Sny155746 typedef struct Elf_Info { 31c2c65e21Sny155746 boolean_t dynamic; /* dymanically linked? */ 32c2c65e21Sny155746 unsigned core_type; /* core? what type of core? */ 33c2c65e21Sny155746 unsigned stripped; /* symtab, debug info */ 34c2c65e21Sny155746 unsigned flags; /* e_flags */ 35c2c65e21Sny155746 unsigned machine; /* e_machine */ 36c2c65e21Sny155746 unsigned type; /* e_type */ 37c2c65e21Sny155746 int elffd; /* fd of file being processed */ 38c2c65e21Sny155746 char fname[PRFNSZ]; /* name of process that dumped core */ 39c2c65e21Sny155746 char cap_str[BUFSZ]; /* hw/sw capabilities */ 40c2c65e21Sny155746 char *file; /* file being processed */ 41*b6a0e2cdSRichard Lowe boolean_t kmod; 42c2c65e21Sny155746 } Elf_Info; 43c2c65e21Sny155746 44c2c65e21Sny155746 /* values for Elf_Info.stripped */ 45c2c65e21Sny155746 #define E_DBGINF 0x01 46c2c65e21Sny155746 #define E_SYMTAB 0x02 47c2c65e21Sny155746 #define E_NOSTRIP 0x03 48c2c65e21Sny155746 49c2c65e21Sny155746 /* values for Elf_Info.core_type; */ 50c2c65e21Sny155746 #define EC_NOTCORE 0x0 51c2c65e21Sny155746 #define EC_OLDCORE 0x1 52c2c65e21Sny155746 #define EC_NEWCORE 0x2 53c2c65e21Sny155746 54c2c65e21Sny155746 /* elf file processing errors */ 55c2c65e21Sny155746 #define ELF_ERR_ELFCAP1 gettext("%s: %s zero size or zero entry ELF " \ 56c2c65e21Sny155746 "section - ELF capabilities ignored\n") 57c2c65e21Sny155746 #define ELF_ERR_ELFCAP2 gettext("%s: %s: can't read ELF capabilities " \ 58c2c65e21Sny155746 "data - ELF capabilities ignored\n") 59*b6a0e2cdSRichard Lowe #define ELF_ERR_DYNAMIC1 gettext("%s: %s zero size or zero entry ELF " \ 60*b6a0e2cdSRichard Lowe "section - ELF dynamic tags ignored\n") 61*b6a0e2cdSRichard Lowe #define ELF_ERR_DYNAMIC2 gettext("%s: %s: can't read ELF dynamic " \ 62*b6a0e2cdSRichard Lowe "data - ELF dynamic tags ignored\n") 63c2c65e21Sny155746 64c2c65e21Sny155746 extern int is_in_list(char *str); 65c2c65e21Sny155746 66c2c65e21Sny155746 /* return status for elf_read and its helper functions */ 67c2c65e21Sny155746 #define ELF_READ_OKAY 1 68c2c65e21Sny155746 #define ELF_READ_FAIL 0 69c2c65e21Sny155746 70c2c65e21Sny155746 #if defined(_ELF64) 71c2c65e21Sny155746 72c2c65e21Sny155746 #define Elf_Ehdr Elf64_Ehdr 73c2c65e21Sny155746 #define Elf_Shdr Elf64_Shdr 74c2c65e21Sny155746 #define Elf_Phdr Elf64_Phdr 75c2c65e21Sny155746 #define Elf_Cap Elf64_Cap 76c2c65e21Sny155746 #define Elf_Nhdr Elf64_Nhdr 7797cca090Sab196087 #define Elf_Word Elf64_Word 78*b6a0e2cdSRichard Lowe #define Elf_Dyn Elf64_Dyn 79c2c65e21Sny155746 80c2c65e21Sny155746 #define elf_read elf_read64 81c2c65e21Sny155746 #define elf_xlatetom elf64_xlatetom 82c2c65e21Sny155746 #define elf_fsize elf64_fsize 83c2c65e21Sny155746 #define get_class get_class64 84c2c65e21Sny155746 #define get_version get_version64 85c2c65e21Sny155746 #define get_format get_format64 86c2c65e21Sny155746 87c2c65e21Sny155746 #else 88c2c65e21Sny155746 89c2c65e21Sny155746 #define Elf_Ehdr Elf32_Ehdr 90c2c65e21Sny155746 #define Elf_Shdr Elf32_Shdr 91c2c65e21Sny155746 #define Elf_Phdr Elf32_Phdr 92c2c65e21Sny155746 #define Elf_Cap Elf32_Cap 93c2c65e21Sny155746 #define Elf_Nhdr Elf32_Nhdr 9497cca090Sab196087 #define Elf_Word Elf32_Word 95*b6a0e2cdSRichard Lowe #define Elf_Dyn Elf32_Dyn 96c2c65e21Sny155746 97c2c65e21Sny155746 #define elf_read elf_read32 98c2c65e21Sny155746 #define elf_xlatetom elf32_xlatetom 99c2c65e21Sny155746 #define elf_fsize elf32_fsize 100c2c65e21Sny155746 #define get_class get_class32 101c2c65e21Sny155746 #define get_version get_version32 102c2c65e21Sny155746 #define get_format get_format32 103c2c65e21Sny155746 104c2c65e21Sny155746 #endif 105c2c65e21Sny155746 106c2c65e21Sny155746 /* so lint can understand elf_read64 is defined */ 107c2c65e21Sny155746 #ifdef lint 108c2c65e21Sny155746 #define elf_read64 elf_read 109c2c65e21Sny155746 #endif /* lint */ 110c2c65e21Sny155746 111c2c65e21Sny155746 #endif /* _ELF_READ_H */ 112