dump.c revision 5aefb6555731130ca4fd295960123d71f2d21fe8
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/* LINTLIBRARY */
#include <procfs.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <errno.h>
#include <alloca.h>
#include "rtld.h"
#include "rtc.h"
#include "_crle.h"
#include "msg.h"
/*
* Routines for dumping alternate objects under CRLE_AUD_DLDUMP mode.
*/
/*
* For each file in the configuration file that requires an alternate (dldump())
* version, add the object to the processes main link-map. The process head
* may be an application, shared object, or lddstub. In any case this object
* may be augmented with other objects defined within the configuration file.
*
* Each file is initially loaded with RTLD_CONFGEN so that no dependency
* analysis, relocation, or user code (.init's) is executed. By skipping
* analysis we save time and allow for a family of objects to be dumped that
* may not have all relocations satisfied. If necessary, a later call to
* dlopen() using RTLD_NOW will force relocations to occur.
*
* A mapping range is maintained to span the mapping of each objects, and this
* range is finally written back to the caller.
*/
static int
/* ARGSUSED1 */
{
return (1);
}
/*
* Establish the mapping range of the objects dumped so far.
*/
if (membgn == 0) {
} else {
}
return (0);
}
/*
* dldump(3x) an object that is already part of the main link-map list.
*/
static int
{
return (1);
}
return (0);
}
/*
* list is maintained as both a full pathname and a simple filename - we're
* only interested in one.
*
* This rutine is called twice, once to insure the appropriate objects are
* mapped in (fptr == load()) and then once again to dldump(3x) the mapped
* objects (fptr == dump()).
*/
static int
{
/* LINTED */
/*
* Scan the directory and filename arrays looking for alternatives.
*/
continue;
(RTC_OBJ_DUMP | RTC_OBJ_REALPTH)) {
return (1);
}
}
}
/*
* Are we dumping a specific application.
*/
/*
* Obtain a handle to the application and set the
* FL1_RT_CONFSET flag.
*/
(RTLD_NOLOAD | RTLD_CONFGEN))) == 0)
return (1);
} else {
/*
* If we're dumping and this configuration is for a
* specific application dump it also.
*/
/* LINTED */
return (1);
}
}
return (0);
}
/*
* Before loading any dependencies determine the present memory mappings being
* used and fill any holes between these mappings. This insures that all
* dldump()'ed dependencies will live in a single consecutive address range.
*/
int
filladdr(void)
{
/*
* process heap.
*/
return (1);
}
return (1);
}
/*
* Round the process heap to the next page boundary so that it can be
* used to isolated the a.out mappings (pr_brkbase typically occurs
* at the end, but within, the a.out's data segment). As libcrle is
* used as an audit library, no process user code has run so there
* can't be any heap. pr_brksize is added here for completeness.
*/
/*
*/
return (1);
}
/*
* Determine number of mappings - use alloca so as not to perturb any
* mapping information by a malloc, which itself might add a mapping.
*/
/* LINTED */
return (1);
}
return (1);
}
/*
*/
return (1);
}
/*
* Scan each mapping - note it is assummed that the mappings are
* presented in order. We fill holes between mappings. On intel
* the last mapping is usually the data segment of ld.so.1, after
* this comes a red zone into which non-fixed mapping won't get
* place. Thus we can simply bail from the loop after seeing the
* last mapping.
*/
/*
* Skip all mappings below brkbase, these represent the a.out
* (and the stack on intel).
*/
if ((laddr == 0) &&
continue;
/*
* For each consecutive mapping determine the hole between each
*/
if (laddr == 0) {
continue;
}
return (1);
}
}
}
/*
* It's been observed that there may be space between the end of the
* last mapping (typically ld.so.1), and the kernel base address. As
* there's no interface to determine the kernel base address, keep
* filling in pages until we get an error. We'll get ENOMEM once we
* hit the kernel base address.
*/
while (laddr) {
break;
return (1);
}
}
/*
*/
return (0);
}
/*
* Dump alternative objects as part of building a configuration file. A temp
* configuration is already built and made available to the process, and is
* located via dlinfo(). Having load()'ed each object, and dump()'ed its image,
* the final memory reservation infoamtion is returned to the caller.
*/
int
dumpconfig(void)
{
/*
* Determine the configuration file and where it is mapped.
*/
return (1);
}
/*
* Scan the configuration file for alternative entries.
*/
return (1);
/*
* Having mapped all objects, relocate them. It would be nice if we
* could drop this step altogether, and have dldump() carry out just
* those relocations required, but when binding to an application we
* need to handle copy relocations - these can affect bindings (in the
* case of things like libld.so which have direct bindings) and require
* that the data being copied is itself relocated.
*/
return (1);
/*
* Rescan the configuration dumping out each alternative file.
*/
return (1);
/*
* Having established the memory range of the dumped images and
* sucessfully dumped them out, report back to the caller.
*/
return (0);
}