1*bfc185c1Svisa.\" $OpenBSD: core.5,v 1.25 2021/05/01 16:11:10 visa Exp $ 2df930be7Sderaadt.\" $NetBSD: core.5,v 1.4 1994/11/30 19:31:11 jtc Exp $ 3df930be7Sderaadt.\" 4df930be7Sderaadt.\" Copyright (c) 1980, 1991, 1993 5df930be7Sderaadt.\" The Regents of the University of California. All rights reserved. 6df930be7Sderaadt.\" 7df930be7Sderaadt.\" Redistribution and use in source and binary forms, with or without 8df930be7Sderaadt.\" modification, are permitted provided that the following conditions 9df930be7Sderaadt.\" are met: 10df930be7Sderaadt.\" 1. Redistributions of source code must retain the above copyright 11df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer. 12df930be7Sderaadt.\" 2. Redistributions in binary form must reproduce the above copyright 13df930be7Sderaadt.\" notice, this list of conditions and the following disclaimer in the 14df930be7Sderaadt.\" documentation and/or other materials provided with the distribution. 1529295d1cSmillert.\" 3. Neither the name of the University nor the names of its contributors 16df930be7Sderaadt.\" may be used to endorse or promote products derived from this software 17df930be7Sderaadt.\" without specific prior written permission. 18df930be7Sderaadt.\" 19df930be7Sderaadt.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20df930be7Sderaadt.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21df930be7Sderaadt.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22df930be7Sderaadt.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23df930be7Sderaadt.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24df930be7Sderaadt.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25df930be7Sderaadt.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26df930be7Sderaadt.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27df930be7Sderaadt.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28df930be7Sderaadt.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29df930be7Sderaadt.\" SUCH DAMAGE. 30df930be7Sderaadt.\" 31df930be7Sderaadt.\" @(#)core.5 8.3 (Berkeley) 12/11/93 32df930be7Sderaadt.\" 33*bfc185c1Svisa.Dd $Mdocdate: May 1 2021 $ 34df930be7Sderaadt.Dt CORE 5 35fc8533a3Saaron.Os 36df930be7Sderaadt.Sh NAME 37df930be7Sderaadt.Nm core 38df930be7Sderaadt.Nd memory image file format 39df930be7Sderaadt.Sh SYNOPSIS 40e2eeca4cSguenther.In sys/types.h 41e2eeca4cSguenther.In sys/exec_elf.h 42df930be7Sderaadt.Sh DESCRIPTION 43df930be7SderaadtA small number of signals which cause abnormal termination of a process 44df930be7Sderaadtalso cause a record of the process's in-core state to be written 45ae8c025fSaaronto disk for later examination by one of the available debuggers (see 46ae8c025fSaaron.Xr sigaction 2 ) . 47e2eeca4cSguenther.Pp 48e2eeca4cSguentherBy default, this memory image is written to a file named 49ae8c025fSaaron.Pa programname.core 50431305c8Saaronin the working directory, provided the terminated process had write 51e2eeca4cSguentherpermission in the directory, 52e2eeca4cSguentherand the terminated process either had an effective user ID of zero or 53e2eeca4cSguentherhad never changed user or group ID. 54e2eeca4cSguentherSee the description of 55e2eeca4cSguenther.Dv KERN_NOSUIDCOREDUMP 56e2eeca4cSguentherin 57aaeccf36Sderaadt.Xr sysctl 2 58e2eeca4cSguentherfor other options. 59df930be7Sderaadt.Pp 60df930be7SderaadtThe maximum size of a 61ae8c025fSaaron.Pa programname.core 62df930be7Sderaadtfile is limited by 63df930be7Sderaadt.Xr setrlimit 2 . 64df930be7SderaadtFiles which would be larger than the limit are not created. 65df930be7Sderaadt.Pp 66df930be7SderaadtThe 67ae8c025fSaaron.Pa programname.core 68e2eeca4cSguentherfile is in the ELF binary file format with an 69e2eeca4cSguenther.Va e_type 70e2eeca4cSguentherof 71e2eeca4cSguenther.Dv ET_CORE . 72e2eeca4cSguentherIt has no section header table and a segment header that contains 73e2eeca4cSguenther.Dv PT_LOAD 74e2eeca4cSguentherand 75e2eeca4cSguenther.Dv PT_NOTE 76e2eeca4cSguenthersegments that describe the state of the process when terminated. 77e2eeca4cSguenther.Pp 786526b047SjmcThe 79e2eeca4cSguenther.Dv PT_LOAD 80e2eeca4cSguenthersegments hold images of the process memory when it was terminated. 81e2eeca4cSguentherDevice mappings are excluded, 82e2eeca4cSguentheras are read-only mappings that do not have private mapping changes. 83e2eeca4cSguentherEach segment's 84e2eeca4cSguenther.Va p_vaddr , 85e2eeca4cSguenther.Va p_memsz , 86e2eeca4cSguentherand 87e2eeca4cSguenther.Va p_flags 88e2eeca4cSguentherspecify the address, size, and access protection of the memory 89e2eeca4cSguenthersegment it describes. 906526b047Sjmc.Pp 91e2eeca4cSguentherThe 92e2eeca4cSguenther.Dv PT_NOTE 93e2eeca4cSguenthersegment contains notes describing the kernel state and CPU registers 94e2eeca4cSguentherof each thread in the process. 95021489dcSjmcNotes describing the process as a whole have the name 96021489dcSjmc.Dq OpenBSD . 97e2eeca4cSguentherAn 98e2eeca4cSguenther.Dv NT_OPENBSD_PROCINFO 99e2eeca4cSguenthernote is included containing an 100e2eeca4cSguenther.Vt elfcore_procinfo 101e2eeca4cSguentherstructure with information about the kernel state of the process. 102e2eeca4cSguentherAn 103e2eeca4cSguenther.Dv NT_OPENBSD_AUXV 104e2eeca4cSguenthernote is included containing a copy of the original process environment strings. 1056a218dd6SjmcOn sparc64, an 106e2eeca4cSguenther.Dv NT_OPENBSD_WCOOKIE 107e2eeca4cSguenthernote is included containing the process's 108e2eeca4cSguenther.Sq window cookie . 1096526b047Sjmc.Pp 110e2eeca4cSguentherNotes describing the individual threads in the process have names 111e2eeca4cSguentherin the format 112e2eeca4cSguenther.Dq OpenBSD@%d 113e2eeca4cSguentherwhere the suffix is the thread ID. 114e2eeca4cSguentherFor each thread, an 115e2eeca4cSguenther.Dv NT_OPENBSD_REGS 116e2eeca4cSguenthernote is included containing the state of the regular registers of 117*bfc185c1Svisathe thread and, on architectures other than luna88k, an 118e2eeca4cSguenther.Dv NT_OPENBSD_FPREGS 119e2eeca4cSguenthernote is also included containing the state of the floating-point 120e2eeca4cSguentherregisters of the thread. 121df930be7Sderaadt.Sh SEE ALSO 122df930be7Sderaadt.Xr gdb 1 , 123ae8c025fSaaron.Xr setrlimit 2 , 12406d47272Sjmc.Xr sigaction 2 , 125aaeccf36Sderaadt.Xr sysctl 2 126df930be7Sderaadt.Sh HISTORY 127df930be7SderaadtA 128fbd19cc4Saaron.Nm 129df930be7Sderaadtfile format appeared in 13083348857Sschwarze.At v1 . 131e2eeca4cSguenther.Ox 2.0 132e2eeca4cSguentherstarted using the ELF format for some architectures. 133e2eeca4cSguentherAll architectures used ELF starting in 134e2eeca4cSguenther.Ox 5.4 . 13506d47272Sjmc.Sh CAVEATS 136668df217SjmcPrograms which are started with either the set-user-ID or 1374fbb8f26Sderaadtset-group-ID bits set, 138668df217Sjmcor which change their UID or GID after starting, will normally not 1394fbb8f26Sderaadtdump core. 1404fbb8f26SderaadtThis is to prevent sensitive information from inadvertently ending 1414fbb8f26Sderaadtup on disk. 142668df217SjmcThis behaviour can be changed (for debugging purposes) by changing the 14306d47272Sjmc.Li kern.nosuidcoredump 144aaeccf36Sderaadt.Xr sysctl 2 1454fbb8f26Sderaadtvariable to the right settings. 146