U.S. stocks rally from sell-off, even as Dow ends first half lower