Uhg, what an awful GCC hack, and supposedly in MIT coursework:https://stackoverflow.com/q/47917027/379897 …
-
-
Replying to @RichFelker
\o/ i've been looking for how to do that on x86 for ages. thank you.
1 reply 0 retweets 0 likes -
Replying to @dlgwynne
This is not how. It will generate nonsense asm with -fPIC and possibly other circumstances.
1 reply 0 retweets 0 likes -
Replying to @RichFelker @dlgwynne
I agree it's gross, but it's also sort of neat. Arguably it has teaching value -- can discuss why it works and why it's not ideal. Maybe better to stick to the TLS ABI and just do extern __thread... can still layout the kernel TLS area manually if you like (with --defsym even).
1 reply 0 retweets 0 likes -
Note that this was eliminated in the MIT xv6 code base at the beginning of this year. https://github.com/mit-pdos/xv6-public/commit/7e0cc8e36ea91d0299f375f3b3476ab58ab71dde#diff-62a197b4710d3ed3ab9a258d55f686ce … is where it was introduced and https://github.com/mit-pdos/xv6-public/commit/abf847a083888bbed4260ecacf849ea19f23e810#diff-62a197b4710d3ed3ab9a258d55f686ce … removed it. Interestingly before that they *were* using __thread – not sure why they stopped.
1 reply 0 retweets 1 like -
Replying to @moyix @stephenrkell and
Interestingly they also experimented keeping curproc at the top of the stack, which is what Linux has historically done (now IIRC Linux uses %gs on x86, but still stores the data structure in the same place, so the ESP & (THREAD_SIZE-1) trick still works).https://github.com/mit-pdos/xv6-public/commit/ce2e7515552adca3a60e349de2931112736d17bf#diff-62a197b4710d3ed3ab9a258d55f686ce …
2 replies 0 retweets 1 like -
Replying to @moyix @stephenrkell and
Anyway, perhaps
@_rsc can be convinced to join the thread and talk about the history?1 reply 0 retweets 1 like -
Replying to @moyix @stephenrkell and
It's a teaching operating system. It's meant to be simple. Why worry about explaining what the "TLS ABI" is when there is no other code running on the machine.
2 replies 0 retweets 2 likes -
It's the abuse of asm names that allows for silent codegen breakage that I'm concerned about, not lack of "TLS ABI".
1 reply 0 retweets 0 likes
I would use an access function with inline asm and proper constraints to make it valid, roughly: void *gettp(void) { void *p; __asm__("mov %%gs:0, %0" : "=r"(p)); return p; }
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.