Scroll to navigation

GETAUXVAL(3) Linux Programmer's Manual GETAUXVAL(3)

名前

getauxval - 補助ベクトルから値を取得する

書式

#include <sys/auxv.h>
unsigned long getauxval(unsigned long type);

説明

getauxval() 関数は補助ベクトル (auxiliary vector) から値を取得する。 補助ベクトルは、 プログラムが実行される際に、 カーネルの ELF バイナリーローダーがユーザー空間にある種の情報を渡すのに使われる仕組みである。

補助ベクトルの各エントリーは、 このエントリーを示すタイプとそのタイプの値のペアで構成される。 引数 type が指定されると、 getauxval() は対応する値を返す。

それぞれの type に対して返される値の詳細を以下に示す。 すべてのアーキテクチャーですべて type 値が存在するわけではない。

プログラムインタープリター (通常は動的ローダー) のベースアドレス。
A pointer to a string (PowerPC and MIPS only). On PowerPC, this identifies the real platform; may differ from AT_PLATFORM. On MIPS, this identifies the ISA level (since Linux 5.7).
times(2) のカウントが行われる周波数。 この値は sysconf(_SC_CLK_TCK) でも取得できる。
データキャッシュのブロックサイズ。
このスレッドの実効グループ ID。
実行ファイルのエントリーアドレス。
このスレッドの実効ユーザー ID。
プログラムのファイルディスクリプター。
A pointer to a string containing the pathname used to execute the program.
フラグ (未使用)。
使用された FPU 制御ワード (SuperH アーキテクチャーのみ)。 カーネルが実行した FPU 初期化に関する情報を提供するためのものである。
このスレッドの実グループ ID。
An architecture and ABI dependent bit-mask whose settings indicate detailed processor capabilities. The contents of the bit mask are hardware dependent (for example, see the kernel source file arch/x86/include/asm/cpufeature.h for details relating to the Intel x86 architecture; the value returned is the first 32-bit word of the array described there). A human-readable version of the same information is available via /proc/cpuinfo.
Further machine-dependent hints about processor capabilities.
命令キャッシュのブロックサイズ。
Geometry of the L1 data cache, encoded with the cache line size in bytes in the bottom 16 bits and the cache associativity in the next 16 bits. The associativity is such that if N is the 16-bit value, the cache is N-way set associative.
L1 データキャッシュのサイズ。
Geometry of the L1 instruction cache, encoded as for AT_L1D_CACHEGEOMETRY.
L1 命令キャッシュのサイズ。
Geometry of the L2 cache, encoded as for AT_L1D_CACHEGEOMETRY.
L2 キャッシュのサイズ。
Geometry of the L3 cache, encoded as for AT_L1D_CACHEGEOMETRY.
L3 キャッシュのサイズ。
システムページサイズ (sysconf(_SC_PAGESIZE) が返す値と同じ)。
実行プログラムのプログラムヘッダーのアドレス。
プログラムヘッダーエントリーのサイズ。
プログラムヘッダー数。
このプログラムが実行されているハードウェアプラットフォームを特定する文字列へのポインター。 動的リンカーは rpath 値の解釈を行う際にこの値を使用する。
ランダム値が入った 16 バイトがあるアドレス。
Has a nonzero value if this executable should be treated securely. Most commonly, a nonzero value indicates that the process is executing a set-user-ID or set-group-ID binary (so that its real and effective UIDs or GIDs differ from one another), or that it gained capabilities by executing a binary file that has capabilities (see capabilities(7)). Alternatively, a nonzero value may be triggered by a Linux Security Module. When this value is nonzero, the dynamic linker disables the use of certain environment variables (see ld-linux.so(8)) and glibc changes other aspects of its behavior. (See also secure_getenv(3).)
vDSO のシステムコール関数へのエントリーポイント。すべてのアーキテクチャーで存在するわけではなく、 また必要というわけでもない (例えば x86-64 には存在しない)。
仮想動的共有オブジェクト (vDSO; virtual Dynamic Shared Object) が入ったページのアドレス。 vDSO は、 特定のシステムコールの高速な実装を提供するためにカーネルが作成する共有オブジェクトである。
ユニファイド (unified) キャッシュのブロックサイズ。
このスレッドの実ユーザー ID。

返り値

成功すると、 getauxval() は type に対応する値を返す。 type が見つからない場合には 0 を返す。

エラー

type に対応するエントリーが補助ベクトルになかった。

バージョン

getauxval() 関数は glibc バージョン 2.16 で追加された。

属性

この節で使用されている用語の説明については、 attributes(7) を参照。

インターフェース 属性
getauxval() Thread safety MT-Safe

準拠

この関数は非標準で glibc による拡張である。

注意

補助ベクトルの情報を主に使用するのは、 動的ローダー ld-linux.so(8) である。 補助ベクトルは、 カーネルが動的リンカーが通常もしくは常に必要とするある意味標準的な情報を伝えるための便利で効率的なショートカットである。 いくつかの場合では、 同じ情報がシステムコール経由でも取得できるが、 補助ベクトルを使う方がコストがかからない。

補助ベクトルには、 単に、 プロセスのアドレス空間の引数リストと環境上に存在するだけである。 プログラム実行時に LD_SHOW_AUXV 環境変数を設定すると、 プログラムに渡された補助ベクトルを表示することができる。


$ LD_SHOW_AUXV=1 sleep 1

任意のプロセスの補助ベクトルは (ファイルのアクセス許可があれば) /proc/[pid]/auxv 経由で取得できる。 詳細は proc(5) を参照。

バグ

glibc 2.19 で ENOENT エラーが追加される前は、 type が見つからなかった場合と type に対応する値が 0 だった場合を明確に区別する方法がなかった。

関連項目

secure_getenv(3), vdso(7), ld-linux.so(8)

この文書について

この man ページは Linux man-pages プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は https://www.kernel.org/doc/man-pages/ に書かれている。

2020-06-09 GNU