Commit Graph

295 Commits

Author SHA1 Message Date
Serge Lamikhov-Center
9f9407d301 Adjust test to the changes done for note section 2016-07-10 17:48:46 +03:00
Serge Lamikhov-Center
492498b563 Release 3.2 preparations 2016-07-10 14:35:16 +03:00
Serge Lamikhov-Center
b2525656a5 New e_machine numbers added 2016-07-10 12:36:52 +03:00
Serge Lamikhov-Center
3c5620d46d Make note section entries for 64-bit ELF file be the same as for 32-bit file
There are discrepancies in documentations. SCO documentation
(http://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section)
requires 8 byte entries alignment for 64-bit ELF file,
but Oracle's definition uses the same structure
for 32-bit and 64-bit formats.
(https://docs.oracle.com/cd/E23824_01/html/819-0690/chapter6-18048.html)

It looks like EM_X86_64 Linux implementation is similar to Oracle's
definition. Therefore, the same alignment works for both formats
2016-07-10 11:35:23 +03:00
Kevin Klues
e3e0d6dbdb Fixed off-by-one error in 'name' of add_note() function.
Previously, when assigning 'name' as a string, it's length was specified
using the full length of 'namesz'. However, this length includes the
trailing '\0' of the underlying char[]. This ultimately causes the C++
string that is created to (incorrectly) contain the '\0' character as
well. This leads to problems where e.g. the following will return false,
even when 'name' itself actually contains the string "GNU\0":

  if (name == "GNU") {
    return true;
  }
  return false;

To fix this, we should only include the length of the string minus the
trailing '\0'.
2016-07-02 11:02:20 -07:00
Serge Lamikhov-Center
8e7a29e128 Refactoring 2016-04-23 17:58:34 +03:00
Tim Strazzere
ecc45ede27 Prevent accessing pdata struct if it doesn't exist. 2016-04-23 16:37:48 +03:00
Tim Strazzere
88503347da Avoid SIGSEV due to non-existant string section. 2016-04-23 16:37:48 +03:00
Tim Strazzere
812f7299b3 Avoid SIGABRT due to over allocating during new instance of objects. 2016-04-23 16:37:48 +03:00
Serge Lamikhov-Center
69b6177bd6 Make '.shstrtab' section be explicitly aligned to 1 2015-09-26 15:01:56 +03:00
Serge Lamikhov-Center
d50e955ca0 Moving to Boost library 1.59.0 2015-09-26 13:03:17 +03:00
Serge Lamikhov-Center
f2e17bac87 Fix offset calculation for the case where section's align field is zero 2015-09-26 11:07:26 +03:00
Serge Lamikhov-Center
c46fe2a371 Moving to MSVC 2015 2015-08-22 20:06:31 +03:00
Serge Lamikhov-Center
3429026ab7 Include <iterator> header file 2015-08-22 20:04:02 +03:00
Serge Lamikhov-Center
b88df7bda8 The list of machine architectures was updated 2015-04-30 18:16:03 +03:00
Serge Lamikhov-Center
5c01ad4434 ARM .so file added 2015-03-19 01:00:22 +02:00
Serge Lamikhov-Center
5ec1fc8949 Prevent a crash when working with MN10300 ELF file 2015-02-25 00:57:51 +02:00
Serge Lamikhov-Center
2ed975be62 Example of MN10300 ELF file added 2015-02-24 08:59:02 +02:00
Serge Lamikhov-Center
c45e81fd32 String section accessor refactoring 2015-02-21 13:50:32 +02:00
Serge Lamikhov-Center
5e39e2197f stdint.h is a part of Visual Studio 2013 distribution already 2015-02-13 22:31:55 +02:00
Serge Lamikhov-Center
56585d98e2 Conditional compilation for boost library linkage 2015-02-13 22:21:12 +02:00
Serge Lamikhov-Center
4eb7a2d216 Release_3.1 2015-02-13 20:55:49 +02:00
Serge Lamikhov-Center
9e4502d90e Copyright year update 2015-02-13 20:51:07 +02:00
Serge Lamikhov-Center
8290078a64 Relocation entry endianness fix; Warnings elimination 2015-02-13 20:47:37 +02:00
Serge Lamikhov-Center
ce2faaa00e Release_3.0 2015-01-19 13:36:49 +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
d2a27c7d96 initialized a few variables to silence warnings when building with Wall 2014-12-03 09:45:21 +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
Serge Lamikhov-Center
a88cfacaca Use boost library version 1.57.0 2014-11-22 23:52:02 +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
Mario Werner
8dda93f2bb fixed a few warnings (signed-unsigned comparisions, unused param) 2014-11-13 18:24:03 +01:00
Mario Werner
22bd7ba77d fix: static class member MAX_DATA_ENTRIES is not defined -> linker error
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.
2014-11-13 18:23:02 +01:00
Mario Werner
c655d9bbca ignored the generated elf files 2014-11-13 18:20:27 +01:00
Mario Werner
39b67828a2 removed generated elf and object files from the repository 2014-11-13 18:19:56 +01:00
Mario Werner
c9cf1a6f8f updated gitignore file 2014-11-13 18:02:22 +01:00
Serge Lamikhov-Center
49c08c53e8 Release 2.3 2014-11-08 19:07:46 +02:00
Semi Malinen
5000c533ba Add const 2014-10-30 14:47:14 +02:00
Semi Malinen
695a05dc5d Do not index past the end of the chain table 2014-10-30 14:29:33 +02:00
Serge Lamikhov-Center
b830e5e452 Documentation update - new functions are described 2014-08-09 11:22:36 +03: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
b227bf1482 Add a test that verifies ARM executable which was generated by CLang and LLVM
Signed-off-by: Serge Lamikhov-Center <to_serge@users.sourceforge.net>
2014-02-27 19:42:57 +02:00
Mario Werner
c95b3395cb add an elf file before and after saving
( requested under https://github.com/serge1/ELFIO/pull/1 )
2014-02-26 18:58:43 +02:00