EXTRAGALACTIC BACKGROUND LIGHT FROM HIERARCHICAL GALAXY FORMATION: GAMMA-RAY ATTENUATION UP TO THE EPOCH OF COSMIC REIONIZATION AND THE FIRST STARS