OSDev.org https://forum.osdev.org/ |
|
Segment based referencing in c https://forum.osdev.org/viewtopic.php?f=13&t=32806 |
Page 1 of 1 |
Author: | thomasloven [ Thu Mar 15, 2018 2:21 am ] |
Post subject: | Segment based referencing in c |
Some xv6 code mirrors have the following line: Code: extern struct cpu *cpu asm("%gs:0"); [github] This is a hack using the assembly label attribute available in some compilers which works by accident rather than by design - if at all. However, having a simple way of automatically referencing an offset from fs/gs is damn convenient, and having it be a variable rather than a function carries a measure of elegance. Can the same thing somehow be be done The Right Way™? |
Author: | Octocontrabass [ Thu Mar 15, 2018 2:39 am ] |
Post subject: | Re: Segment based referencing in c |
Yes, using GCC's Named Address Spaces extensions. |
Author: | thomasloven [ Thu Mar 15, 2018 3:09 am ] |
Post subject: | Re: Segment based referencing in c |
Works like a charm! Thank you! |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |