Open3
`.debug_gnu_pubnames` と `.debug_gnu_pubtypes` を何とかしたい
とりあえずWebKitのCygwin + Clangビルドに戻る。ビルド時にエラーにならないものの謎の警告が出ていることに気付いた:
[354/10321] Linking CXX executable bin/LLIntSettingsExtractor.exe
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: bin/LLIntSettingsExtractor.exe:/4: section below image base
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: bin/LLIntSettingsExtractor.exe:/24: section below image base
7-zipで .exe
を開いてみると、確かに仮想アドレスが変なエントリが存在する。
objdump -h
でセクションヘッダを確認してみると、これは .debug_gnu_pubnames
と .debug_gnu_pubtypes
のようで、これらはたぶんCygwinのgccでは生成されないのではぐれてしまったのだろう。
LLIntSettingsExtractor.exe: file format pei-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .debug_gnu_pubnames 00002cbe 0000000200000000 0000000200000000 000004f8 2**0
CONTENTS, READONLY, DEBUGGING
1 .debug_gnu_pubtypes 00000b64 0000000200000000 0000000200000000 000032f8 2**0
CONTENTS, READONLY, DEBUGGING
2 .text 001dcac0 0000000100401000 0000000100401000 00004000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
そもそもDWARF32だと足りないのでDWARF2を使っている
WebKitをビルドしたときに生成されるデバッグ情報はでかすぎるので、 -gdwarf-2 -g1
を指定してDWARF2、かつ、ローカル変数情報なしにしている。そうしないとリンク時にエラーが出てしまう。。
/cygdrive/f/webkit/llvm/bin/clang++ -fdiagnostics-color=always -fcolor-diagnostics -Wextra -Wall -pipe -Wno-noexcept-type -Wno-psabi -Wno-misleading-indentation -Wno-parentheses-equality -Qunused-arguments -Wwrite-strings -Wundef -Wpointer-arith -Wmissing-format-attribute -Wformat-security -Wcast-align -Wno-tautological-compare -femulated-tls -fno-strict-aliasing -fno-exceptions -fno-rtti -gsplit-dwarf -g -g1 -Wl,--enable-auto-import @CMakeFiles/LLIntSettingsExtractor.rsp -o bin/LLIntSettingsExtractor.exe -Wl,--out-implib,lib/libLLIntSettingsExtractor.dll.a -Wl,--major-image-version,0,--minor-image-version,0 && :
Source/JavaScriptCore/CMakeFiles/LLIntSettingsExtractor.dir/llint/LLIntSettingsExtractor.cpp.o:LLIntSettingsExtra:(.debug_line+0x22): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/JavaScriptCore/CMakeFiles/LLIntSettingsExtractor.dir/llint/LLIntSettingsExtractor.cpp.o:LLIntSettingsExtra:(.debug_line+0x26): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/JavaScriptCore/CMakeFiles/LLIntSettingsExtractor.dir/llint/LLIntSettingsExtractor.cpp.o:LLIntSettingsExtra:(.debug_line+0x32): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/JavaScriptCore/CMakeFiles/LLIntSettingsExtractor.dir/llint/LLIntSettingsExtractor.cpp.o:LLIntSettingsExtra:(.debug_line+0x47): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: DWARF error: invalid or unhandled FORM value: 0x23
Source/WTF/wtf/CMakeFiles/WTF.dir/./ApproximateTime.cpp.o:ApproximateTime.cp:(.debug_line+0x22): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/WTF/wtf/CMakeFiles/WTF.dir/./ApproximateTime.cpp.o:ApproximateTime.cp:(.debug_line+0x26): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/WTF/wtf/CMakeFiles/WTF.dir/./ApproximateTime.cpp.o:ApproximateTime.cp:(.debug_line+0x32): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/WTF/wtf/CMakeFiles/WTF.dir/./ApproximateTime.cpp.o:ApproximateTime.cp:(.debug_line+0x47): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/WTF/wtf/CMakeFiles/WTF.dir/./ApproximateTime.cpp.o:ApproximateTime.cp:(.debug_line+0x5c): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/WTF/wtf/CMakeFiles/WTF.dir/./ApproximateTime.cpp.o:ApproximateTime.cp:(.debug_line+0x71): relocation truncated to fit: IMAGE_REL_AMD64_ADDR32 against `.debug_line_str'
Source/WTF/wtf/CMakeFiles/WTF.dir/./ApproximateTime.cpp.o:ApproximateTime.cp:(.debug_line+0x86): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
clang-14: error: linker (via gcc) command failed with exit code 1 (use -v to see invocation)
明示的に生成すればちゃんとエラーになる
clang++ -femulated-tls -fno-exceptions -gdwarf-2 -g1 -ggnu-pubnames check.cpp
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: a.exe:/4: section below image base
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: a.exe:/24: section below image base
$ ./a.exe
-bash: ./a.exe: cannot execute binary file: Exec format error
... WebKitはそんなの設定している気配は無いんだけど。。
-gsplit-dwarf
っぽい
-gsplit-dwarf
でも同じエラーが出た。ということは -gsplit-dwarf
を指定しないようにすれば大丈夫だろうか。。WebKitではCMakeのオプション DEBUG_FISSION
が該当するようだ。
clang++ -femulated-tls -fno-exceptions -gdwarf-2 -g1 -gsplit-dwarf check.cpp
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: a.exe:/4: section below image base
/usr/lib/gcc/x86_64-pc-cygwin/11/../../../../x86_64-pc-cygwin/bin/ld: a.exe:/24: section below image base