Joined: 24 Aug 2004
Location: MACS J1149 Lensed Star 1
The meanings are not fixed and different authors use different attributions.
So with that in mind we can say this:
A section is a portion of a file (usually a PE or ELF file) that defines some code/data.
A segment is a memory area in an x86 CPU that is accessed with the help of a segment register, like DS or ES etc.
Okay so far so good. Now we get to the tricky part. Some people also use segment to refer to a portion of a file that contains code or data or whatever. And some people use section to refer to an x86 CPU segment.
Now you should be totally confused. Sorry about that. The thing to take away from this is that you have to look at each document and work within the context that the author is describing. I wish there was better way, but unfortunately we appear to be stuck with it.
Joined: 16 Jun 2003
Location: Kraków, Poland
I would guess that the question is about the difference between SEGMENT and SECTION directives a defined by fasm in context of ELF output format. This is a terminology taken straight from the ELF specification.
A segment is a run-time entity defined in the Program Headers. It has no name, only attributes, and it is used to map an executable file into memory.
A section is defined in the Section Headers, has a name and attributes and is used mainly when linking object files. Linking combines the sections with the same name into a single section.
A linker usually combines multiple sections into a single segment, for example all code sections may be combined into a single segment with "executable" attribute.
When you look at the figure 1-1 in ELF specification, you may notice that Program Headers are mandatory for executable ELF, while Section Headers are only mandatory for the object file. Though linkers usually keep section headers in the executable files they create, mainly for informative purposes (e.g. debugging). But when you use "format ELF executable" in fasm, you create an executable that has no section headers at all and you only define segments.
Yes. And what are the mandatory sections or segments for a Linux x32 or 64 application/library which a programmer must define? I've read that for a Linux application there must be no sections defined in an asm file.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum