Michael Klinger hit 80 not out to steer Gloucestershire clear of trouble on day two of their Division Two match against Glamorgan at Bristol.