uselibのヘルプ・マニュアル
日本語 英語
uselib --help
man uselib
USELIB(2) Linux Programmer’s Manual USELIB(2)
名前
uselib - 共有ライブラリを選択する
書式
#include
int uselib(const char *library);
説明
シ ステムコール uselib() は、呼び出し元プロセスが使用する共有ライブラリ
をロードする際に使用される。このシステムコールにはライブラリのパス名 を
指 定する。ライブラリをロードするアドレスはライブラリ自身に書かれている
。ライブラリは認識可能なバイナリ形式であればどんな形式でもよい。
返り値
成功した場合 0 を返す。失敗した場合 -1 を返し、 errno をエラーの内容 に
従って設定する。
エラー
open(2) と mmap(2) が返すエラーコードに加えて、以下のエラーコードが設定
されることがある。
EACCES library で指定されたライブラリに対する読み込み許可、または実行許
可 がない。もしくは library が存在するディレクトリかその上位のい
ずれかに対する検索許可がない (path_resolution(7) も参照)。
ENFILE オープンされたファイルの総数がシステム全体の上限に達した。
ENOEXEC
library で指定されたファイルが、実行可能ファイルと認識されるファ
イル種別ではない、つまり正しいマジック・ナンバーが付いていない。
準拠
uselib() は Linux 特有の関数であり、移植性を持たせたいプログラムには 使
用すべきでない。
注意
初 期の libc の起動コードは、 uselib() を使って、バイナリ中のリストに書
かれている共有ライブラリをリスト中のそのままの名前でロードしていた。
libc 4.3.2 以降では、これらの名前の前に "/usr/lib", "/lib", "" をつけて
共 有ライブラリを探すようになった。 libc 4.3.4 以降では、これらの名前の
共有ライブラリをまず LD_LIBRARY_PATH で指定されたディレクトリで探し、見
つからなければ、名前の前に "/usr/lib", "/lib", "/" をつけて探す。
libc 4.4.4 以降では、ライブラリ "/lib/ld.so" だけがロードされ、その後で
この動的ライブラリが (このシステムコールをもう一度使って) 必要な残り の
ライブラリをロードできるようになっている。
glibc2 は、このシステムコールを使用しない。
関連項目
ar(1), gcc(1), ld(1), ldd(1), mmap(2), open(2), dlopen(3), capabili-
ties(7), ld.so(8)
Linux 2005-01-09 USELIB(2)
USELIB(2) Linux Programmer’s Manual USELIB(2)
NAME
uselib - load shared library
SYNOPSIS
#include
int uselib(const char *library);
DESCRIPTION
The system call uselib() serves to load a shared library to be used by
the calling process. It is given a pathname. The address where to
load is found in the library itself. The library can have any recog-
nized binary format.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is
set appropriately.
ERRORS
In addition to all of the error codes returned by open(2) and mmap(2),
the following may also be returned:
EACCES The library specified by library does not have read or execute
permission, or the caller does not have search permission for
one of the directories in the path prefix. (See also path_reso-
lution(7).)
ENFILE The system limit on the total number of open files has been
reached.
ENOEXEC
The file specified by library is not an executable of known
type, e.g., does not have the correct magic numbers.
CONFORMING TO
uselib() is Linux-specific, and should not be used in programs intended
to be portable.
NOTES
uselib() was used by early libc startup code to load the shared
libraries with names found in an array of names in the binary.
Since libc 4.3.2, startup code tries to prefix these names with
"/usr/lib", "/lib" and "" before giving up. In libc 4.3.4 and later
these names are looked for in the directories found in LD_LIBRARY_PATH,
and if not found there, prefixes "/usr/lib", "/lib" and "/" are tried.
From libc 4.4.4 on only the library "/lib/ld.so" is loaded, so that
this dynamic library can load the remaining libraries needed (again
using this call). This is also the state of affairs in libc5.
glibc2 does not use this call.
SEE ALSO
ar(1), gcc(1), ld(1), ldd(1), mmap(2), open(2), dlopen(3), capabili-
ties(7), ld.so(8)
COLOPHON
This page is part of release 3.22 of the Linux man-pages project. A
description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2005-01-09 USELIB(2)