cmd/8g: factor out prog information

Like CL 12637051, but for 8g instead of 6g.
Fix a few minor 6g errors too.

R=ken2
CC=golang-dev
https://codereview.appspot.com/12778043