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/addr2line: prints ? instead of function name and source file info for windows pe executables #7899

Closed
alexbrainman opened this issue Apr 30, 2014 · 10 comments
Milestone

Comments

@alexbrainman
Copy link
Member

This

# go build -o /tmp/a.exe cmd/go && go tool nm /tmp/a.exe | awk
'/main.main/{print $1}' | go tool addr2line /tmp/a.exe
main.main
/root/go/root/src/cmd/go/main.go:110

works, but

# GOOS=windows go build -o /tmp/a.exe cmd/go && go tool nm /tmp/a.exe | awk
'/main.main/{print $1}' | go tool addr2line /tmp/a.exe
?
?:0

does not. hg id is 824f981dd4b7.

Alex
@alexbrainman
Copy link
Member Author

Comment 1:

Looking at the source, cmd/addr2line is assuming that Go pe executable will have
.gosymtab and .gopclntab pe sections. But we have never output these. I really don't
know what to do here. I don't want to start rewriting cmd/ld code now. Perhaps there is
a symbol in our symbol table that can point me to .gosymtab and .gopclntab. But I looked
hard and I don't see it. Perhaps I can add these symbols, but I don't know how. Looking
for suggestions. Thank you.
Alex

@ianlancetaylor
Copy link
Contributor

Comment 3:

The .gosymtab and .gopclntab sections are created, for all object file formats, by
dodata in ld/data.c.  They are attached to the symbols symtab/esymtab and
pclntab/epclntab.
As far as I can tell, the .gosymtab section is empty.  I think that addr2line now gets
the symbol table from .gopclntab (see go12Funcs in pkg/debug/gosym/pclntab.go).  The
.gopclntab data is filled in by pclntab in ld/pcln.c.
I don't know why .gopclntab shows up in ELF files but not in PE files.

@alexbrainman
Copy link
Member Author

Comment 4:

"pe section" != "cmd/ld Section"
"pe section" == "cmd/ld Segment"
Go pe file have ".text" and ".data" pe sections. (it has others, but they aren't related
to this discussion - dwarf sections and "dll imports" section). .gopclntab Section is
not pe section, but is part of ".text" pe section. There is nothing in Go pe file that
identify .gopclntab Section inside of ".text" pe section. I can see .gosymtab is empty
and not used (just like you say), so we only need to worry about .gopclntab.
I started looking for a symbol that points to .gopclntab Section (address and length),
but I cannot find any. I can see pclntab/epclntab symbols, but these live in bss (part
of ".data" pe section), and I don't see how they can be useful.
Alex

@ianlancetaylor
Copy link
Contributor

Comment 5:

The "pclntab" symbol is set to point to the .gopclntab section in the function address
in ld/data.c.  It does work on ELF.  The "epclntab" symbol is the end of the section. 
Those symbols show up in the ELF symbol table with the correct values.  I guess the
question is why that does not happen for PE.  I don't know the answer.

@ianlancetaylor
Copy link
Contributor

Comment 6:

Labels changed: added release-go1.3maybe.

@alexbrainman
Copy link
Member Author

Comment 7:

> ... why that does not happen for PE ...
Because I made a mistake while writing PE symbols. Sending a fix. Thank you for your
help again.
Alex

@gopherbot
Copy link

Comment 8:

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

@gopherbot
Copy link

Comment 9:

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

@alexbrainman
Copy link
Member Author

Comment 10:

This issue was updated by revision cf78f96.

LGTM=iant
R=golang-codereviews, rsc, iant
CC=golang-codereviews
https://golang.org/cl/97920044

@rsc
Copy link
Contributor

rsc commented May 9, 2014

Comment 11:

Submit of CL 96960043 should have marked this fixed. Not sure what happened.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 25, 2016
This issue was closed.
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