High energy gamma ray counterparts of astrophysical sources of ultra-high energy cosmic rays