Stocks extend their rally, all major averages higher