Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: OSX 10.11 go/cgo binary corrupted by codesign #12950

Closed
gazed opened this issue Oct 15, 2015 · 4 comments
Closed

cmd/link: OSX 10.11 go/cgo binary corrupted by codesign #12950

gazed opened this issue Oct 15, 2015 · 4 comments

Comments

@gazed
Copy link

gazed commented Oct 15, 2015

1: go version go1.5.1 darwin/amd64
2: OSX 10.11 MacPro6,1Quad-Core Intel Xeon E5
3: Minimal program to create an invalid go binary on OSX using codesign tool.

package main

import "C" // Delete this line and codesign'd binary works.

func main() {
    println("Hello OSX.")
}
~/code/src/ttt: go build
~/code/src/ttt: ./ttt
Hello OSX.
~/code/src/ttt: codesign -s "Developer ID Application: Name" ttt
~/code/src/ttt: ./ttt
Killed: 9

4: The program should run successfully after code signing. This used to work prior to OSX 10.11.
5: All of my OSX Go products depend on Cgo. Still looking for a workaround.
Possibly related to issue #12700

@rakyll rakyll changed the title OSX 10.11 go/cgo binary corrupted by codesign. build: OSX 10.11 go/cgo binary corrupted by codesign Oct 15, 2015
@ianlancetaylor ianlancetaylor added this to the Go1.6 milestone Oct 15, 2015
@ianlancetaylor ianlancetaylor changed the title build: OSX 10.11 go/cgo binary corrupted by codesign cmd/link: OSX 10.11 go/cgo binary corrupted by codesign Oct 15, 2015
@ianlancetaylor
Copy link
Contributor

This is peculiar since it's the opposite of what I would expect. When you have the import "C" line there, the final program should be produced by the Darwin linker. I don't know why codesign would break a progrma produced by the Darwin linker.

Please run the failing commands again, but use "go build -ldflags=-v". Thanks.

@gazed
Copy link
Author

gazed commented Oct 15, 2015

~/code/src/ttt: go build -ldflags=-v
# ttt
HEADER = -H1 -T0x2000 -D0x0 -R0x1000
searching for runtime.a in $WORK/runtime.a
searching for runtime.a in /usr/local/go/pkg/darwin_amd64/runtime.a
 0.00 deadcode
 0.01 pclntab=165294 bytes, funcdata total 34936 bytes
 0.01 dodata
 0.01 symsize = 0
 0.01 symsize = 0
 0.01 reloc
 0.02 reloc
 0.02 asmb
 0.02 codeblk
 0.03 datblk
 0.03 dwarf
 0.03 symsize = 0
 0.05 dwarf pass 2.
 0.06 sym
 0.06 headr
host link: "clang" "-m64" "-gdwarf-2" "-Wl,-no_pie,-headerpad,1144" "-Wl,-pagezero_size,4000000" "-o" "/var/folders/_d/8n_wrc4n32d1rgx80bn6hsl80000gn/T/go-build588937113/ttt/_obj/exe/a.out" "-Qunused-arguments" "/var/folders/_d/8n_wrc4n32d1rgx80bn6hsl80000gn/T/go-link-219552470/000000.o" "/var/folders/_d/8n_wrc4n32d1rgx80bn6hsl80000gn/T/go-link-219552470/000001.o" "/var/folders/_d/8n_wrc4n32d1rgx80bn6hsl80000gn/T/go-link-219552470/go.o" "-g" "-O2" "-g" "-O2" "-lpthread"
 0.12 cpu time
23064 symbols
17716 liveness data
~/code/src/ttt: ./ttt
Hello OSX.
~/code/src/ttt: codesign -s "Developer ID Application: Name" ttt
~/code/src/ttt: ./ttt
Killed: 9

@gazed gazed closed this as completed Oct 15, 2015
@gazed gazed reopened this Oct 15, 2015
@gazed
Copy link
Author

gazed commented Oct 15, 2015

This problem does not seem occur when code-signing with some simple Obj-C binaries produced by clang. I've tried one from Xcode and one from the command line.

@rakyll
Copy link
Contributor

rakyll commented Oct 15, 2015

Looks like a duplicate of #11887. The issue is the DWARF information in the binary. A workaround is to use -ldflags=-s until the issue is resolved.

@rakyll rakyll closed this as completed Oct 15, 2015
@golang golang locked and limited conversation to collaborators Oct 17, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants