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/nm: decide on symbol index presentation #38875
Comments
Yeah, this was done in CL https://go-review.googlesource.com/c/go/+/229246 . The reason is that in the new object files, symbols are referenced by indices instead of by names. So, if you objdump an object file which imports the fmt package and call Does this format cause any problem for you? Should we add a flag to switch it on/off? I'd also be happy to hear if you have a better suggestion of the format. Thanks! |
cc @aclements |
I just added a RELNOTE marker on that CL. It may be worth mentioning this to golang-dev@, too, since I imagine Josh won't be the only person surprised by this! |
It confused some tools I have that parse the output of Although there would be some value in having a flag (default on or off? not sure.) Or maybe another column in the output for easier parsing (perhaps enabled by a flag)? Those would move the knowledge about how to unmangle from N tools--each possibly using different algorithms and thus getting it wrong in the future in different ways--to one tool. An alternative, which I would like even better, since I would no longer have to exec |
I originally had a space between the index and the name. Austin pointed out that adding a space may makes tools harder to parse. |
Change https://golang.org/cl/236167 mentions this issue: |
Change https://golang.org/cl/236168 mentions this issue: |
…ols" This reverts CL 229246. For new indexed object files, in CL 229246 we added symbol index to tools (nm, objdump) output. This affects external tools that parse those outputs. And the added index doesn't look very nice. In this release we take it out. For future releases we may introduce a flag to tools (nm, objdump) and optionally dump the symbol index. For refererenced (not defined) indexed symbols, currently the symbol is still referenced only by index, not by name. The next CL will make the object file self-contained, so tools can dump the symbol names properly (as before). For #38875. Change-Id: I07375e85a8e826e15c82fa452d11f0eaf8535a00 Reviewed-on: https://go-review.googlesource.com/c/go/+/236167 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Jeremy Faller <jeremy@golang.org>
To close the loop on this, nm and objdump now print full symbol names even for cross-package references, so we don't need to print the index any more. Cherry did this by adding a table of referenced symbol names to object files so they're self-contained (but only tools use these tables). We may add an option in the future to show these indexes again, since they can be useful for debugging linker issues. (And I'd love a similar option to show ABI information.) |
Sample reproduction:
Run
go tool nm ../pkg/darwin_amd64/net.a
. With tip, I see entries like:Note the trailing
#423
. Those are not present with Go 1.14:cc @cherrymui @jeremyfaller @thanm
The text was updated successfully, but these errors were encountered: