/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <ctf_impl.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <dlfcn.h>
#include <gelf.h>
#ifdef _LP64
#else
#endif
static struct {
const char *(*z_error)(int);
void *z_dlp;
} zlib;
#pragma init(_libctf_init)
void
_libctf_init(void)
{
const char *p = getenv("LIBCTF_DECOMPRESSOR");
if (p != NULL)
_libctf_zlib = p; /* use alternate decompression library */
_PAGESIZE = getpagesize();
}
/*
* Attempt to dlopen the decompression library and locate the symbols of
* interest that we will need to call. This information in cached so
* that multiple calls to ctf_bufopen() do not need to reopen the library.
*/
void *
{
}
}
/*
* which we then patch through to the functions in the decompression library.
*/
int
{
}
const char *
{
}
/*
* Convert a 32-bit ELF file header into GElf.
*/
static void
{
}
/*
* Convert a 32-bit ELF section header into GElf.
*/
static void
{
}
/*
* In order to mmap a section from the ELF file, we must round down sh_offset
* to the previous page boundary, and mmap the surrounding page. We store
* the pointer to the start of the actual section data back into sp->cts_data.
*/
const void *
{
if (base != MAP_FAILED)
return (base);
}
/*
* Since sp->cts_data has the adjusted offset, we have to again round down
* to get the actual mmap address and round up to get the size.
*/
void
{
}
/*
* Open the specified file descriptor and return a pointer to a CTF container.
* The file can be either an ELF file or raw CTF file. The caller is
* responsible for closing the file descriptor when it is no longer needed.
*/
{
union {
} hdr;
/*
* If we have read enough bytes to form a CTF header and the magic
* string matches, attempt to interpret the file as raw CTF.
*/
if (nbytes >= sizeof (ctf_preamble_t) &&
MAP_PRIVATE, fd, 0);
ctfsect.cts_offset = 0;
return (fp);
}
/*
* If we have read enough bytes to form an ELF header and the magic
* string matches, attempt to interpret the file as an ELF file. We
* do our own largefile ELF processing, and convert everything to
* GElf structures so that clients can operate on any data model.
*/
if (nbytes >= sizeof (Elf32_Ehdr) &&
#ifdef _BIG_ENDIAN
#else
#endif
void *strs_map;
const char *strs;
} else {
}
/* Extended ELF sections */
return (ctf_set_open_errno(errp,
errno));
} else {
return (ctf_set_open_errno(errp,
errno));
}
}
/*
* Read in and convert to GElf the array of Shdr structures
* from e_shoff so we can locate sections of interest.
*/
}
for (i = 0; i < shnum; i++)
}
/*
* Now mmap the section header strings section so that we can
* perform string comparison on the section names.
*/
if (strs_map == MAP_FAILED) {
}
/*
* Iterate over the section header array looking for the CTF
* section and symbol table. The strtab is linked to symtab.
*/
for (i = 0; i < shnum; i++) {
continue; /* corrupt sh_link field */
continue; /* corrupt sh_name field */
}
}
}
/*
* Now mmap the CTF data, symtab, and strtab sections and
* call ctf_bufopen() to do the rest of the work.
*/
}
goto bad; /* unmap all and abort */
}
} else
bad:
} else
return (fp);
}
}
/*
* Open the specified file and return a pointer to a CTF container. The file
* can be either an ELF file or raw CTF file. This is just a convenient
* wrapper around ctf_fdopen() for callers.
*/
{
int fd;
return (NULL);
}
return (fp);
}
/*
* Write the uncompressed CTF data stream to the specified file descriptor.
* This is useful for saving the results of dynamic CTF containers.
*/
int
{
while (resid != 0) {
}
return (0);
}
/*
* Set the CTF library client version to the specified version. If version is
* zero, we just return the default library version number.
*/
int
{
if (version < 0) {
return (-1);
}
if (version > 0) {
if (version > CTF_VERSION) {
return (-1);
}
}
return (_libctf_version);
}