Re: The different groups and segments of object files

Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid>
Thu, 25 Jun 2020 23:13:33 +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)
Re: The different groups and segments of object files DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-06-25)
Re: The different groups and segments of object files DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-06-26)
Re: The different groups and segments of object files gah4@u.washington.edu (2020-07-02)
| List of all articles for this month |

From: Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid>
Newsgroups: comp.compilers
Date: Thu, 25 Jun 2020 23:13:33 +0800
Organization: Easynews - www.easynews.com
References: 20-06-004 20-06-006
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="43610"; mail-complaints-to="abuse@iecc.com"
Keywords: code, history, comment
Posted-Date: 25 Jun 2020 11:57:40 EDT
In-Reply-To: 20-06-006
Content-Language: en-GB

On 20/06/2020 10:01 pm, Hans-Peter Diettrich wrote:
> Am 19.06.2020 um 17:22 schrieb Johann 'Myrkraverk' Oskarsson:
>
>> 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?
>
> I think that it's not the segment name that enforces special handling
> but segment attributes. Eventually these attributes are defined in the
> various segment groups only, not at segment level?
>
> It depends on the target OS and hardware whether deailed hardware
> protection is applied to memory segments. Code segments can be read-only
> or execute-only, all others non-execute. Const segments also can/should
> be read-only. The same protection schemes can apply to paged memory. A
> compiler only can assign attributes to memory sections, the use of these
> attributes depends on the linker and loader for the target platform.


For this exercise, I'm using the OpenWatcom code generator. This
generator comes is several flavours, though I'm using only one for now,
the 386 [others are i86 (16bit), Alpha, PPC, MIPS, and a nonfunctional
S/370] and supports several operating systems.


The code generator allows me to specify an attribute per object file
segment, EXEC, GLOBAL, ROM, INIT, COMMON, PRIVATE; to name the few that
seem to have meaning outside OW itself. So they seem to be handled per
segment, rather than segment groups.


The group name is then queried by the code generator using a callback
mechanism. It doesn't seem documented under what circumstances (how
often) the code generator queries this, and I haven't browsed the code
nor done enough experiments to see what the granularity is.


Do you know if group names have any meaning in the modern world? DGROUP
seems like a traditional name. The OW disassembler tells me this when I
apply it to output from the C compiler, GROUP: 'DGROUP' CONST, CONST2,
_DATA. This group does not seem to list the _TEXT segment, which is
where the code lives. [Note, the code generator does not make assembly
files, it generates object code directly; unlike some other compilers.]


What I'm getting at is that, it's not so important what this code
generator does or doesn't do, but why I should choose one group name
over others; or the segment names [which as John has mentioned, choosing
the traditional names seems to make it much easier to interact with
existing linkers and object files.]


--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk
[Oops, see comment on previous message. -John]


Post a followup to this message

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