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/ld: must sort exported symbols on Mountain Lion #4029

Closed
gopherbot opened this issue Sep 1, 2012 · 6 comments
Closed

cmd/ld: must sort exported symbols on Mountain Lion #4029

gopherbot opened this issue Sep 1, 2012 · 6 comments
Milestone

Comments

@gopherbot
Copy link

by d.wright.dev:

What steps will reproduce the problem?

This is an issue that implies that there might be something funny going on with 8l
(illegal code points? newlines? non printing characters?), although the exported symbols
are printed by nm.

When exporting function symbols using the //export <symbolname> comment syntax on
Mountain Lion, they cannot reliably be found by dlsym() when invoked upon the executable
from within the program itself. 

The behavior seems to vary by symbol name. If the first character of the export is
several letters off in alphabetical sequence from the last one, dlsym() finds the
symbol. This is pretty inconvenient and obviously not the main issue.

see: dlbug_fail.go, dlbug_pass.go


What is the expected output?

> go run dlbug_fail.go

symbol:IMPWindowResize found
symbol:IMPDrawRect found
symbol:IMPInitWithFrame found
symbol:IMPIsOpaque found

What do you see instead?

symbol:IMPWindowResize found
symbol:IMPDrawRect error: dlsym(RTLD_DEFAULT, IMPDrawRect): symbol not found
symbol:IMPInitWithFrame found
symbol:IMPIsOpaque error: dlsym(RTLD_DEFAULT, IMPIsOpaque): symbol not found

Which compiler are you using (5g, 6g, 8g, gccgo)?

6g

Which operating system are you using?

OS X 10.8.1 (12B19)

Which version are you using?  (run 'go version')

go version go1.0.2

Please provide any additional information below.

If I could make a suggestion about resource allocation: not being able to use cgo from
within gotest prevents integration of regression testing on this sort of issue. It's
probably worth the time to fix that. The first thing I tried to do before submitting a
report was to package these files as tests. 

Also, "go run" treats files named *_test.go as tests and then fails if tests
aren't found.

I'll file these suggestions as separate bugs.

Attachments:

  1. dlbug_fail.go (1371 bytes)
  2. dlbug_pass.go (1371 bytes)
@gopherbot
Copy link
Author

Comment 1 by d.wright.dev:

Actually, pardon. That's 6l, not 8l.

@gopherbot
Copy link
Author

Comment 2 by d.wright.dev:

The above files are not completely identical, I've made them so in order to look at a
binary diff.
What I'm seeing is what looks like an internal symbol table that's alphabetized and
referring to Go runtime functions. And what looks like an exports table that may not be
alphabetized. My hunch is that a sort occurs on the function list between the time the
internal and external pointers are generated.
Which explains why I have to sort them by hand in my source file.

Attachments:

  1. dlbug_fail.go (1371 bytes)
  2. dlbug_pass.go (1371 bytes)

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 3:

Labels changed: added priority-soon, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 4:

Labels changed: added go1.1.

@minux
Copy link
Member

minux commented Oct 8, 2012

Comment 5:

https://golang.org/cl/6620075/
As I don't have Mountain Lion machines, i can't test this CL (other than "objdump -t")

Owner changed to @minux.

Status changed to Started.

@minux
Copy link
Member

minux commented Oct 9, 2012

Comment 6:

This issue was closed by revision fa563ae.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 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

3 participants