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

Comments

@jeremyfaller
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor Author

commented Aug 23, 2019

@cherrymui

This comment has been minimized.

Copy link
Contributor

commented Aug 23, 2019

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 this to the Go1.14 milestone Aug 26, 2019

@gopherbot

This comment has been minimized.

Copy link

commented Sep 9, 2019

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
cmd/link: prefix syms with "_" on external darwin links
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

This comment has been minimized.

Copy link
Contributor

commented Sep 13, 2019

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

@jeremyfaller jeremyfaller reopened this Sep 13, 2019

@jeremyfaller

This comment has been minimized.

Copy link
Contributor Author

commented Sep 13, 2019

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

@gopherbot

This comment has been minimized.

Copy link

commented Sep 16, 2019

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

@gopherbot gopherbot closed this in 06e5529 Sep 17, 2019

@jeremyfaller jeremyfaller reopened this Sep 18, 2019

@jeremyfaller

This comment has been minimized.

Copy link
Contributor Author

commented Sep 18, 2019

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

@gopherbot

This comment has been minimized.

Copy link

commented Sep 18, 2019

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

@gopherbot gopherbot closed this in 1aa64b5 Sep 18, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.