MKSHLIB(1-SysV) RISC/os Reference Manual MKSHLIB(1-SysV)
NAME
mkshlib - create a shared library
SYNOPSIS
mkshlib -s specfil [-t target] [-h host] [-n] [-q] [-v]
DESCRIPTION
The mkshlib command builds both the host and target shared
libraries. A shared library is similar in function to a
normal, non-shared library, except that programs that link
with a shared library will share the library code during
execution. Programs that link with a non-shared library will
get their own copies of each library routine used.
The host shared library is an archive that is used to link-
edit user programs with the shared library [see ar(4)]. A
host shared library can be treated exactly like a non-shared
library and should be included on compiler driver (cc(1),
etc.) command lines in the usual way. Further, all opera-
tions that can be performed on an archive can also be per-
formed on the host shared library.
The target shared library is an executable module that is
attached to the user's process during execution of a program
using the shared library. The target shared library con-
tains the code for all the routines in the library and must
be fully resolved. The target will be brought into memory
during execution of a program using the shared library, and
subsequent processes that use the shared library will share
the copy of code already in memory. The text of the target
is always shared, but each process will get its own copy of
the data.
The user interface to mkshlib consists of command line
options and a shared library specification file. The shared
library specification file describes the contents of the
shared library.
The mkshlib command invokes other tools, such as the
archiver, ar(1), the assembler, as(1), and the link editor,
ld(1). Tools are invoked through the use of execvp(3),
which searches directories in the user's PATH. Also, suf-
fixes to mkshlib are parsed in the same manner as suffixes
to the compiler drivers, and invoked tools are given the
suffix, where appropriate. For example, mkshlib1.0 will
invoke ld1.10.
The following command line options are recognized by
mkshlib:
-s specfil
Specifies the shared library specification file,
Printed 1/15/91 Page 1
MKSHLIB(1-SysV) RISC/os Reference Manual MKSHLIB(1-SysV)
specfil. This file contains the information neces-
sary to build a shared library. Its contents
include the branch table specifications for the
target, the pathname in which the target should be
installed, the start addresses of text and data
for the target, the initialization specifications
for the host, and the list of object files to be
included in the shared library (see details
below).
-t target Specifies the name, target, of the target shared
library produced on the host machine. When target
is moved to the target machine, it should be
installed at the location given in the specifica-
tion file (see the #target directive below). If
the -n option is used, a new target shared library
will not be generated.
-h host Specifies the name of the host shared library,
host. If this options is not given, the host
shared library will not be produced.
-n Do not generate a new target shared library. This
option is useful when producing only a new host
shared library. The -t option must still be sup-
plied since a version of the target shared library
is needed to build the host shared library.
-q Quiet warning messages. This option is useful
when warning messages are expected, but not
desired.
-v Set the verbose option. This option prints the
command lines it executes as in the compiler
drivers.
The shared library specification file contains all the
information necessary to build both the host and target
shared libraries. The contents and format of the specifica-
tion file are given by the following directives:
#address segname address
Specifies the start address, address, of the seg-
ment segname for the target. This directive is
used to specify the start addresses of the text
and data segments. Since the headers part of the
text segment of target shared libraries they are
put on there own page. The real text starts on
the next page from where the text segment is
specified.
#target pathname
Page 2 Printed 1/15/91
MKSHLIB(1-SysV) RISC/os Reference Manual MKSHLIB(1-SysV)
Specifies the absolute pathname, pathname, of the
target shared library on the target machine. This
pathname is copied to a.out files and is the loca-
tion where the operating system will look for the
shared library when executing a file that uses it.
#branch Specifies the start of the branch table specifica-
tions. The lines following this directive are
taken to be branch table specification lines.
Branch table specification lines have the follow-
ing format:
funcname < white space > position
where funcname is the name of the symbol given a
branch table entry and position specifies the
position of funcname's branch table entry. Posi-
tion may be a single integer integer or a range of
integers of the form position1-position2. Each
position must be greater than or equal to one, the
same position cannot be specified more than once,
and every position from one to the highest given
position must be accounted for.
If a symbol is given more than one branch table
entry by associating a range of positions with the
symbol or by specifying the same symbol on more
than one branch table specification line, the sym-
bol is defined to have the address of the highest
associated branch table entry. All other branch
table entries for the symbol can be thought of as
"empty" slots and can be replaced by new entries
in future versions of the shared library.
Finally, only functions should be given branch
table entries, and those functions must be exter-
nal.
This directive can be specified only once per
shared library specification file.
#objects Specifies the names of the object files constitut-
ing the target shared library. The lines follow-
ing this directive are taken to be the list of
input object files in the order they are to be
loaded into the target. The list simply consists
of each filename followed by white space. This
list is also used to determine the input object
files for the host shared library.
This directive can be specified only once per
Printed 1/15/91 Page 3
MKSHLIB(1-SysV) RISC/os Reference Manual MKSHLIB(1-SysV)
shared library specification file.
#init object
Specifies that the object file, object, requires
initialization code. The lines following this
directive are taken to be initialization specifi-
cation lines.
Initialization specification lines have the fol-
lowing format:
pimport < white space > import
Pimport is a pointer to the associated imported
symbol, import, and must be defined in the current
specified object file, object. The initialization
code generated for each such line is of the form:
pimport = &import;
where pimport is the absolute address of import.
All initializations for a particular object file
must be given at once and multiple specifications
of the same object file are not allowed.
#ident string
Specifies a string, string, to be included in the
.comment section of the target shared library.
This directive can be specified only once per
shared library specification file. This is
ignored but allowed for compatibility.
## Specifies a comment. All information on a line
following this directive is ignored.
All directives that may be followed by multi-line specifica-
tions are valid until the next directive of the end of the
file.
FILES
TEMPDIR/* temporary files
TEMPDIR is usually /tmp, but can be redefined by setting the
environment variable TMPDIR [see tempnam() in tmpnam(3S)].
SEE ALSO
ar(1), as(1), cc(1), ld(1).
a.out(4), ar(4) in the Programmer's Reference Manual.
NOTES
Page 4 Printed 1/15/91
MKSHLIB(1-SysV) RISC/os Reference Manual MKSHLIB(1-SysV)
The addresses of the text and data segments must meet the
boundary requirements of the operating system. For RISC/os
the segments must be on full-page boundaries.
Because of jump instructions on MIPS machines, all the text
making up the program should be in the same 256 megabyte
segment so that all the text can be reached by normal jumps.
It is suggested that shared library text segments be allo-
cated from the top of the first 256 megabyte segment
(0x10000000) through lower addresses. User program's text
segments would continued to be link at the bottom
(0x00400000) which is the default. This is suggested so
that maximum distance be obtained between user's text and
shared library text.
The target shared library data segments are suggested to be
allocated from where the normal default data segment is
loaded (0x10000000) through higher addresses. This will
result in the user having to load his data segment after the
target shared library he uses with the highest data segment
address. This suggestion will allow the maximum space for
the sbrk(see brk(2)) arena and the stack to grow without
interference of target shared library segments.
Printed 1/15/91 Page 5