The tech giants helped spark a rally in stocks that pushed the S&P 500 back into positive territory for the year.