flat assembler
Message board for the users of flat assembler.
Index
> Linux > Segments and sections |
Author |
|
revolution 30 Jan 2017, 05:23
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. |
|||
30 Jan 2017, 05:23 |
|
Tomasz Grysztar 30 Jan 2017, 07:51
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. |
|||
30 Jan 2017, 07:51 |
|
jorido 30 Jan 2017, 08:32
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.
|
|||
30 Jan 2017, 08:32 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.