aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2013-11-01 11:32:10 +1100
committerAndrew Gerrand <adg@golang.org>2013-11-01 11:32:10 +1100
commit8648d26c5f89d70cd7d9364a327768e3d91cca3f (patch)
treee3803e9954c62e6be45243ba00857555bbbbb3ac
parent63ff715a55c0e9833cd5aab5aa326fe0d764b7c2 (diff)
downloadgo-8648d26c5f89d70cd7d9364a327768e3d91cca3f.tar.gz
go-8648d26c5f89d70cd7d9364a327768e3d91cca3f.zip
[release-branch.go1.2] cmd/cgo: accept extra leading _ on __cgodebug_data for all object formats
««« CL 19780043 / 8b49cdda6ff4 cmd/cgo: accept extra leading _ on __cgodebug_data for all object formats The current Windows build breakage appears to be because the Windows code should be looking for __cgodebug_data not ___cgodebug_data. Dodge the question everywhere by accepting both. R=golang-dev, iant CC=golang-dev https://golang.org/cl/19780043 »»» R=golang-dev CC=golang-dev https://golang.org/cl/20660043
-rw-r--r--src/cmd/cgo/gcc.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go
index 60d420b21f..f2a109d343 100644
--- a/src/cmd/cgo/gcc.go
+++ b/src/cmd/cgo/gcc.go
@@ -780,6 +780,11 @@ func (p *Package) gccCmd() []string {
func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte) {
runGcc(stdin, p.gccCmd())
+ isDebugData := func(s string) bool {
+ // Some systems use leading _ to denote non-assembly symbols.
+ return s == "__cgodebug_data" || s == "___cgodebug_data"
+ }
+
if f, err := macho.Open(gccTmp()); err == nil {
defer f.Close()
d, err := f.DWARF()
@@ -790,8 +795,7 @@ func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte)
if f.Symtab != nil {
for i := range f.Symtab.Syms {
s := &f.Symtab.Syms[i]
- // Mach-O still uses a leading _ to denote non-assembly symbols.
- if s.Name == "_"+"__cgodebug_data" {
+ if isDebugData(s.Name) {
// Found it. Now find data section.
if i := int(s.Sect) - 1; 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
@@ -818,7 +822,7 @@ func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte)
if err == nil {
for i := range symtab {
s := &symtab[i]
- if s.Name == "__cgodebug_data" {
+ if isDebugData(s.Name) {
// Found it. Now find data section.
if i := int(s.Section); 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
@@ -842,7 +846,7 @@ func (p *Package) gccDebug(stdin []byte) (*dwarf.Data, binary.ByteOrder, []byte)
}
var data []byte
for _, s := range f.Symbols {
- if s.Name == "_"+"__cgodebug_data" {
+ if isDebugData(s.Name) {
if i := int(s.SectionNumber) - 1; 0 <= i && i < len(f.Sections) {
sect := f.Sections[i]
if s.Value < sect.Size {