Rather than having one potentially large wasm_apply_relocs function, wasm_apply_relocs is split into 10 smaller functions, all executed in order.
Safari on iOS struggles with excessively large functions, and for a larger .wasm module (~7mb observed), _wasm_apply_relocs balloons to >500kb, causing Safari iOS to fail with a "max stack size exceeded" error. By splitting __wasm_apply_relocs into multiple smaller methods, relocation functionality is preserved while being able to load/run on iOS.
I understand that this code may not be perfect, setting the initial function count to 10 is a hack, etc. I'm submitting this patch to spark discussion, expecting that the overall approach may need to be modified (or at-least made tune-able with linker flags).