-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
SIGSEGV in TLS startup on mips/musl with rcrt1.o #46566
Comments
Can you clarify what you mean by "happens with rcrt1.o but not with Scrt1.o"? They are not interchangible. rcrt1.o is valid only with static pie (no PT_INTERP) and Scrt1.o is valid for dynamic pie (ET_DYN + PT_INTERP) or for ET_EXEC (but not normally used for the latter). I believe rcrt1.o's limited relocation handling means it only works when TLS accesses have been generated (by the compiler) or relaxed (by the linker) for local-exec model; dynamic models might not work. If needed adding support for them should be possible. |
indeed
from my experience implementing bolter, rust uses all 4 TLS models and somtimes they can't be relaxed, so this could be the problem. Unfortunately i have no idea how to read relocations out of a mips binary to confirm |
OK, that's probably the cause then. Can you show me a simple object file with TLS where access fails? |
@richfelker this is a simple hello world that crashes as described but if i read the output of readelf correctly, the only tls reloc is R_MIPS_TLS_DTPMOD |
Let me know if this patch helps: |
@richfelker yes, this fixes it! thank you so much. This will allow fully statically linked PIE binaries in rust. weeee |
Thinking about it more, for non-pie static linking, there is no runtime relocation at all, so the linker must know how to perform the DTPMOD relocation at ld time (i.e. fill in the 1). In fact bfd ld https://sourceware.org/bugzilla/show_bug.cgi?id=22570 Most other archs are not affected because they have TLS relaxations that convert the dynamic models to initial/local exec models at ld time, but mips seems to lack relaxations. Feel free to use the musl rcrt1 patch for now if you like, but I don't think it's the right fix. This is not something rcrt1 should need to do. |
Can you please reopen the issue until the correct course of action for resolving it upstream (in binutils and/or in musl) is determined? |
See rust-lang/rust#46566 Signed-off-by: Arvid E. Picciani <aep@exys.org>
It's been over a year; does anyone know what the next steps should be? |
we completely pulled rust from all projects, so i cant test this. |
this looks like a bug in musl's rcrt1.o to me, but i can't quite give the musl guys any useful information here
this only happens when using rcrt1.o as entrypoint, not with Scrt1.o , so i suspect something related to TLS must be different in rcrt1
I'd appecheciate some pointers from the rust community here how TLS is different than for C++ so i can show a better test case to musl.
The text was updated successfully, but these errors were encountered: