link-editor builds bogus .eh_frame_hdr on ia32
The link-editor builds bogus .eh_frame_hdr sections on ia32, due to the poor and crazy specification of DW_EH_PE_datarel.
DW_EH_PE_datarel is specified as being "relative to .eh_frame_hdr or .got", without any real further description. In practice, within .eh_frame_hdr it is relative to the start of .eh_frame_hdr, elsewhere it is relative to .got (though reportedly this may differ on other platforms).
Updated by Rich Lowe over 9 years ago
So what's going on here is that on i386, we use ..._datarel values in .eh_frame (because, apparently, the Sun assembler couldn't cope with cross-section math).
Because we were interpreting these incorrectly, the values we were placing into .eh_frame_hdr were incorrect. Code using the eh_frame-based unwind, would look at the hdr, and either not match ever (and our exception would erroneously hit the top level), or would match incorrectly (since the offset from correct may be slight), and crash because it was trying to use the wrong FDE. elfdump doesn't make this obvious, because it shares the code that mis-interprets the values, so everything appears to line up.