objfs_data.c revision da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0
/*
* 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 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <sys/objfs_impl.h>
#include <sys/sysmacros.h>
#include <sys/vfs_opreg.h>
/*
*
* This is an ELF file that contains information about data stored in the
* kernel. We use a special ELF file type, ET_SUNWPSEUDO, so that we can
* control which fields and sections have meaning. The file contains the
* following sections:
*
* .shstrtab Section header string table
* .SUNW_ctf CTF data
* .symtab Symbol table
* .strtab String table
* .text Text
* .data Data
* .bss BSS
* .filename Filename of module
* .info Private module info structure
*
* The .text, .data, and .bss sections are all marked SHT_NOBITS, and the data
* is not actually exported in the file for security reasons. The section
* headers do contain the address and size of the sections, which is needed by
* DTrace. The CTF data, symbol table, and string table are present only if
* they exist in the kernel.
*/
typedef enum {
} sect_type_t;
typedef struct section_desc {
const char *sect_name;
int sect_type;
int sect_flags;
int sect_link;
int sect_entsize;
int sect_align;
/*
* For data sections, 'addr' and 'size' refer to offsets within the module
* structure where we can find the address and size of the section.
*/
/*
* The dummy section is the initial section of the file. It is put into this
* array only for convenience when reading the file.
*/
/*
* The size of the symbol table and string table are not immediately available
* as an offset into the module struct, so we have to create individual types
* for each.
*/
#ifdef _LP64
#else
#endif
flags, 0, 0, 0, 1 }
/*
* The .shstrtab section is constructed when the module is first loaded.
*/
/*
* Generic module information (objfs_info_t)
*/
#define SECT_INFO \
sizeof (uint32_t) }
/*
* Filename section.
*/
#define SECT_FILENAME \
static section_desc_t data_sections[] = {
SECT_SHSTRTAB(".shstrtab",
SHT_PROGBITS, 0, sizeof (uint64_t)),
};
#define NSECTIONS \
(sizeof (data_sections) / sizeof (section_desc_t))
#ifdef _LP64
#define SECTION_OFFSET(section) \
#else
#define SECTION_OFFSET(section) \
#endif
/*
* Given a data node, returns the struct module appropriately locked. If the
* object has been unloaded, or re-loaded since the file was first opened, this
* function will return NULL. If successful, the caller must call
* objfs_data_unlock().
*/
struct module *
{
return (NULL);
}
}
void
{
}
/*
* Called when the filesystem is first loaded. Creates and initializes the
* section header string table, and fills in the sect_str members of the section
* descriptors. This information could be encoded at compile-time, but this
* way keeps the code more maintainable, as we don't have to worry about
* duplicating information.
*/
void
objfs_data_init(void)
{
char *strdata;
for (i = 0; i < NSECTIONS; i++) {
sect = &data_sections[i];
shstrtab = i;
symtab = i;
strtab = i;
}
len = 0;
for (i = 0; i < NSECTIONS; i++) {
sect = &data_sections[i];
}
}
/*
* Given a section descriptor and module pointer, return the address of the
* data.
*/
static uintptr_t
{
case SECT_TYPE_DUMMY:
addr = 0;
break;
case SECT_TYPE_SHSTRTAB:
break;
case SECT_TYPE_STRTAB:
case SECT_TYPE_SYMTAB:
case SECT_TYPE_DATA:
break;
case SECT_TYPE_FILENAME:
break;
case SECT_TYPE_INFO:
break;
}
return (addr);
}
/*
* Given a section descriptor and module pointer, return the size of the data.
*/
static size_t
{
case SECT_TYPE_DUMMY:
size = 0;
break;
case SECT_TYPE_SHSTRTAB:
break;
case SECT_TYPE_DATA:
break;
case SECT_TYPE_SYMTAB:
break;
case SECT_TYPE_STRTAB:
break;
case SECT_TYPE_INFO:
size = sizeof (objfs_info_t);
break;
case SECT_TYPE_FILENAME:
size = 0;
else
}
return (size);
}
/*
* Given a section descriptor and module pointer, return 1 if the section has
* valid data and should be included, 0 otherwise.
*/
static int
{
return (1);
return (0);
}
/*
* Given a section descriptor and module pointer, return the offset into the
* file where the data should be placed.
*/
static size_t
{
int i;
return (0);
#ifdef _LP64
len = sizeof (Elf64_Ehdr);
#else
len = sizeof (Elf32_Ehdr);
#endif
/*
* Do a first pass to account for all the section headers.
*/
for (i = 0; i < NSECTIONS; i++) {
#ifdef _LP64
len += sizeof (Elf64_Shdr);
#else
len += sizeof (Elf32_Shdr);
#endif
}
}
/*
* Add length of each section until we find the one we're looking for.
*/
for (i = 0; i < NSECTIONS; i++) {
cp = &data_sections[i];
/*
* Align the section only if it's valid and contains data. When
* searching for a specific section, align the section before
* breaking out of the loop.
*/
}
break;
}
return (len);
}
/*
* Given an index into the section table and a module pointer, returns the
* data offset of the next section.
*/
static size_t
{
int i;
}
}
/*
* Given a module pointer, return the total size needed for the file.
*/
static size_t
{
}
/*
* Returns the size needed for all the headers in the file.
*/
static size_t
header_size(void)
{
}
/* ARGSUSED */
vnode_t *
{
return (vp);
}
/* ARGSUSED */
static int
{
return (EIO);
gethrestime(&now);
return (0);
}
/* ARGSUSED */
static int
{
return (EACCES);
return (0);
}
/* ARGSUSED */
int
{
return (EINVAL);
return (0);
}
/*
* Iterate over all symbols in the table and output each one individually,
* converting st_shndx to SHN_ABS for each symbol.
*/
static int
{
#ifdef _LP64
#else
#endif
int error;
/*
* Be careful with the first symbol, as it is not
* symbol-aligned.
*/
return (error);
}
index++) {
return (error);
}
return (0);
}
/* ARGSUSED */
static int
{
int error = 0;
#ifdef _LP64
#else
#endif
int i, j;
void *addr;
return (ENOENT);
goto error;
/*
* Construct an array to translate from a generic section header index
* to an index specific for this object.
*/
for (i = 0, j = 0; i < NSECTIONS; i++) {
transidx[i] = j;
j++;
}
/*
* Check to see if we're in the Elf header
*/
#ifdef _LP64
#else
#endif
#ifdef _BIG_ENDIAN
#else
#endif
#ifdef _LP64
#else
#endif
#ifdef __sparc
#ifdef __sparcv9
#else
#endif
#else
#endif
for (i = 0; i < NSECTIONS; i++) {
".shstrtab") == 0)
}
goto error;
}
/*
* Go through and construct section headers for each section.
*/
j = 0;
for (i = 0; i < NSECTIONS; i++) {
sp = &data_sections[i];
continue;
goto error;
}
j++;
}
/*
* Output the data for each section
*/
for (i = 0; i < NSECTIONS; i++) {
sp = &data_sections[i];
else
/*
* The symtab requires special processing to convert
* the st_shndx field to SHN_ABS. Otherwise, simply
* copy the data in bulk.
*/
else
goto error;
/*
* If the next section needs to be aligned, pad out with
* zeroes.
*/
sizeof (uint64_t));
goto error;
}
}
}
return (error);
}
/* ARGSUSED */
static int
{
return (0);
}
const fs_operation_def_t objfs_tops_data[] = {
{ NULL }
};