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: external linking on darwin strips symbols starting with "l" #33808

Closed
jeremyfaller opened this issue Aug 23, 2019 · 8 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Milestone

Comments

@jeremyfaller
Copy link
Contributor

jeremyfaller commented Aug 23, 2019

What version of Go are you using (go version)?

$ go version
1.13 locally built

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN="/Users/jfaller/go/bin"
GOCACHE="/Users/jfaller/Library/Caches/go-build"
GOENV="/Users/jfaller/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jfaller/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/jfaller/src/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/jfaller/src/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/kt/9h7gfgy955lgbm_cys108l2c002pwh/T/go-build423342355=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

[16:12]~/go/src/hello $ cat hello.go
package main

import "log"

func main() {
	log.Fatalf("See we called a function that started with l")
}
[16:12]~/go/src/hello $ go build .
[16:12]~/go/src/hello $ nm hello | grep Fatal
000000000109c170 t log.Fatalf
[16:12]~/go/src/hello $ go build -ldflags="-linkmode external"
[16:12]~/go/src/hello $ nm hello | grep Fatal
[16:13]~/go/src/hello $ 

What did you expect to see?

I expected that log.Fatal would still be in my executable.

What did you see instead?

Symbols starting with an l have been stripped.

Oringally reported HERE

@jeremyfaller
Copy link
Contributor Author

CC @cherrymui @aarzilli @diffmike

@cherrymui
Copy link
Member

I think we already add leading _ to symbol names for plugins, for exactly the reason mentioned in go-delve/delve#1635 (comment) : dlsym needs it. We may want to do this for other build modes as well.

@bcmills bcmills changed the title cmd/link external linking on darwin strips symbols starting with "l" cmd/link: external linking on darwin strips symbols starting with "l" Aug 26, 2019
@bcmills bcmills added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin labels Aug 26, 2019
@bcmills bcmills added this to the Go1.14 milestone Aug 26, 2019
@gopherbot
Copy link

Change https://golang.org/cl/194381 mentions this issue: cmd/link: prefix syms with "_" on external darwin links

gopherbot pushed a commit that referenced this issue Sep 12, 2019
Fixes #33808

Change-Id: If1f30bc80004093ffdf9121768464dfb3a6e1f63
Reviewed-on: https://go-review.googlesource.com/c/go/+/194381
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
@aarzilli
Copy link
Contributor

Given that the change was reverted this issue should be reopened, I think.

@jeremyfaller jeremyfaller reopened this Sep 13, 2019
@jeremyfaller
Copy link
Contributor Author

Totally right. I'm on vacation till Monday, but will fix whatever caused the trybots unhappiness first thing.

@gopherbot
Copy link

Change https://golang.org/cl/195619 mentions this issue: cmd/link: prefix syms with "_" on external darwin links

@jeremyfaller
Copy link
Contributor Author

Apparently external linking hasn't ever worked on darwin_386. I'll exclude that in the test, and resubmit.

@gopherbot
Copy link

Change https://golang.org/cl/196217 mentions this issue: cmd/link: prefix Go syms with _ on darwin

@golang golang locked and limited conversation to collaborators Sep 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Darwin
Projects
None yet
Development

No branches or pull requests

5 participants