common object file access routines
The common object file access routines are a collection of functions
for reading common object files and archives
containing common object files.
Although the calling program must know the detailed structure of the
parts of the object file that it processes,
the routines insulate the calling program
from knowledge of the overall structure of the object file.
The interface between the calling program and the object file access
routines is based on the defined type LDFILE,
defined as struct ldfile,
declared in the ldfcn.h header file.
This structure provides uniform access to
both simple object files and object files that are members of an
function allocates and initializes
the LDFILE structure
and returns a pointer to the structure to the calling program.
The members of the LDFILE structure
can be accessed individually
through macros defined in ldfcn.h
and contain the following information:
The file magic number used to distinguish between archive members and simple
The file pointer returned by fopen and used
by the standard input/output functions
The file address of the beginning of the object file;
the offset is non-zero if the object file is a member of an archive file.
The file header structure of the object file
The object file access functions themselves can be divided into
the following categories:
functions that open or close an object file:
and ldaopen open a common object file
and ldaclose close a common object file
functions that read header or symbol table information:
reads the archive header of a member of an archive file
reads the file header of a common object file
and ldnshread read a section header of a
common object file
reads a symbol table entry of a common object file
retrieves a symbol name from a symbol table entry or from the string table
functions that position an object file at (seek to)
the start of the section, relocation,
or line number information for a particular section:
seeks to the optional file header of a common object file
seek to a section of a common object file
and ldnrseek seek to the relocation information for
a section of a common object file
and ldnlseek seek to the line number information for
a section of a common object file
seeks to the symbol table of a common object file
the function ldtbindex(S)
which returns the index of a particular common object
file symbol table entry.
These functions are described in detail on their respective manual pages.
All the functions except
return either SUCCESS or FAILURE,
both constants defined in ldfcn.h.
and ldaopen both return pointers to an
Additional access to an object file is provided through a set of macros
defined in ldfcn.h.
They parallel the standard
input/output file reading and manipulating functions,
translating a reference of the LDFILE
structure into a reference to its file descriptor field.
The following macros are provided:
FGETS(s, n, ldptr)
FREAD((char ) ptr, sizeof (ptr), nitems, ldptr)
FSEEK(ldptr, offset, ptrname)
macro calculates the address of the string table.
See the manual entries for the corresponding standard input/output library
functions for details on the use of the rest of the macros.
The program must be loaded with the object file access library routine
The macro FSEEK defined in the header file
ldfcn.h translates into a call to the standard input/output function
FSEEK should not be used to seek from the end of
an archive file,
since the end of an archive file might not be the same as the end of one of
its object file members.
is not part of any
currently supported standard;
it was developed by UNIX System Laboratories, Inc.
and is maintained by The SCO Group.
© 2003 File Formats for Programming (FP)
SCO OpenServer Release 5.0.7 -- 11 February 2003