Serge Lamikhov-Center
fc0293ebbd
Explicit element size for array accessor
2021-08-13 09:40:49 +03:00
Serge Lamikhov-Center
91c8c7770a
Add GNU specific types
2021-08-13 09:37:52 +03:00
Serge Lamikhov-Center
ef262285dc
Add support for GNU hash lookup algorithm
2021-07-27 16:30:41 +03:00
Serge Lamikhov-Center
46b1e22414
Add section type verification for hash section
2021-07-23 16:58:06 +03:00
Artem Belevich
028b4117fa
Update AMDGPU macros.
...
The values are based on LLVM's ELF.h
https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/BinaryFormat/ELF.h
Related issue: ROCm-Developer-Tools/HIP#2259
2021-06-17 09:51:51 +03:00
Serge Lamikhov-Center
79fcd11595
Add check for data endianess flags
2021-06-05 16:46:24 +03:00
Serge Lamikhov-Center
0fac6ce45b
Add a convinience function 'add_section()' to segment class
...
It is not clear why this hasn't been done initially
2021-04-08 17:03:05 +03:00
Serge Lamikhov-Center
f591a3b74e
Add explicit declaration of move constructor and move assignment
2021-03-30 00:59:06 +03:00
Serge Lamikhov-Center
29114f6538
Explicetly delete the copy constructor and assignment operator
2021-03-29 21:17:57 +03:00
Serge Lamikhov-Center
7409369fc0
Change the data segment alignment for newer Linux kernels
2021-03-29 01:22:43 +03:00
Serge Lamikhov-Center
a01d7285cf
Generated by newer automake tools
2021-03-28 10:16:39 +03:00
Serge Lamikhov-Center
becd79d05c
Support stringstream by filling gaps in output stream
2021-03-27 21:14:56 +03:00
Serge Lamikhov-Center
57e614a486
Remove postfix underscore in parameter names
2021-02-05 10:40:18 +02:00
Serge Lamikhov-Center
762c59a2bb
Change copyright period
2021-01-19 09:43:01 +02:00
Serge Lamikhov-Center
7e9c0a4675
In spite of the previous commit, clang-formatter inserts multi-line comments.
...
This is an attempt to avoid this
2021-01-19 09:37:18 +02:00
Kevin Stefanik
8ab497c57b
Removing backslashes from AMDGPU comments so as not to trigger compiler warnings.
2021-01-19 08:41:42 +02:00
Serge Lamikhov-Center
eaae4e1e13
Fix endianness conversion for array acceessor
2021-01-13 11:18:23 +02:00
Serge Lamikhov-Center
8037e5a42a
Add 'validate' function to C language wrapper
2021-01-08 00:11:20 +02:00
Martin Bickel
3e55690e6d
Added new check for section/progHeader consistency
2021-01-07 12:43:21 +02:00
Serge Lamikhov-Center
def3653abc
Increase version number to 3.9
2020-12-22 14:30:16 +02:00
Serge Lamikhov-Center
22ff134363
Address array section accessor added
...
The accessor is useful for manipulation of such sections as .ctors,
.dtors, .init_array and .fini_array
2020-12-22 14:10:16 +02:00
Serge Lamikhov-Center
0368a08624
Add more machine codes
2020-12-21 10:57:32 +02:00
Serge Lamikhov-Center
a8831c5d74
Address warnings reported by MS VS analyzer
2020-10-30 18:06:26 +02:00
Serge Lamikhov-Center
3c434f7587
Address warnings reported by MS VS
2020-10-30 17:54:13 +02:00
Serge Lamikhov-Center
f02366804f
More apropriate way to avoid macro extraction
2020-10-17 23:57:58 +03:00
Serge Lamikhov-Center
0826f15d0b
Use funny syntax to prevent min() macro in MSVS
2020-10-17 22:51:53 +03:00
Serge Lamikhov-Center
49c2de32ec
In dynamic section count entries until DT_NULL; Add const for modinfo params
2020-10-16 01:29:26 +03:00
Serge Lamikhov-Center
49c676ad06
Remove unused var; Use std::swap()
2020-10-10 08:51:11 +03:00
Serge Lamikhov-Center
4c0153d752
C language interoperability example added
2020-10-10 00:31:35 +03:00
Serge Lamikhov-Center
937978973f
Remove usage of try/catch blocks
2020-08-28 22:38:40 -07:00
Serge Lamikhov-Center
e18e5bc261
Use a header for version information
2020-08-24 10:24:09 -07:00
Serge Lamikhov-Center
c92b6f3fb5
Fix a VS warning
2020-08-23 11:22:34 +03:00
Serge Lamikhov-Center
e00bf98230
Add modinfo to VS project
2020-08-23 09:57:21 +03:00
Serge Lamikhov-Center
761d70da2c
Add dump function for .modinfo section
2020-08-22 23:10:11 -07:00
Serge Lamikhov-Center
b4c245f5a8
Add .modinfo section accessor
2020-08-22 15:11:58 -07:00
Serge Lamikhov-Center
9c739b49a0
Reformat sources by using clang-format
...
It is not perfect (and, probably, it is worser than it was before), but, it is automatic
2020-08-21 07:56:08 -07:00
Serge Lamikhov-Center
46acd5c16d
Pass all used vars by reference
2020-08-21 00:55:28 -07:00
Serge Lamikhov-Center
aa4d2c5a74
Substitute memcpy() by std::copy()
2020-08-20 02:13:04 -07:00
Serge Lamikhov-Center
fe17eb40aa
Implement swap_symbols() for relocation section.
...
The function can be used as a callback for arrange_local_symbols()
2020-08-19 22:44:58 -07:00
Serge Lamikhov-Center
d255a35259
Address warnings reported by VS
2020-08-19 23:58:07 +03:00
Serge Lamikhov-Center
c6e5eb0aad
Update Copyright period
2020-08-19 13:47:20 -07:00
Serge Lamikhov-Center
6d3d5467a2
Permit substitution of relocation entry by using set_entry() function call
2020-08-19 13:39:15 -07:00
Serge Lamikhov-Center
5a5ba2dc09
Add a callback to arrange_local_symbols()
2020-08-19 07:28:47 -07:00
Serge Lamikhov-Center
8e0b5754e4
arrange_local_symbols() added
...
ELF standard requires that all STB_LOCAL symbols will go prior others and sh_info entry will contain the number of the local symbols
2020-08-18 12:57:45 -07:00
Serge Lamikhov-Center
d2c3fb6a14
Refactoring - remove unnecessary check
2020-08-15 18:56:13 +03:00
Serge Lamikhov-Center
8d79cc0929
Add function source delimiters
2020-08-15 18:33:50 +03:00
Serge Lamikhov-Center
a59cbf6674
Alighn code with whitespaces
2020-08-08 09:55:42 -07:00
Serge Lamikhov-Center
5f904722f6
New machine numbers added
2020-08-08 08:23:25 -07:00
Serge Lamikhov-Center
b1961db18b
Fix compilation warnings in VS 2019 v16.7.0
2020-08-07 20:27:13 +03:00
Serge Lamikhov-Center
a735f412ec
Remove unused header
2020-06-10 08:01:20 -07:00
Serge Lamikhov-Center
9cf8821c03
Prevents seg fault described in #42
2020-06-10 06:53:29 -07:00
Serge Lamikhov-Center
b56b93de1b
Remove implementation functions from section interface
2020-06-09 23:46:41 -07:00
Pierre Bélissent
6e237576f0
Issue serge1/ELFIO#19 : Test case to reproduce, and correction
2020-06-06 22:26:12 +03:00
Serge Lamikhov-Center
453929342f
Don't access a note entry in case namesz is less than 1
2020-05-29 05:26:43 -07:00
Serge Lamikhov-Center
a935b5472e
The counter type for 'symbol_tables' has been changed to Elf_Xword
2020-05-29 13:54:28 +03:00
Serge Lamikhov-Center
64626605ed
Remove tab characters
2020-02-22 18:22:23 +02:00
Serge Lamikhov-Center
3e4a2fabfd
Add tests for the new flavor of get_symbol()
2020-02-22 11:31:27 +02:00
Serge Lamikhov-Center
46d081d5df
Add autoxxx tools to the ELFIOTest directory
2020-02-15 23:24:20 +02:00
Alfred Bratterud
d8e8a4cbb4
Added get_symbol by value and generic linear search
2020-02-15 23:10:01 +02:00
Serge Lamikhov-Center
15cd4b1bf2
Remove tabs
2019-04-28 09:00:14 +03:00
Gleb Struchalin
15340ddf9c
Avoid warning about initialization reorder (-Wreorder) on GCC
2019-04-28 08:57:04 +03:00
Serge Lamikhov-Center
cdafaa0abf
Prevent potential dereferencing of NULL pointer
2019-04-19 15:05:50 +03:00
Serge Lamikhov-Center
858b7a3b70
Names and tabs refactoring
2019-04-19 14:52:20 +03:00
Gleb Struchalin
a314b28193
Replaced tabs by spaces
2019-04-19 13:55:00 +03:00
Gleb Struchalin
925af0d3d5
Added overload to elfio::save which accepts std::ostream
2019-04-19 13:55:00 +03:00
Gleb Struchalin
e64acb2b2e
Added parentheses in ELF64_R_INFO macro for 's' parameter
2019-04-19 13:55:00 +03:00
Vinicius Rangel
350008420f
dynamic_section_accessor#add_entry params updated
...
Changed useless by-reference params to by-value
which forbids number literals (i.e. DT_*)
Added missing const keyword to std::string& parameter
2019-04-19 09:24:40 +03:00
Serge Lamikhov-Center
cb3bd43ca5
Avoid warning regarding incompatible integer types
2018-11-03 18:11:32 +02:00
Alex Voicu
9f1e1ae164
Fix alignment.
2018-11-02 23:16:14 +02:00
Alex Voicu
144946f753
Add support for AMDGPU specific ELF bits.
2018-11-02 23:16:14 +02:00
Serge Lamikhov-Center
9461ce1167
Fix "Call to virtual function during construction". Thanks to Pavel Kryukov
2018-11-02 23:05:26 +02:00
Pavel I. Kryukov
e4abc190d6
Cast -1 to Elf_Half explicitly to suppress Visual Studio warning
2018-08-25 22:41:06 +03:00
Pavel I. Kryukov
6a2e8c78b0
Avoid hiding local variable by another local variable in elfio::load_sections
2018-08-25 22:40:00 +03:00
Jingxuan He
4b9ff89770
modify get_ordered_segments
2018-05-05 19:32:49 +03:00
Tobias Klauser
37ebcd91b8
Fix two gcc -Wignored-qualifiers warnings
...
Fix the following two gcc warnings:
elfio/elfio_section.hpp:50:36: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
const size_t get_stream_size() const
^
elfio/elfio_segment.hpp:99:23: warning: type qualifiers ignored on function return type [-Wignored-qualifiers]
get_stream_size() const
2018-05-05 19:30:09 +03:00
alvaro
bc5f17b0fc
Fix more NULL dereferences
...
Crash 7d695153fd8052529d480c2352d4ada33a44bada
2017-10-04 20:47:51 +03:00
alvaro
abab994411
Fix NULL deference for no ELF files
...
Fix crash 060833f08dc14d1712428742b3cad7af17b36bb7
2017-10-04 20:47:51 +03:00
alvaro
bd5f2128ae
Check size for segment
...
Fix crash b82f05b0b25c8fdc98480e6d76b6d5f9164ae2bc
Running: crash-b82f05b0b25c8fdc98480e6d76b6d5f9164ae2bc
==2850==WARNING: AddressSanitizer failed to allocate 0x400000004000001 bytes
==2850==AddressSanitizer's allocator is terminating the process instead of returning 0
==2850==If you don't like this behavior set allocator_may_return_null=1
==2850==AddressSanitizer CHECK failed: /home/alvaro/tools/llvm/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc:22
1 "((0)) != (0)" (0x0, 0x0)
2017-10-04 20:47:51 +03:00
alvaro
1a3cb25a7c
Fix oob read terminating data with 0
...
Fix crash e3c41070342cf84dea077356ddbb8ebf4326a601
==12073==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6110000003bb at pc 0x0000004c234c bp 0x7fcf6359ec30 sp 0x7fcf6359e3
e0
READ of size 11 at 0x6110000003bb thread T0
#0 0x4c234b in __interceptor_strlen.part.30 /home/alvaro/tools/llvm/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitize
r_common_interceptors.inc:301
#1 0x7165e6579d87 in std::char_traits<char>::length(char const*) /build/gcc-multilib/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3
/include/bits/char_traits.h:269
#2 0x7165e6579d87 in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std
::allocator<char> const&) /build/gcc-multilib/src/gcc-build/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.h:495
#3 0x5c3333 in ELFIO::elfio::load_sections(std::istream&) /home/alvaro/fuzzers/elfio/ELFIO/examples/libfuzzer/../../elfio/elfio.hpp
:413:44
2017-10-04 20:47:51 +03:00
alvaro
39f8614f17
Added stream_size into section
...
This will allow to perform some security checks when reading size values
from ELF file
Fix crash e1ce7cecf01cf800397a4302854d9d76fa19763c
2017-10-04 20:47:51 +03:00
Vašek Potoček
972f89e022
Better support for read-only ELF access
2017-10-04 20:33:10 +03:00
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
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
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
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