-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: would like a way to emit DT_RPATH tags (instead of DT_RUNPATH) #45412
Comments
As far as I can tell, this is only going to be an issue when linking against C shared libraries, which means when using the C linker. Therefore, the |
Or am I confused about this? Does this somehow arise with a pure Go binary? |
Sure, it breaks the "go" binary:
("go.handhacked" is a copy of the same binary where I used a hex editor to change the DT_RUNPATH to a DT_RPATH) |
OK, so we would need this new option only for building the go binary itself. And we would need some way to build the go binary with the new option. The difference between What if you replace the go tool with a tiny shell script
? |
What I am doing today is setting GO_LDFLAGS to "-I {interp} -r {rpath}" when invoking ./make.bash and this works fine, apart from the RPATH/RUNPATH thing. 'pprof' and 'trace' are the other dynamic executables in the snap today.
Right, this is about dlopen and friends.
Yeah but this attitude seems to fly in the face of reality a bit, unfortunately. They don't do the same thing!
That could cause problems when go tries to execute the host compiler or linker. I think I could replace go (and trace and pprof) with shell scripts that run "/snap/core18/current/lib64/ld-linux-x86-64.so.2 --library-path /snap/core18/current/lib/x86_64-linux-gnu $realbinary". |
Since we have an option |
That's the host linker I think :-) cmd/link just takes -r, nicely ambiguous. FWIW I have a workaround for now but it's pretty ghastly. |
Ah, right, sorry. |
What version of Go are you using (
go version
)?Anything (since the linker's -r flag was added in 2010 anyway)
Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?Ubuntu 20.04, but really: any ELF system.
What did you do?
I maintain the Go snap, which is a "classic snap": classic snaps run in the same mount namespace as everything else but load dynamic libraries from a "core" snap, which is mounted at a path like /snap/core18/current. To do this, they need to have a DT_RPATH like /snap/core18/current/lib/x86_64-linux-gnu. The linker's -r option causes a DT_RUNPATH tag to be used, which doesn't work for the reasons explained in https://www.qt.io/blog/2011/10/28/rpath-and-runpath. (It almost works, but when glibc tries to load a NSS component, it loads it from the host not the core snap and that can break).
It would be a trivial change to the linker to add an option "-rpath-instead-of-runpath" or whatever, but would that be acceptable?
The text was updated successfully, but these errors were encountered: