-
-
Notifications
You must be signed in to change notification settings - Fork 464
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
Mesa linked with mold creates symbols with wrong visibility #197
Comments
I knew this difference but didn't recognize as an issue because I thought that the dynamic linker would ignore HIDDEN symbols. Thank you for your excerpt from binutils. I looks like my recognition was wrong. I'll investigate it a bit more and make a fix. |
Excerpt from the spec (link):
|
@icecream95 Can you share your I don't think mold puts a hidden symbol to |
I'm doing some more debugging, and it appears that the actual issue is related to TLS, and that the symbol tables weren't causing the issues. |
Mesa uses this variable to store the current EGL context.:
Using watchpoints, I found that when libEGL is linked with mold it has the same address as this variable declared in the ApiTrace
|
Here is a small example that reproduces the issue:
#include <stdio.h>
void lib_set(int);
__thread int bin;
int main(void)
{
bin = 1;
lib_set(2);
printf("%i\n", bin);
}
static __thread __attribute__((tls_model("initial-exec"))) int lib;
void lib_set(int x)
{
lib = x;
}
When linked with EDIT: Added |
@icecream95 Thank you for sharing a small test case! I can reproduce it on my machine. Looking... |
Fixed the issue in the above patch. |
Thank you, everything works now! |
When Mesa is compiled with glvnd enabled using mold, programs crash on startup with errors like this:
When linked with
ld.bfd
, readelf shows an entry like this for the function inlibEGL_mesa.so
:ld.lld
gives something similar:But
mold
creates a symbol withGLOBAL
visibility, which I think causes the bug because it overrides theeglGetProcAddress
function in glvnd.The original object file lists the function as
GLOBAL
andHIDDEN
:elflink.c
in binutils mentions:It seems that the BFD linker does this whenever it is passed the
-shared
option.The text was updated successfully, but these errors were encountered: