The different groups and segments of object files

Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com>
Fri, 19 Jun 2020 23:22:52 +0800

          From comp.compilers

Related articles
The different groups and segments of object files johann@myrkraverk.com (Johann 'Myrkraverk' Oskarsson) (2020-06-19)
Re: The different groups and segments of object files gah4@u.washington.edu (2020-06-19)
Re: The different groups and segments of object files DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-06-20)
Re: The different groups and segments of object files gah4@u.washington.edu (2020-06-21)
Re: The different groups and segments of object files johann@myrkraverk.invalid (Johann 'Myrkraverk' Oskarsson) (2020-06-25)
Re: The different groups and segments of object files johann@myrkraverk.invalid (Johann 'Myrkraverk' Oskarsson) (2020-06-25)
Re: The different groups and segments of object files DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-06-25)
[3 later articles]
| List of all articles for this month |

From: Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com>
Newsgroups: comp.compilers
Date: Fri, 19 Jun 2020 23:22:52 +0800
Organization: Easynews - www.easynews.com
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="98527"; mail-complaints-to="abuse@iecc.com"
Keywords: code, architecture, comment
Posted-Date: 19 Jun 2020 11:33:32 EDT
Content-Language: en-GB

Dear c.compilers,


The short story is that I've been playing with the OpenWatcom code
generator. I can use it to make a custom object file. The platform
is 32bit x86, though I'm happy to know how things work in 16bit and
64bit modes as well.


The code generator has options I do not fully understand, and I do
not know where I can find information on this subject. To further
complicate matters I'm unsure what questions I should be asking.


Here, I'm /exclusively/ asking about object files, as I'm at the
moment generating 32bit code without considerations for physical
segments [1].


What are segment groups for? The Watcom compiler interface seems to
be based on the Microsoft documentation, so I've been reading old MS
manuals as well. There we have the following paragraph:


  > All segments with the same group name must fit into a single physical
  > segĀ­ment, which is up to 64K long. This allows all segments in a group
  > to be acĀ­cessed through the same segment register. The Microsoft C
  > Compiler defines one group named DGROUP.


As far as I can tell, Watcom also defines this DGROUP in 32bit mode, but
I still don't know if it has any purpose anymore.


When I am defining my own compiler, do the traditional names of object
file segments, _TEXT, _DATA, STACK, _BSS, CONST (to name a few from the
MS manual) any meaning? When I place my code in a _TEXT segment, the
disassembler will show a list of the instructions; this does not happen
if I name the segment FOO. Is there any particular reason I want my
code in a _TEXT segment rather than FOO?


If this subject is covered in the Linkers & Loaders book in sufficient
details to answer my questions, I have not come across it yet. Please
refere to a specific chapter if there's something I should read there.


[1] Or if I am, I'm not aware of it.


--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk


[Segment groups were useful on the '286 but are pointless on later
machines since a single segment can be the full size of the address
space. My dim recollection is that some software treated segment names
like _TEXT and _DATA specially so your life will likely be easier if
you put the code in _TEXT, the static data in _DATA, and the
uninitialized or zero initialized data in _BSS. I didn't say anything
about this in Linkers and Loaders since by that time segmented
addressing was just an historical curiosity. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.