views:

64

answers:

1

In ELF file format we have an Alignment field in Segment Header Table aka Program Header Table.

In case of Windows PE file format they take it to next level the Sections have two alignment values, one within the disk file and the other in memory. The PE file header specifies both of these values.

I didn't understand a thing about this alignment. What do we need it for? How & Where is it used? Again, I don't know what is alignment in binary file format context but why do we need it?

+2  A: 

Well, alignment is usually stretching the storage size of some value to occupy some "round" space, like 32, 64, 128 bit etc.

If we're talking about binary formats, it may be done in order to optimize format processing. Read/write operations can be quicker when you read/write some "round" data length portions.

I found a reading for you, formulated in better words I can come up with right now:

Data structure alignment

Data structure alignment is the way data is arranged and accessed in computer memory. It consists of two separate but related issues: data alignment and data structure padding. When a modern computer reads from or writes to a memory address, it will do this in word sized chunks (e.g. 4 byte chunks on a 32-bit system). Data alignment means putting the data at a memory offset equal to some multiple of the word size, which increases the system's performance due to the way the CPU handles memory. To align the data, it may be necessary to insert some meaningless bytes between the end of the last data structure and the start of the next, which is data structure padding.

Developer Art
can you please be little more descriptive?
claws
I'm trying to...
Developer Art
Thank you!! Now, I'm very clear.
claws