Skip to content

Commit

Permalink
builder: prefer GNU build ID over Go build ID
Browse files Browse the repository at this point in the history
The GNU build ID covers the Go build ID, and probably some more.
  • Loading branch information
aykevl authored and deadprogram committed Jan 27, 2022
1 parent 4210200 commit a7a69d3
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion builder/buildid.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func ReadBuildID() ([]byte, error) {
if err != nil {
return nil, err
}
var gnuID, goID []byte
for _, section := range file.Sections {
if section.Type != elf.SHT_NOTE ||
(section.Name != ".note.gnu.build-id" && section.Name != ".note.go.buildid") {
Expand All @@ -40,7 +41,16 @@ func ReadBuildID() ([]byte, error) {
if uint64(n) != section.Size || err != nil {
return nil, fmt.Errorf("could not read build id: %w", err)
}
return buf, nil
if section.Name == ".note.gnu.build-id" {
gnuID = buf
} else {
goID = buf
}
}
if gnuID != nil {
return gnuID, nil
} else if goID != nil {
return goID, nil
}
case "darwin":
// Read the LC_UUID load command, which contains the equivalent of a
Expand Down

0 comments on commit a7a69d3

Please sign in to comment.