A generalized global Arnoldi method for ill-posed matrix equations