 |
Index for Section 3 |
|
 |
Alphabetical listing for S |
|
 |
Bottom of page |
|
st_dyn_start(3)
NAME
st_dyn_start, st_dyn_next, st_dyn_count, st_dyn_find_tag, st_dyn_tag,
st_dyn_value, st_dyn_addr - Access routines for dynamic header information
in shared objects
SYNOPSIS
#include <st.h>
st_status_t st_dyn_start(
st_obj_t *obj,
st_dynscn_t *pdyn );
st_status_t st_dyn_next(
st_obj_t *obj,
st_dynscn_t dcur,
st_dynscn_t *pdyn );
st_status_t st_dyn_count(
st_obj_t *obj,
unsigned int *pcount );
st_status_t st_dyn_find_tag(
st_obj_t *obj,
unsigned int tag,
st_dynscn_t *pdyn );
st_status_t st_dyn_tag(
st_obj_t *obj,
st_dynscn_t dyn,
unsigned int *ptag );
st_status_t st_dyn_value(
st_obj_t *obj,
st_dynscn_t dyn,
unsigned long *pvalue );
st_status_t st_dyn_addr(
st_obj_t *obj,
st_dynscn_t dyn,
st_addr_t *addr );
LIBRARY
Symbol Table and Object File Access Library (libst.a)
PARAMETERS
obj Specifies an object handle, as returned by the st_obj_open() function.
pdyn
Specifies an address to which st_dyn_start(), st_dyn_next(), or
st_dyn_find_tag() return a dynamic section handle.
dcur
Specifies a dynamic section handle as returned by st_dyn_start(),
st_dyn_next(), or st_dyn_find_tag() functions.
pcount
Specifies an address to which st_dyn_count() returns the number of
entries in the dynamic section.
ptag
Specifies an address to which st_dyn_tag() returns a dynamic section
tag.
tag Specifies a dynamic section tag. Dynamic section tags are defined in
/usr/include/coff_dyn.h. The Object File/Symbol Table Format
Specification provides a complete description of all dynamic section
tags.
pvalue
Specifies an address to which st_dyn_value() returns a dynamic section
value. Dynamic section values may be either link-time addresses or
absolute values. The dynamic section tag determines how the associated
dynamic section value should be interpreted. The Object File/Symbol
Table Format Specification identifies value interpretations for all
dynamic section tags.
paddr
Specifies an address to which st_dyn_addr() returns a pointer to the
data addressed by a dynamic section entry.
DESCRIPTION
These functions are used to read dynamic section entries in an object file.
The dynamic section is an array of tag and value pairs providing
information that is used to navigate and interpret additional dynamic load
information contained in the object file. The dynamic section entries and
other dynamic load information are described in the Object File/Symbol
Table Format Specification. This document provides a complete list of
dynamic section tags and describes how each tag's corresponding value
should be interpreted.
st_dyn_start and st_dyn_next
Used to iterate over all of the dynamic section entries. These
functions return an opaque dynamic section handle to the pdyn
parameter. You can use this handle as an input argument in subsequent
calls to other dynamic section access functions. (To indicate that the
iteration over the dynamic sections has been completed, st_dyn_next()
returns NULL to the pdyn parameter.)
st_dyn_count
This function returns the number of entries in the specified object's
dynamic section to the pcount parameter.
st_dyn_find_tag
Used to locate a dynamic section entry with a specific tag. This
function returns an opaque dynamic section handle to the pdyn
parameter. (To indicate that no matching dynamic section entry was
found, st_dyn_find_tag() returns NULL to the pdyn parameter.)
st_dyn_tag and st_dyn_value
Used to read the components of a dynamic section entry. The
st_dyn_tag() function returns the dynamic section entry tag to the ptag
parameter. The st_dyn_value() function returns the dynamic section
entry value to the pvalue parameter. The dynamic section entry value
may be a constant or a link-time address, or it may be unused.
st_dyn_addr
If the specified dynamic section entry's value is a link-time address,
this function returns a corresponding buffer pointer to the addr
parameter. Otherwise, NULL is returned to the addr parameter. The
buffer pointer can be used to access the file data that is referenced
by the dynamic section entry. The format of the data is determined by
the dynamic section entry tag.
RETURN VALUES
All functions indicate success by returning a value of 0 (zero). A positive
return value is an errno value from a system call. A negative return value
is a library error or informational code. The library codes are documented
in st.h.
Return parameters are set to 0 when an error occurs. An exception to this
is the case in which an invalid input parameter is passed. In such cases,
the return parameters will be unchanged. A non-zero return status is the
recommended method for detecting an error return from a libst function.
EXAMPLES
The following program illustrates how to use libst routines to read dynamic
section data. This sample program shows an algorithm for reading and
displaying shared library dependency information.
This example has been simplified for illustration purposes. Return status
should be tested after each function call. See st_strerror(3) for an
example of return status testing.
#include "st.h"
#include "coff_dyn.h"
main(int argc, char **argv){
st_status_t s; /* error status */
st_obj_t *obj; /* object handle */
st_dynscn_t pdyn; /* dynamic entry */
Coff_Lib *llib; /* library list */
int llibno; /* # of libraries */
char *dynstr; /* dynamic strings */
unsigned long val;
unsigned long addr;
int i;
s = st_obj_open(&obj, argv[1], ST_RDONLY);
/* Find dynamic section entry for the list of
* shared library dependencies.
*/
s = st_dyn_find_tag(obj, DT_LIBLIST, &pdyn);
if (!pdyn) {
printf("%s has no shared library dependencies\n",
argv[1]);
exit(0);
}
/* Get a pointer to the list of shared library
* dependencies.
*/
st_dyn_addr(obj, pdyn, &addr);
llib = (Coff_Lib *)addr;
/* Get the number of entries in the list. */
st_dyn_find_tag(obj, DT_LIBLISTNO, &pdyn);
st_dyn_value(obj, pdyn, &val);
llibno = val;
/* Get a pointer to the dynamic string table. */
st_dyn_find_tag(obj, DT_STRTAB, &pdyn);
st_dyn_addr(obj, pdyn, &addr);
dynstr = (char *)addr;
/* Print out the library dependency names. */
for (i = 0; i < llibno; i++) {
printf("%s\n", &dynstr[llib[i].l_name]);
}
}
FILES
/usr/include/st.h
Header file that contains all definitions and function prototypes for
libst.a functions
/usr/include/coff_dyn.h
Header file that contains definitions for dynamic section tag values
SEE ALSO
Functions: libst_intro(3), st_obj_open(3), st_str_error(3)
Programmer's Guide: Use a web browser such as netscape(1) to access the
Developers' Toolkit Supplement edition of the Programmer's Guide at
file:/usr/share/doclib/dtk/guide/index.html
 |
Index for Section 3 |
|
 |
Alphabetical listing for S |
|
 |
Top of page |
|