The old implementation aligned the segment start. However, the
intended behaviour is to align the offset and the vaddr
(p_vaddr % p_align == p_offset % p_align). This is required for the
loader which can then operate on memory pages.
Only elf files with strange GNU_RELRO segments fail the load, save, cycle.
It would maybe a good idea to separate the layout functionality from the
current save. The current coupling of layout and save make it
impossible to build layouts which contain the elf header via the public
API.
Many example elfs (hello_32, hello_64, asm ...) require that the
first section directly follows the program header table. The
section header is then placed between segments or at the end.
This change prepares the late placement of section header table.
The initial implementation only made sure that all sections and segments
are properly aligned. This is enough for simple embedded applications
but can not deal with more complex layouts.
The new implementation should be more generic given that it respects the
virtual addresses of the individual sections.
One thing which is currently not supported by this rewrite are segments
which contain the program/segment header or even the whole elf header.
Static class members usually have to be defined explicitly which plays not
well with header only libraries. Moving the constant into the ELFIO scope
works around that problem.
The problem only shows up at -O0. Higher optimisations levels manage to
completely remove the references to the static member.
We have some elf files where a section (.ARM.exidx) is located in multiple segments.
To keep this property it is necessary to keep track of the emitted sections.
Furthermore, the correct sequence for the segment emission has to be determined.
This is done by postponing segments which are actually a subsequence of another segment.
Additionally the alignment is not considered as part of the file size of a segment anymore.
Fix segment header position when no segments are present
Dumper - dynamic section output added
Dynamic section reader tests are added
Signed-off-by: Serge Lamikhov-Center <to_serge@users.sourceforge.net>