When using LLVM in WebKit's FTL JIT (on x86_64/Linux/ELF), WebKit crashes with errors like:
ASSERTION FAILED: cfiLength
../../Source/JavaScriptCore/ftl/FTLUnwindInfo.cpp(430) : void JSC::FTL::{anonymous}::findFDE(uintptr_t, uintptr_t, uint32_t, JSC::FTL::{anonymous}::FDE_Info*, JSC::FTL::{anonymous}::CIE_Info*)
1 0x7f5bd4ceabf4 /home/akiss/devel/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(WTFCrash+0x1e) [0x7f5bd4ceabf4]
2 0x7f5bd4c94b05 /home/akiss/devel/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(+0x12ceb05) [0x7f5bd4c94b05]
3 0x7f5bd4c952b3 /home/akiss/devel/WebKit/WebKitBuild/Debug/lib/libjavascriptcoregtk-4.0.so.18(_ZN3JSC3FTL10UnwindInfo5parseEPvmPFlPNS_9ExecStateEE+0xa9) [0x7f5bd4c952b3]
The root cause of the errors turns out to be that the addresses in the Frame Description Entries (FDEs) of the EH frames are encoded in 32-bit PC-relative format. However, quite often the EH frames can get far away in the memory from the associated code and so the correct relative addresses cannot be computed/stored in 32 bits.
This patch defines the address encoding on x86_64 to be dwarf::DW_EH_PE_pcrel, which is 8 bytes there (instead of dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4, which is explicitly 4 bytes) so that the relative addresses don't get truncated.