Segment

R

raghu

Can anyone please tell me what are the different segments in a C
program? Where can I find more details regarding this?

Please help.

Merry Christmas and Happy New Year

Regards,
Raghu
 
D

David T. Ashley

raghu said:
Can anyone please tell me what are the different segments in a C
program? Where can I find more details regarding this?

You may find this page interesting reading:

http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/mem.html

"Segment" is a very system-specific notion. Some systems historically have
had shared "segments" optimized linking, loading, running common programs,
etc. in various ways.

Some systems historically have also had hardware limitations on the amount
of memory that could be in a segment, leading to various ways of linking and
loading large programs.

http://en.wikipedia.org/wiki/Memory_segment

Generally, any small 'C' program is going to have at minimum a)executable
code, b)stack, and c)memory for static and global variables.

Understanding the ELF format is a good first step.
 
R

Richard Heathfield

raghu said:
Can anyone please tell me what are the different segments in a C
program?

The term is not used within the C language specification. We have functions,
if that's any help to you.
 
W

Walter Roberson

raghu said:
The term is not used within the C language specification. We have functions,
if that's any help to you.

I note the local man pages use the term in at least one place:

strspn (or strcspn) returns the length of the initial segment of string
s1 which consists entirely of characters from (not from) string s2.

I don't have my Standard available to check the official wording.
 
R

Richard Heathfield

Walter Roberson said:
I note the local man pages use the term in at least one place:

strspn (or strcspn) returns the length of the initial segment of
string s1 which consists entirely of characters from (not from)
string s2.

I don't have my Standard available to check the official wording.

I am guilty of jumping to a conclusion. The Standard does indeed use the
term 'segment' in the docs for strcspn and strspn, to refer to the first
part of a string.
 
D

David T. Ashley

Richard Heathfield said:
Walter Roberson said:


I am guilty of jumping to a conclusion. The Standard does indeed use the
term 'segment' in the docs for strcspn and strspn, to refer to the first
part of a string.

Ah ... actually, you were right the first time. The term as the OP intended
is not really used.

It depends on whether you interpret "term" to be (the literal word) or (a
particular meaning of a word that can have several meanings). In this case
I'd support the second definition.

The OP intended "segment" as used in linker documentation or machine
architecture, things like ".data", ".bss", etc.

"segment" as cited above means "contiguous portion" or "subset" ... somewhat
different than the linker meaning.

If the specification includes an appendix on human parasitic infections and
they mention "segment" of a tapeworm, would it be fair to say that a
"segment" when talking about a tapeworm is different than a "segment" when
talking about a linker map? ... I kind of think they are different.
 
W

Walter Roberson

If the specification includes an appendix on human parasitic infections and
they mention "segment" of a tapeworm, would it be fair to say that a
"segment" when talking about a tapeworm is different than a "segment" when
talking about a linker map? ... I kind of think they are different.

That's fine, but the original poster did not say anything about
linker maps. I have quoted what was actually said, above.
If "segment" is mentioned only in connection with str[c]spn, then
it is only in connection with uses of str[c]spn that one has
"different segments in a C program".


(To clarify my position, I was the first to reply, and I posted a
"that's system specific; see further discussion at" answer. But then
I nitpicked Richard's answer, seeing as "Free Nitpicking!" is the
official newsgroup motto ;-) )
 
R

Richard Heathfield

David T. Ashley said:
Ah ... actually, you were right the first time.

No, I was wrong. The term *is* used within the C spec.
The term as the OP intended is not really used.

Probably true, and that's why I replied as I did originally. Nevertheless,
we only know what he said, not what he meant.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top