[Fwd: Re: ELF bugfixes]
Signature · 4 lines
-- Regards Vladimir 'phcoder' Serbinenko
Quoted 29 lines · David Miller
From: phcoder <[email protected]>
Date: Thu, 12 Mar 2009 12:22:15 +0100Quoted 19 lines
Quoted 18 lines · David Miller
From: phcoder <[email protected]>
Date: Thu, 12 Mar 2009 09:23:34 +0100grub/elf.h line 81
Quoted 11 lines
Index:
include/grub/elf.h
===================================================================grub/elf.h +1
-1@@ -77,7 +77,7 @@Elf32_Half e_shentsize;/* Section header table entry size */ Elf32_Half e_shnum;/* Section header table entry count */ Elf32_Half e_shstrndx;/* Section header string table index */ -} Elf32_Ehdr; +} __attribute__ ((packed)) Elf32_Ehdr;There is no reason why you should need the packed attribute here. I can't think of any cpu where this could even remotely be necessary. And if it's not necessary, all it does it emit terribly suboptimal code on RISC cpus.
Quoted 1 line
If it doesn't make a difference in the structure why does the compiler generate different code?
Because packed also means that the alignment of the structure can't be assumed to be naturally word aligned. So the compiler has to use byte loads and stores to load a word, for example, on RISC machines.
Quoted 4 lines
This is because the packed attribute influences how the structure is embedded into other structures.
This attribute controls two different things, not just local packing.
I knew it but normally when you parse files normally offsets aren't guaranteed to be aligned. But now it seems that elf parser is written in a way to guarantee at least some alignments. Then this part of patch probably is to be dropped or changed to proper aligned attribute
Signature · 2 lines
Regards Vladimir 'phcoder' Serbinenko