Hi,
I have memory layout (In Increasing memory addr) like :
Code Section (0-4k), Data Section(4k-8k), Stack Section(8k-12k), CustomData Section(12k-16k).
I have put some special arrays, structs in Custom Data Section.
As i know, Data Segment (#DS)Selector will be used for any Data related compiler code.
So Data Section(4k-8k) will have #DS by default for all operation.
But, I want to use Extra Segment(#ES) selector for CustomData access. I would define a new GDT entry for ES with different Base and Limit.
So my question is:
Does GCC has any x86 compiler flag, which can be used to tell compiler that use #ES for CustomData Section code access.?
Means, compiler flag which will generate code using #ES for CustomData Section.?
Thanks in advance !!
what is GCC compiler option to get Segment Override in x86
-
- Member
- Posts: 26
- Joined: Wed Sep 28, 2011 6:46 am
- Location: Bangalore - India
Re: what is GCC compiler option to get Segment Override in x
Hi,
Note: There's a small chance that you might be able to use FS or GS (e.g. maybe with inline assembly getters/setters) to access data in a special section; which wouldn't interfere with code generated by GCC as neither FS nor GS is a default segment for anything. However there's a larger chance that it's a waste of time and you should just use "flat" anyway.
Cheers,
Brendan
Not really. Different instructions have different "default" segments, depending on a bunch of things. GCC doesn't care and just assumes that all segments are the same and ends up using the default segment for each instruction (whatever it happens to be); which means that it could end up using SS, DS or ES to access data in your Data Section (or your Stack Section, or your CustomData Section).RajivKumarSrivastav wrote:As i know, Data Segment (#DS)Selector will be used for any Data related compiler code.
Too bad. GCC is designed for a "flat" address space where segments aren't really used (and paging is used to enforce section permissions if needed instead).RajivKumarSrivastav wrote:But, I want to use Extra Segment(#ES) selector for CustomData access. I would define a new GDT entry for ES with different Base and Limit.
Note: There's a small chance that you might be able to use FS or GS (e.g. maybe with inline assembly getters/setters) to access data in a special section; which wouldn't interfere with code generated by GCC as neither FS nor GS is a default segment for anything. However there's a larger chance that it's a waste of time and you should just use "flat" anyway.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Member
- Posts: 26
- Joined: Wed Sep 28, 2011 6:46 am
- Location: Bangalore - India
Re: what is GCC compiler option to get Segment Override in x
Thanks Brendan.
Is it possible by any other method?
Is it possible by any other method?
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: what is GCC compiler option to get Segment Override in x
Use a different compiler, like OpenWatcom