17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 59acbbeafSnn35248 * Common Development and Distribution License (the "License"). 69acbbeafSnn35248 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 229acbbeafSnn35248 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 25*4e18e297SPatrick Mooney /* 26*4e18e297SPatrick Mooney * Copyright 2019 Joyent, Inc. 27*4e18e297SPatrick Mooney */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _ELF_ELF_IMPL_H 307c478bd9Sstevel@tonic-gate #define _ELF_ELF_IMPL_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #if !defined(_LP64) || defined(_ELF32_COMPAT) 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * Definitions for ELF32, native 32-bit or 32-bit compatibility mode. 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate #define ELFCLASS ELFCLASS32 427c478bd9Sstevel@tonic-gate typedef unsigned int aux_val_t; 437c478bd9Sstevel@tonic-gate typedef auxv32_t aux_entry_t; 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate #define USR_LIB_RTLD "/usr/lib/ld.so.1" 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #else /* !_LP64 || _ELF32_COMPAT */ 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate /* 507c478bd9Sstevel@tonic-gate * Definitions for native 64-bit ELF 517c478bd9Sstevel@tonic-gate */ 527c478bd9Sstevel@tonic-gate #define ELFCLASS ELFCLASS64 537c478bd9Sstevel@tonic-gate typedef unsigned long aux_val_t; 547c478bd9Sstevel@tonic-gate typedef auxv_t aux_entry_t; 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate /* put defines for 64-bit architectures here */ 577c478bd9Sstevel@tonic-gate #if defined(__sparcv9) 587c478bd9Sstevel@tonic-gate #define USR_LIB_RTLD "/usr/lib/sparcv9/ld.so.1" 597c478bd9Sstevel@tonic-gate #endif 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate #if defined(__amd64) 627c478bd9Sstevel@tonic-gate #define USR_LIB_RTLD "/usr/lib/amd64/ld.so.1" 637c478bd9Sstevel@tonic-gate #endif 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate #endif /* !_LP64 || _ELF32_COMPAT */ 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * Start of an ELF Note. 697c478bd9Sstevel@tonic-gate */ 707c478bd9Sstevel@tonic-gate typedef struct { 717c478bd9Sstevel@tonic-gate Nhdr nhdr; 727c478bd9Sstevel@tonic-gate char name[8]; 737c478bd9Sstevel@tonic-gate } Note; 747c478bd9Sstevel@tonic-gate 75*4e18e297SPatrick Mooney typedef struct { 76*4e18e297SPatrick Mooney vnode_t *ecc_vp; 77*4e18e297SPatrick Mooney proc_t *ecc_p; 78*4e18e297SPatrick Mooney cred_t *ecc_credp; 79*4e18e297SPatrick Mooney rlim64_t ecc_rlimit; 80*4e18e297SPatrick Mooney core_content_t ecc_content; 81*4e18e297SPatrick Mooney u_offset_t ecc_doffset; 82*4e18e297SPatrick Mooney void *ecc_buf; 83*4e18e297SPatrick Mooney size_t ecc_bufsz; 84*4e18e297SPatrick Mooney } elf_core_ctx_t; 85*4e18e297SPatrick Mooney 867c478bd9Sstevel@tonic-gate #ifdef _ELF32_COMPAT 877c478bd9Sstevel@tonic-gate /* 887c478bd9Sstevel@tonic-gate * These are defined only for the 32-bit compatibility 897c478bd9Sstevel@tonic-gate * compilation mode of the 64-bit kernel. 907c478bd9Sstevel@tonic-gate */ 917c478bd9Sstevel@tonic-gate #define elfexec elf32exec 927c478bd9Sstevel@tonic-gate #define elfnote elf32note 937c478bd9Sstevel@tonic-gate #define elfcore elf32core 94*4e18e297SPatrick Mooney #define elfreadhdr elf32readhdr 959acbbeafSnn35248 #define mapexec_brand mapexec32_brand 967c478bd9Sstevel@tonic-gate #define setup_note_header setup_note_header32 977c478bd9Sstevel@tonic-gate #define write_elfnotes write_elfnotes32 987c478bd9Sstevel@tonic-gate #define setup_old_note_header setup_old_note_header32 997c478bd9Sstevel@tonic-gate #define write_old_elfnotes write_old_elfnotes32 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #if defined(__sparc) 1027c478bd9Sstevel@tonic-gate #define gwindows_t gwindows32_t 1037c478bd9Sstevel@tonic-gate #define rwindow rwindow32 1047c478bd9Sstevel@tonic-gate #endif 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate #define psinfo_t psinfo32_t 1077c478bd9Sstevel@tonic-gate #define pstatus_t pstatus32_t 1087c478bd9Sstevel@tonic-gate #define lwpsinfo_t lwpsinfo32_t 1097c478bd9Sstevel@tonic-gate #define lwpstatus_t lwpstatus32_t 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate #define prgetpsinfo prgetpsinfo32 1127c478bd9Sstevel@tonic-gate #define prgetstatus prgetstatus32 1137c478bd9Sstevel@tonic-gate #define prgetlwpsinfo prgetlwpsinfo32 1147c478bd9Sstevel@tonic-gate #define prgetlwpstatus prgetlwpstatus32 1157c478bd9Sstevel@tonic-gate #define prgetwindows prgetwindows32 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate #define prpsinfo_t prpsinfo32_t 1187c478bd9Sstevel@tonic-gate #define prstatus_t prstatus32_t 1197c478bd9Sstevel@tonic-gate #if defined(prfpregset_t) 1207c478bd9Sstevel@tonic-gate #undef prfpregset_t 1217c478bd9Sstevel@tonic-gate #endif 1227c478bd9Sstevel@tonic-gate #define prfpregset_t prfpregset32_t 1237c478bd9Sstevel@tonic-gate 1247c478bd9Sstevel@tonic-gate #define oprgetstatus oprgetstatus32 1257c478bd9Sstevel@tonic-gate #define oprgetpsinfo oprgetpsinfo32 1267c478bd9Sstevel@tonic-gate #define prgetprfpregs prgetprfpregs32 1277c478bd9Sstevel@tonic-gate 1287c478bd9Sstevel@tonic-gate #endif /* _ELF32_COMPAT */ 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate extern int elfnote(vnode_t *, offset_t *, int, int, void *, rlim64_t, cred_t *); 1317c478bd9Sstevel@tonic-gate extern void setup_old_note_header(Phdr *, proc_t *); 1327c478bd9Sstevel@tonic-gate extern void setup_note_header(Phdr *, proc_t *); 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate extern int write_old_elfnotes(proc_t *, int, vnode_t *, offset_t, 1357c478bd9Sstevel@tonic-gate rlim64_t, cred_t *); 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate extern int write_elfnotes(proc_t *, int, vnode_t *, offset_t, 1387c478bd9Sstevel@tonic-gate rlim64_t, cred_t *, core_content_t); 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1417c478bd9Sstevel@tonic-gate } 1427c478bd9Sstevel@tonic-gate #endif 1437c478bd9Sstevel@tonic-gate 1447c478bd9Sstevel@tonic-gate #endif /* _ELF_ELF_IMPL_H */ 145