day02b (EDK2でメモリーマップ保存?)
#ゼロからのOS自作入門
mikanos/Main.c at osbook_day02b · uchan-nos/mikanos
// #@@range_begin(main) ってなんだ?
技術書作成支援ライブラリ用らしい 便利そう
gBS→OpenProtocolの説明なくて泣いてしまった ドキュメント見てもよくわからん(とりあえず先に進むことにした)
undefined reference to 'gEfiLoadedImageProtocolGuid' が出て、すぐに原因がわからなくて大変だった
https://twitter.com/Watasuke102/status/1485145239845478404
memmapという名前のファイル自体は作成されているらしいが、中身がない
安心と信頼と伝統のPrintデバッグをしようと思ったが、Print("%s")でCHAR8*を出力できない
なんで?と思ったけど、答えはソースコードにあった
edk2/PrintLib.h at master · tianocore/edk2
%sはUnicodeで、ASCII(CHAR8)の文字列は%aで出力するらしい・・・
ちなみにこのリポジトリにたどり着いたのはここのおかげ(edk2 print format で検索したら出てきた)
EFI format string reference
ちなみに、memmapに保存されてなかった原因はファイルをクローズしていなかったから
書き込みできてないからおおよそSaveMemoryMapのせいだろうなとおもったら違った・・・(closeするのはUefiMain)
またオプションが大量に出てきてしまった
-ffreestanding
Clang 13 documentation
まあ予想通りだったけど、何らかのOS上で動かないプログラム向けであることを示すフラグっぽい?
Indicate that the file should be compiled for a freestanding, not a hosted, environment.
というかフラグはぜんぶここでいいのでは・・・?
-fno-exceptions
-fexceptionの説明がこれ
Enable generation of unwind information. This allows exceptions to be thrown through Clang compiled stack frames. This is on by default in x86-64.
unwind information??
what's mean about "compact unwind info" in linker synthesized
Unwind info is the information necessary to unwind the stack when an exception is thrown/raised. Unwinding the stack involves determining where the frame pointer, stack pointer, return address, and any saved registers were stored so state can be restored for the previous frame.
「例外が発生した時、スタックをアンワインドするための情報」「スタックポインタやリターンアドレスを復元するための情報が含まれる」らしい
-fno-rtti
RTTI(Run-Time Type Information)の無効化
名前の通り、実行時の型情報を無効化するらしい?
RTTIとは?具体的にはこんな感じらしい
'RTTI | Programming Place Plus C++編【言語解説】 第31章'
-z norelro
Ubuntu Manpage: ld.lld - ELF linker from the LLVM project
-z option
Linker option extensions.
リンカオプション??
norelro
Do not indicate that portions of the object should be mapped read-only after
initial relocation processing.
no rel (ocation) RO といったところか
読み取り専用なオブジェクトを作らないようにします!みたいな?