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: broken with binutils that generates STT_COMMON symbols #18088

moben opened this issue Nov 28, 2016 · 3 comments

cmd/link: broken with binutils that generates STT_COMMON symbols #18088

moben opened this issue Nov 28, 2016 · 3 comments


Copy link

@moben moben commented Nov 28, 2016

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

go version go1.7.1 linux/amd64

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

GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build450521412=/tmp/go-build -gno-record-gcc-switches"

What did you do?

We built binutils with --enable-elf-stt-common. This makes the gnu assembler/objcopy and ld default to generating common symbols with the STT_COMMON type.

What did you see?

This makes go break at runtime with:

..../go/pkg/linux_amd64/runtime/cgo.a(_all.o): malformed elf file: runtime/cgo(.text)#40: reloc of invalid sym #65 x_cgo_threadentry shndx=65522 type=5

If binutils was not configured this way, this should be reproducible by passing --elf-stt-common=yes and -z common to the assembler and linker respectively when builing go. I wasn't able to do this but that's probably due to my unfamiliarity with go's build system.

How to fix this?

go could pass --elf-stt-common=no and -z nocommon when building itself or anything else. However I don't think that's workable, as then it would not be able to link to objects that were created with those flags set.

Copy link

@bradfitz bradfitz commented Nov 28, 2016

Can you try Go master? (what will be Go 1.8)

Or wait a few days for the first beta if you don't want to run src/make.bash.

@ianlancetaylor ianlancetaylor changed the title go broken with binutils that generates STT_COMMON symbols cmd/link: broken with binutils that generates STT_COMMON symbols Nov 29, 2016
Copy link

@gopherbot gopherbot commented Nov 29, 2016

CL mentions this issue.

Copy link

@moben moben commented Nov 29, 2016

I can confirm that it happens on master and that fixes it.

@gopherbot gopherbot closed this in 45f7595 Nov 29, 2016
@golang golang locked and limited conversation to collaborators Nov 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.