Commit Graph

33 Commits

Author SHA1 Message Date
Serge Lamikhov-Center
8290078a64 Relocation entry endianness fix; Warnings elimination 2015-02-13 20:47:37 +02:00
Mario Werner
91e61ec4b2 use the NULL section instead of offset == 0
This change makes it possible to use the regular API to build up
elf files which include the file header.
2014-12-03 10:38:44 +01:00
Mario Werner
1676247836 fix alignment of segments during saving -> copied elfs are working
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.
2014-12-03 09:27:56 +01:00
Mario Werner
fe0c85995d add 4 byte alignment for the section table
this is probably not required but definitely does not hurt
2014-12-03 09:24:21 +01:00
Serge Lamikhov-Center
1db119a8ca Refactoring - a nicer code for is_subsequence_of()
Conflicts:
	elf_examples/asm_copy
2014-11-23 00:53:19 +02:00
Mario Werner
b91a43b378 special support for PHDR segments and segments which include the elf header
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.
2014-11-15 22:08:52 +01:00
Mario Werner
755b92c580 move the section table to the end of the elf file 2014-11-14 13:40:25 +01:00
Mario Werner
c743d0bf74 separated layout generation and saving
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.
2014-11-14 13:06:39 +01:00
Mario Werner
55c2841e47 changed order in which the sections are emitted
The fact that segments can contain header information as well as
sections requires that sections within segments are emitted first.
2014-11-14 10:37:50 +01:00
Mario Werner
0ece76b5eb rewrote the segment save logic to not only care about alignment
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.
2014-11-14 08:27:36 +01:00
Mario Werner
e5592ddfdd fix: make segment loading similar to readelf's algorithm
ALLOC sections are now matched against the virtual address space of
the segment. Non ALLOC sections still use the offset approach.
2014-11-14 08:04:55 +01:00
Serge Lamikhov-Center
7dd7dade6f Non-significant formatting 2014-08-09 10:56:18 +03:00
Vincent Huang
6d713f4d0a Added iterator for segments and sections
segments and sections were already stored as std::vector<T>.
This change simply exposes the std::vector<T>::iterator functions.
2014-08-07 23:12:35 -04:00
Serge Lamikhov-Center
33dcaf063f Use [i|o]stream instead of [i|o]fstream; The patch was provided by Jason Hiser
Test's fixes
2014-02-26 18:02:30 +02:00
Serge Lamikhov-Center
17f03740e6 Using macros for header fields access functions
Set segment's index upon its creation
Move to VS2013 projects
2014-02-26 17:30:43 +02:00
Mario Werner
1d2930abc7 redesigned save_segments_and_their_sections
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.
2014-02-17 11:52:25 +01:00
Mario Werner
5dd8ba29bd assign sections to the segments during load based on the offsets 2014-02-13 18:59:16 +01:00
Serge Lamikhov-Center
ed600e64f3 Ticket #10: Fix section type SHT_NOBITS file_size calculation 2013-05-16 17:58:09 +03:00
Serge Lamikhov-Center
ed6a40ada1 Proper calculate size difference between file_size/memory_size in case of section type SHT_NOBITS 2013-04-21 16:54:07 +03:00
Serge Lamikhov-Center
2ced96026d Remove 'mutable' specification in 'section' class 2013-03-21 02:13:50 +02:00
Serge Lamikhov-Center
1e82ef11b4 add_entry() functions are implemented for dynamic_section_accessor class
Signed-off-by: Serge Lamikhov-Center <to_serge@users.sourceforge.net>
2013-01-13 19:59:15 +02:00
Serge Lamikhov-Center
4b7061dc92 Dynamic section accessor is implemented
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>
2013-01-13 04:29:43 +02:00
Serge Lamikhov-Center
b78c0aca3d Convert all files to UNIX EOL 2012-11-27 11:45:28 +02:00
Serge Lamikhov-Center
d3a0732983 Use <elfio/> prefix for \#include files 2012-11-25 14:37:09 +02:00
Serge Lamikhov-Center
647aa544be Remove tabs; Fix line endianess 2012-11-25 00:23:05 +02:00
Serge Lamikhov-Center
16e9c36e28 Document updates; Small refactoring 2012-11-20 19:58:28 +02:00
Serge Lamikhov-Center
3203483e34 Prevent compilation warnings when compiled x64 target with VS2008 2012-07-24 12:10:16 +03:00
Serge Lamikhov-Center
bf2efcc32f Don't pass NULL pointer to set_name function 2012-07-24 00:00:11 +03:00
Serge Lamikhov-Center
e1d554978d Trim trailing space and remove tabs 2012-06-24 09:02:32 +03:00
Serge Lamikhov-Center
2cddbab258 To make memory_size bigger than file_size, set memory_size prior calling 'save' function 2012-06-24 08:50:29 +03:00
Serge Lamikhov-Center
1a957edfba Don't calculate section address if it was already initialized 2012-06-03 23:19:33 +03:00
Serge Lamikhov-Center
03da533493 Starting new site building 2012-03-09 12:01:14 +02:00
Serge Lamikhov-Center
493549e030 Initial 2012-02-18 12:01:36 +02:00