Commit Graph

167 Commits

Author SHA1 Message Date
Vašek Potoček
ced83b14be More 386 relocation types 2017-10-04 20:15:53 +03:00
Serge Lamikhov-Center
fbf8eafc2d Permit updating of e_version field of ELF header 2017-03-28 00:35:17 +03:00
Martin Bickel
b4127676ba Fix calculation of section alignment 2017-03-06 22:28:46 +02:00
Martin Bickel
a638f47edc new testcase for read/save sequence 2017-03-06 22:28:46 +02:00
Martin Bickel
e838986dae remove Makefile.in from version control, they are generated files 2017-03-06 22:28:46 +02:00
Martin Bickel
728a2b6523 Replace broken reference ELF file for testing
The existing ELF file was somehow seriously broken.
It's now replaced with the file generated by the current code of
ELFio, which seems to be working correctly.

So the test now serves as a regression test for future
changes.
2017-03-06 22:28:46 +02:00
Martin Bickel
65335f6a75 Integrate tests into automake 2017-03-06 22:28:46 +02:00
Martin Bickel
a2cd870eb9 Added tool for anonymizing ELF files 2017-03-06 22:28:46 +02:00
Martin Bickel
9e787dcf1e Additional assertions to prevent crashes 2017-03-06 22:28:46 +02:00
Martin Bickel
3385408d6b Rephrase condition of is_sect_in_seg() to make it more intuitive 2017-03-06 22:28:46 +02:00
Martin Bickel
fe78d06e81 Segment align updated when saving, not loading
After loading, the data model in memory should resemble the original ELF file as closely as possible,
so that ELF viewers based on elfio will print out the original values, not the calculated ones.
2017-02-18 19:25:21 +02:00
Martin Bickel
6c19078803 Fixed section to segment mapping for 0-length sections 2017-02-18 19:25:21 +02:00
Martin Bickel
6dad943222 Tests now use distinct output files, allowing for better post test analysis 2017-01-16 20:38:37 +02:00
Martin Bickel
d800c7b295 When saving a previously loaded ELF file, don't shrink segments' memory size 2017-01-16 20:38:37 +02:00
Martin Bickel
213dbedac2 Add sanity check when calculating alignment 2017-01-16 20:38:37 +02:00
Martin Bickel
fb5ec079ba new method for validating the loaded ELF file 2017-01-16 20:38:37 +02:00
Martin Bickel
d0cb172474 Expose getter for section.offset 2017-01-16 20:38:37 +02:00
Martin Bickel
a0de1960d6 Check for errors when loading segments 2017-01-16 20:38:37 +02:00
Serge Lamikhov-Center
878247108f Ignore sections of zero size. Thanks to Martin Bickel 2016-12-20 20:11:20 +02:00
Tobias Klauser
446e0c215c elfio_note: fix MSVC compiler warning
Fix the following MSVC compiler warning:

elfio/elfio_note.hpp(77): warning C4267: 'initializing' : conversion from 'size_t' to 'ELFIO::Elf_Word', possible loss of data

by changing the type of max_name_sizei to Elf_Xword, as
note_secton->get_size() returns Elf_Xword and note_start_positions also
contains members of type Elf_Xword.
2016-10-06 12:07:20 +02:00
Tobias Klauser
af4140a122 elfio: don't cast away const qualifiers
Don't cast away const qualifiers when accessing const data (e.g. section
data). This fixes the warnings such as the following when compiling with
GCC and the -Wcast-qual flag set:

warning: cast from type ‘const char*’ to type ‘ELFIO::Elf_Word* {aka unsigned int*}’ casts away qualifiers [-Wcast-qual]
2016-09-22 23:22:39 +03:00
Yutetsu TAKATSUKASA
fb26cf1002 resolve compiler warning by "-Wsign-compare" 2016-09-18 10:44:16 +09:00
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