リンカ設定ファイル内の式
構文
式は、以下の要素で構成されます。
expressionbinopexpressionunop expressionexpression?expression:expression(expression)numbersymbolfunc-operator
binopは、以下のいずれかのバイナリ演算子です。
+, -, *, /, %, <<, >>, <, >, ==, !=, &, ^, |, &&, ||
unopは、以下のいずれかの単項演算子です。
+, -, !, ~
numberは数値です(詳細はリンカ設定ファイル内の数値を参照)。
symbolは、定義済みシンボルです。詳細については、define symbolディレクティブおよび‑‑config_defを参照してください。
func-operatorは、すべての式で使用できる以下の関数のような演算子のいずれかです。
|
|
|
|
| 領域の最上位アドレス。 |
| シンボル |
| 領域が空だとTrue ( |
| 一番大きいパラメータ。 |
| 一番小さいパラメータ。 |
| 領域のすべての範囲の合計サイズ。 |
| 共有オブジェクトが指定した出力タイプの場合はTrue ( |
| 領域の最下位アドレス。 |
alignとexprが式で、regionが領域式(Region式参照)。
Note that isdefinedsymbol allows you to probe the linker context without giving an error if something is not there. In combination with if conditions, this can lead to unexpected results. The if evaluation order specifies that any conditions that rely on isdefinedsymbol—either directly or indirectly through other symbols—are evaluated last. Specifically, all if conditions that do not rely on isdefinedsymbol and can be evaluated are processed first. Once those are complete, any remaining if conditions that do rely on isdefinedsymbol (and can otherwise be evaluated) are evaluated in the same context.
Consider this example:
if((x > 0) && !isdefinedsymbol(y))
{
define symbol z = 1;
}
if((x > 0) && !isdefinedsymbol(z))
{
define symbol y = 1;
}
if(!isdefinedsymbol(w))
{
define symbol x = 1;
} In this example, the two first conditions cannot be evaluated, because x does not have a well-defined value. The only condition that can be evaluated is !isdefinedsymbol(w), which is true, so x=1 is added to the context. Then the other two conditions—(x > 0) && !isdefinedsymbol(y) and (x > 0) && !isdefinedsymbol(z)—are evaluated in the same context. Both are true, so z=1,y=1 are added to the context.
func-operatorは、これらのオペランドの1つで、check that式のブロックやオーバレイのサイズやアライメントの式、およびdefine sectionディレクティブのデータ式でのみ利用できます。
|
|
| スレッドのローカル記憶領域のアライメント。 |
| スレッドのローカル記憶領域のサイズ。 |
説明
リンカ設定ファイルでは、式は、範囲-2^64~2^64の65ビット値です。式の構文は、いくつかの例外はありますが、C構文に従っています。代入、キャスト、前置演算、後置演算、アドレス演算(*、&、[]、->、.)はありません。領域の式から値を抽出する処理など、いくつかの処理では、関数呼び出しに似た構文が使用されます。ブール値式は、0(偽)または1(真)を返します。