fix segfaults when using gcc 4.8 on amd64/x86 unix

I'm just porting the aarch64 stuff committed recently.