Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.compilers > #2542

Re: The different groups and segments of object files

Path csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.misty.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end
From Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid>
Newsgroups comp.compilers
Subject Re: The different groups and segments of object files
Date Thu, 25 Jun 2020 23:13:33 +0800
Organization Easynews - www.easynews.com
Lines 53
Sender news@iecc.com
Approved comp.compilers@iecc.com
Message-ID <20-06-021@comp.compilers> (permalink)
References <20-06-004@comp.compilers> <20-06-006@comp.compilers>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 8bit
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
X-submission-address compilers@iecc.com
X-moderator-address compilers-request@iecc.com
X-FAQ-and-archives http://compilers.iecc.com
In-Reply-To <20-06-006@comp.compilers>
Content-Language en-GB
Xref csiph.com comp.compilers:2542

Show key headers only | View raw


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]

Back to comp.compilers | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

The different groups and segments of object files Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.com> - 2020-06-19 23:22 +0800
  Re: The different groups and segments of object files gah4@u.washington.edu - 2020-06-19 14:12 -0700
    Re: The different groups and segments of object files gah4@u.washington.edu - 2020-06-21 01:50 -0700
    Re: The different groups and segments of object files Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2020-06-25 22:41 +0800
    Re: The different groups and segments of object files Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2020-06-25 22:40 +0200
      Re: The different groups and segments of object files Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2020-06-26 00:09 +0200
        Re: The different groups and segments of object files gah4@u.washington.edu - 2020-07-02 00:36 -0700
  Re: The different groups and segments of object files Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2020-06-20 16:01 +0200
    Re: The different groups and segments of object files Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> - 2020-06-25 23:13 +0800
      Re: The different groups and segments of object files Hans-Peter Diettrich <DrDiettrich1@netscape.net> - 2020-06-25 22:52 +0200

csiph-web