This code was copied from src/debug/gosym in the go repo at commit e146d3eafafe149aa3a28e6a251db9c01d04f11d.
It was modified to remove dependencies on internal packages in the go repo, and to compile under go 1.17.