Stocks gained ground on Wall Street Friday for a second straight day, wiping away losses from earlier in the week.