問題タブ [got]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
cmake - valgrindでGOTの「無効な読み取り」警告を抑制する方法は?
単体テストの一環として valgrind memcheck を実行しています。Valgrind は、特定のテスト ビューに対して「サイズ 8 の無効な読み取り」を発行し、プロセスの GOT (グローバル オフセット テーブル) を変更します。できれば GOT だけに対してこの警告を抑制したいと思います (つまり、他の「無効な読み取り」警告を発行する必要があります)。valgrind 抑制ファイルを定義せずにこれを行う方法はありますか? 引数の一部として、CMake/CTest 経由で valgrind に渡すことができますか?
c++ - 共有ライブラリ自体で定義されたシンボルにグローバル オフセット テーブルを使用するのはなぜですか?
次の単純な共有ライブラリ ソース コードを考えてみましょう。
ライブラリ.cpp:
-fPIC
clangでオプションを指定してコンパイルすると、次のオブジェクト アセンブリが生成されます (x86-64):
シンボルはライブラリ内で定義されているため、コンパイラは予想どおり PC 相対アドレッシングを使用しています。mov eax, dword ptr [rip + global]
ただし、外部リンケージを持つシンボルに変更static int global = 10;
すると、結果のアセンブリは次のようになります。int global = 10;
ご覧のとおり、コンパイラはグローバル オフセット テーブルを使用して間接レイヤーを追加しました。これは、シンボルが同じライブラリ (およびソース ファイル) 内で定義されているため、この場合はまったく不要に思えます。
シンボルが別の共有ライブラリで定義されている場合、GOT が必要になりますが、この場合は冗長に感じられます。コンパイラがまだこのシンボルを GOT に追加しているのはなぜですか?
注:この質問はこれに似ていると思いますが、詳細が不足しているため、回答は適切ではありませんでした.
elf - About the necessity of GOT & PLT structures in ELF header
In some architectures (like x86_64) where it's possible to reference data (mov e.g.) and code (jmp, call) using PC(RIP)-relative addressing mode, is there really a technical reason justifying the need of such structures (got, plt) ?
I mean, if I want to mov a global data (for instance) to a register, I could make the following instruction (standard PIE) :
mov rax,QWORD PTR [rip+0x2009db]
mov eax,DWORD PTR [rax]
(where 0x2009db is the offset between rip and the right entry in the got containing the symbol address)
And why couldn't we do something like that :
mov rax, rip+0xYYYYYY
mov eax,DWORD PTR [rax]
(0xYYYYYYY being the direct delta between the RIP value and the symbol (a global variable e.g.))
I'm not used to do ASM, so my example is perhaps false. But my idea is : why not just simply compute the absolute address of the symbol based on RIP, put it in EAX, and then access its content. If the instruction set allows to do whatever we want with relative addressing, why use such structures (got, plt) ?
The same question would apply for call/jmp instructions.
Is it because the instruction set does not allow it ? Is it because the offset value cannot cover the entire address space ? But.. is it important ? Since the structure of a section is maintained one mapped into the virtual addressing space of a process (e.g. .dat section followed by .got or something like). I mean, why would the offset be bigger in referring directly to the symbol address instead of the entry address in the got ? Other reason ?
Thanks !
c++ - グローバルオフセットテーブルを埋める方法は?
動機:
アーチ (x86) でグローバル オフセット テーブルの gcc の制限サイズをテストしたいと考えています。
私がやった事:
共有ライブラリで宣言されていない複数の関数を使用する ( gcc -nostdlib -shared -o got.so ./got.c
)
とreadelf --relocs ./got.so
:
上記のように、グローバル オフセット テーブルは で埋められてfun1-8
いますが、制限サイズに達するには十分ではありません。次の 2 つの方法が考えられます。
- これらのようなより多くの関数を生成するには、emacs のような適切なエディターを使用してください
- 適切な codegen を使用して、マクロのように前処理時にそのようなコードを生成します (ただし、マクロで解決策を見つけることができません)
もちろん、この目標を達成する方法は他にもあるかもしれません。
質問:
グローバル オフセット テーブルの制限に到達するにはどうすればよいですか?