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: build broken on plan9/amd64 since CL 27790 #17411

Closed
0intro opened this issue Oct 11, 2016 · 5 comments

Comments

Projects
None yet
4 participants
@0intro
Copy link
Member

commented Oct 11, 2016

Since CL 27790, the build is broken on plan9/amd64.

##### Building packages and commands for plan9/amd64.
panic: runtime error: invalid memory address or nil pointer dereference
[signal sys: trap: fault read code=0x0 addr=0x18 pc=0x3ba12e]

goroutine 1 [running]:
panic(0x45a620, 0x6129f0)
    /tmp/gobuilder/plan9-amd64-9front-b4efd09d1880/go/src/runtime/panic.go:496 +0x18d
reflect.(*rtype).Elem(0x43a6e0, 0x0, 0x608000)
    /tmp/gobuilder/plan9-amd64-9front-b4efd09d1880/go/src/reflect/type.go:927 +0xe
text/template.init()
    /tmp/gobuilder/plan9-amd64-9front-b4efd09d1880/go/src/text/template/exec.go:599 +0xb4
go/doc.init()
    /tmp/gobuilder/plan9-amd64-9front-b4efd09d1880/go/src/go/doc/synopsis.go:83 +0x5f
go/build.init()
    /tmp/gobuilder/plan9-amd64-9front-b4efd09d1880/go/src/go/build/zcgo.go:33 +0x76
main.init()
    /tmp/gobuilder/plan9-amd64-9front-b4efd09d1880/go/src/cmd/go/zosarch.go:43 +0x91

See https://build.golang.org/log/4ca47ecfe2249b3368d4488118da1dd4ca9850ec

The issue is related to this specific change:

--- a/src/cmd/link/internal/ld/data.go
+++ b/src/cmd/link/internal/ld/data.go
@@ -544,7 +544,14 @@ func relocsym(ctxt *Link, s *Symbol) {
            o = Symaddr(r.Sym) + r.Add - int64(r.Sym.Sect.Vaddr)

        case obj.R_ADDROFF:
-           o = Symaddr(r.Sym) - int64(r.Sym.Sect.Vaddr) + r.Add
+           // The method offset tables using this relocation expect the offset to be relative
+           // to the start of the first text section, even if there are multiple.
+
+           if r.Sym.Sect.Name == ".text" {
+               o = Symaddr(r.Sym) - int64(Segtext.Vaddr) + r.Add
+           } else {
+               o = Symaddr(r.Sym) - int64(r.Sym.Sect.Vaddr) + r.Add
+           }

            // r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
        case obj.R_CALL, obj.R_GOTPCREL, obj.R_PCREL:

CC @ianlancetaylor

@0intro 0intro added the OS-Plan9 label Oct 11, 2016

@0intro 0intro added this to the Go1.8 milestone Oct 11, 2016

@0intro 0intro self-assigned this Oct 11, 2016

@quentinmit quentinmit added the NeedsFix label Oct 11, 2016

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Oct 11, 2016

@0intro

This comment has been minimized.

Copy link
Member Author

commented Oct 12, 2016

For some reason, there is a difference of 8 bytes between Segtext.Vaddr and r.Sym.Sect.Vaddr on plan9/amd64.

Segtext.Vaddr    = 0x200028
r.Sym.Sect.Vaddr = 0x200030
@0intro

This comment has been minimized.

Copy link
Member Author

commented Oct 12, 2016

Shouldn't we use Segtext.Vaddr rather be Segtext.Sect.Vaddr?

Segtext.Vaddr is the address of the text segment, while Segtext.Sect.Vaddr is the address the first section in the text segment (runtime.text), which is expected here.

I've sent CL 30911.

@gopherbot

This comment has been minimized.

Copy link

commented Oct 12, 2016

CL https://golang.org/cl/30911 mentions this issue.

@gopherbot gopherbot closed this in 29c600b Oct 12, 2016

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Oct 12, 2016

The difference in addresses is due to alignment. cmd/link/internal/amd64/obj.go sets FlagTextAddr to a value that is aligned to an 8 byte boundary, but evidently some symbol in the text section wants to be aligned to a 16 byte boundary.

@golang golang locked and limited conversation to collaborators Oct 12, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.