The M-theory origin of global properties of gauge theories