mirror of
https://github.com/golang/go
synced 2024-11-11 23:40:22 -07:00
cmd/go: add Solaris assembler syntax for gccgo buildid file
The Solaris assembler uses a different syntax for section directives. Fixes https://gcc.gnu.org/PR85429. Change-Id: I1e54dffee3290046dbb68ba4e90ab795c6b72571 Reviewed-on: https://go-review.googlesource.com/109140 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
289ab30457
commit
77d5c62815
@ -294,13 +294,32 @@ func (b *Builder) gccgoToolID(name, language string) (string, error) {
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// Check if assembler used by gccgo is GNU as.
|
||||
func assemblerIsGas() bool {
|
||||
cmd := exec.Command(BuildToolchain.compiler(), "-print-prog-name=as")
|
||||
assembler, err := cmd.Output()
|
||||
if err == nil {
|
||||
cmd := exec.Command(strings.TrimSpace(string(assembler)), "--version")
|
||||
out, err := cmd.Output()
|
||||
return err == nil && strings.Contains(string(out), "GNU")
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// gccgoBuildIDELFFile creates an assembler file that records the
|
||||
// action's build ID in an SHF_EXCLUDE section.
|
||||
func (b *Builder) gccgoBuildIDELFFile(a *Action) (string, error) {
|
||||
sfile := a.Objdir + "_buildid.s"
|
||||
|
||||
var buf bytes.Buffer
|
||||
if cfg.Goos != "solaris" || assemblerIsGas() {
|
||||
fmt.Fprintf(&buf, "\t"+`.section .go.buildid,"e"`+"\n")
|
||||
} else if cfg.Goarch == "sparc" || cfg.Goarch == "sparc64" {
|
||||
fmt.Fprintf(&buf, "\t"+`.section ".go.buildid",#exclude`+"\n")
|
||||
} else { // cfg.Goarch == "386" || cfg.Goarch == "amd64"
|
||||
fmt.Fprintf(&buf, "\t"+`.section .go.buildid,#exclude`+"\n")
|
||||
}
|
||||
fmt.Fprintf(&buf, "\t.byte ")
|
||||
for i := 0; i < len(a.buildID); i++ {
|
||||
if i > 0 {
|
||||
@ -313,8 +332,10 @@ func (b *Builder) gccgoBuildIDELFFile(a *Action) (string, error) {
|
||||
fmt.Fprintf(&buf, "%#02x", a.buildID[i])
|
||||
}
|
||||
fmt.Fprintf(&buf, "\n")
|
||||
if cfg.Goos != "solaris" {
|
||||
fmt.Fprintf(&buf, "\t"+`.section .note.GNU-stack,"",@progbits`+"\n")
|
||||
fmt.Fprintf(&buf, "\t"+`.section .note.GNU-split-stack,"",@progbits`+"\n")
|
||||
}
|
||||
|
||||
if cfg.BuildN || cfg.BuildX {
|
||||
for _, line := range bytes.Split(buf.Bytes(), []byte("\n")) {
|
||||
|
Loading…
Reference in New Issue
Block a user