kernels/linux-2.4.0/fs/binfmt_aout.c
/*
 * Routine writes a core dump image in the current directory.
 * Currently only a stub-function.
 *
 * Note that setuid/setgid files won't make a core-dump if the uid/gid
 * changed due to the set[u|g]id. It's enforced by the "current->dumpable"
 * field, which also makes sure the core-dumps won't be recursive if the
 * dumping of the process results in another error..
 */
Routine writes a core dump image in the current directory.
Currently only a stub-function.

Note that setuid/setgid files won't make a core-dump if the uid/gid
changed due to the set[u|g]id. It's enforced by the "current->dumpable"
field, which also makes sure the core-dumps won't be recursive if the
dumping of the process results in another error
Routine writes a core dump image in the current directory . Currently only a stub - function . Note that setuid / setgid files won ' t make a core - dump if the uid / gid changed due to the set [ u|g ] id . It ' s enforced by the " current - > dumpable " field which also makes sure the core - dumps won ' t be recursive if the dumping of the process results in another error
static int aout_core_dump(long signr, struct pt_regs * regs, struct file *file)
{
	mm_segment_t fs;
	int has_dumped = 0;
	unsigned long dump_start, dump_size;
	struct user dump;
#if defined(__alpha__)
#       define START_DATA(u)	(u.start_data)
#elif defined(__arm__)
#	define START_DATA(u)	((u.u_tsize << PAGE_SHIFT) + u.start_code)
#elif defined(__sparc__)
#       define START_DATA(u)    (u.u_tsize)
#elif defined(__i386__) || defined(__mc68000__)
#       define START_DATA(u)	(u.u_tsize << PAGE_SHIFT)
#endif
#ifdef __sparc__
#       define START_STACK(u)   ((regs->u_regs[UREG_FP]) & ~(PAGE_SIZE - 1))
#else
#       define START_STACK(u)   (u.start_stack)
#endif
	fs = get_fs();
	set_fs(KERNEL_DS);
	has_dumped = 1;
	current->flags |= PF_DUMPCORE;
       	strncpy(dump.u_comm, current->comm, sizeof(current->comm));
#ifndef __sparc__
	dump.u_ar0 = (void *)(((unsigned long)(&dump.regs)) - ((unsigned long)(&dump)));
#endif
	dump.signal = signr;
	dump_thread(regs, &dump);
#ifdef __sparc__
	if ((dump.u_dsize+dump.u_ssize) >
	    current->rlim[RLIMIT_CORE].rlim_cur)
		dump.u_dsize = 0;
#else
	if ((dump.u_dsize+dump.u_ssize+1) * PAGE_SIZE >
	    current->rlim[RLIMIT_CORE].rlim_cur)
		dump.u_dsize = 0;
#endif
#ifdef __sparc__
	if ((dump.u_ssize) >
	    current->rlim[RLIMIT_CORE].rlim_cur)
		dump.u_ssize = 0;
#else
	if ((dump.u_ssize+1) * PAGE_SIZE >
	    current->rlim[RLIMIT_CORE].rlim_cur)
		dump.u_ssize = 0;
#endif
	set_fs(USER_DS);
#ifdef __sparc__
	if (verify_area(VERIFY_READ, (void *) START_DATA(dump), dump.u_dsize))
		dump.u_dsize = 0;
	if (verify_area(VERIFY_READ, (void *) START_STACK(dump), dump.u_ssize))
		dump.u_ssize = 0;
#else
	if (verify_area(VERIFY_READ, (void *) START_DATA(dump), dump.u_dsize << PAGE_SHIFT))
		dump.u_dsize = 0;
	if (verify_area(VERIFY_READ, (void *) START_STACK(dump), dump.u_ssize << PAGE_SHIFT))
		dump.u_ssize = 0;
#endif
	set_fs(KERNEL_DS);
	DUMP_WRITE(&dump,sizeof(dump));
#ifndef __sparc__
	DUMP_SEEK(PAGE_SIZE);
#endif
	set_fs(USER_DS);
	if (dump.u_dsize != 0) {
		dump_start = START_DATA(dump);
#ifdef __sparc__
		dump_size = dump.u_dsize;
#else
		dump_size = dump.u_dsize << PAGE_SHIFT;
#endif
		DUMP_WRITE(dump_start,dump_size);
	}
	if (dump.u_ssize != 0) {
		dump_start = START_STACK(dump);
#ifdef __sparc__
		dump_size = dump.u_ssize;
#else
		dump_size = dump.u_ssize << PAGE_SHIFT;
#endif
		DUMP_WRITE(dump_start,dump_size);
	}
	set_fs(KERNEL_DS);
	DUMP_WRITE(current,sizeof(*current));
end_coredump:
	set_fs(fs);
	return has_dumped;
}
static int aout_core_dump ( long signr , struct pt_regs * regs , struct file * file ) { mm_segment_t fs ; int has_dumped = 0 ; unsigned long dump_start , dump_size ; struct user dump ; #if defined ( __alpha__ ) #       define START_DATA ( u ) 	(u.start_data) #elif defined ( __arm__ ) #	define START_DATA ( u ) 	((u.u_tsize << PAGE_SHIFT) + u.start_code) #elif defined ( __sparc__ ) #       define START_DATA ( u )     (u.u_tsize) #elif defined ( __i386__ ) || defined ( __mc68000__ ) #       define START_DATA ( u ) 	(u.u_tsize << PAGE_SHIFT) #endif #ifdef __sparc__ #       define START_STACK ( u )    ((regs->u_regs[UREG_FP]) & ~(PAGE_SIZE - 1)) #else #       define START_STACK ( u )    (u.start_stack) #endif fs = get_fs ( ) ; set_fs ( KERNEL_DS ) ; has_dumped = 1 ; current -> flags |= PF_DUMPCORE ; strncpy ( dump . u_comm , current -> comm , sizeof ( current -> comm ) ) ; #ifndef __sparc__ dump . u_ar0 = ( void * ) ( ( ( unsigned long ) ( & dump . regs ) ) - ( ( unsigned long ) ( & dump ) ) ) ; #endif dump . signal = signr ; dump_thread ( regs , & dump ) ; #ifdef __sparc__ if ( ( dump . u_dsize + dump . u_ssize ) > current -> rlim [ RLIMIT_CORE ] . rlim_cur ) dump . u_dsize = 0 ; #else if ( ( dump . u_dsize + dump . u_ssize + 1 ) * PAGE_SIZE > current -> rlim [ RLIMIT_CORE ] . rlim_cur ) dump . u_dsize = 0 ; #endif #ifdef __sparc__ if ( ( dump . u_ssize ) > current -> rlim [ RLIMIT_CORE ] . rlim_cur ) dump . u_ssize = 0 ; #else if ( ( dump . u_ssize + 1 ) * PAGE_SIZE > current -> rlim [ RLIMIT_CORE ] . rlim_cur ) dump . u_ssize = 0 ; #endif set_fs ( USER_DS ) ; #ifdef __sparc__ if ( verify_area ( VERIFY_READ , ( void * ) START_DATA ( dump ) , dump . u_dsize ) ) dump . u_dsize = 0 ; if ( verify_area ( VERIFY_READ , ( void * ) START_STACK ( dump ) , dump . u_ssize ) ) dump . u_ssize = 0 ; #else if ( verify_area ( VERIFY_READ , ( void * ) START_DATA ( dump ) , dump . u_dsize << PAGE_SHIFT ) ) dump . u_dsize = 0 ; if ( verify_area ( VERIFY_READ , ( void * ) START_STACK ( dump ) , dump . u_ssize << PAGE_SHIFT ) ) dump . u_ssize = 0 ; #endif set_fs ( KERNEL_DS ) ; DUMP_WRITE ( & dump , sizeof ( dump ) ) ; #ifndef __sparc__ DUMP_SEEK ( PAGE_SIZE ) ; #endif set_fs ( USER_DS ) ; if ( dump . u_dsize != 0 ) { dump_start = START_DATA ( dump ) ; #ifdef __sparc__ dump_size = dump . u_dsize ; #else dump_size = dump . u_dsize << PAGE_SHIFT ; #endif DUMP_WRITE ( dump_start , dump_size ) ; } if ( dump . u_ssize != 0 ) { dump_start = START_STACK ( dump ) ; #ifdef __sparc__ dump_size = dump . u_ssize ; #else dump_size = dump . u_ssize << PAGE_SHIFT ; #endif DUMP_WRITE ( dump_start , dump_size ) ; } set_fs ( KERNEL_DS ) ; DUMP_WRITE ( current , sizeof ( * current ) ) ; end_coredump : set_fs ( fs ) ; return has_dumped ; }
Routine writes a core dump image in the current directory.
Routine writes a core dump image in the current directory .
/* If the size of the dump file exceeds the rlimit, then see what would happen
   if we wrote the stack, but not the data area.  */ /* Make sure we have enough room to write the stack and data areas. */ /* make sure we actually have a data and stack area to dump */ /* struct user */ /* Now dump all of the user data.  Include malloced stuff as well */ /* now we start writing out the user space info */ /* Dump the data area */ /* Now prepare to dump the stack area */ /* Finally dump the task struct.  Not be used by gdb, but could be useful */