When referencing weak undefined symbols, relocations are patched as though they target address zero. However, in the case of relative relocations, if the address being patched is large, the relocation will fail with an out of range error. This is unhelpful to the user, and they can only work around it by changing the base address of their program or explicitly defining the symbol, if this validation fails, which may not be desired.
This patch disables the validation of relocations when they target weak undefined symbols, in order to work around this issue. This is safe, because all such calls should be guarded anyway to ensure that the symbol really is defined.
I wonder if you really have to change this many places to handle weak undefined symbols. If you don't call relocateOne if UndefinedWeak is true, doesn't it work?