Skip to content

Commit bab8690

Browse files
committed
Update ELFIO
1 parent 521d23b commit bab8690

17 files changed

+2884
-2289
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1-
[![License Info](https://img.shields.io/badge/license-Apache-blue.svg?style=flat-square)](https://github.com/TimScriptov/Disassembler) [![Play Store Info](https://img.shields.io/badge/Play_Store-v2.3-blue.svg?style=flat-square)](https://play.google.com/store/apps/details?id=com.mcal.disassembler)
1+
[![License Info](https://img.shields.io/badge/license-Apache-blue.svg?style=flat-square)](https://github.com/TimScriptov/Disassembler) [![Play Store Info](https://img.shields.io/badge/Play_Store-v2.5-blue.svg?style=flat-square)](https://play.google.com/store/apps/details?id=com.mcal.disassembler)
2+
3+
### Additional components
4+
> [ELFIO v3.9][1]<br>
5+
6+
[1]: https://github.com/serge1/ELFIO

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
minSdkVersion 21
1212
//noinspection OldTargetApi
1313
targetSdkVersion 29
14-
versionCode 24
15-
versionName "2.4"
14+
versionCode 25
15+
versionName "2.5"
1616
ndk {
1717
abiFilters 'armeabi-v7a', 'x86', 'arm64-v8a', 'x86_64'
1818
}

app/src/main/jni/elfio/elf_types.hpp

Lines changed: 640 additions & 561 deletions
Large diffs are not rendered by default.

app/src/main/jni/elfio/elfio.hpp

Lines changed: 368 additions & 303 deletions
Large diffs are not rendered by default.
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/*
2+
Copyright (C) 2001-present by Serge Lamikhov-Center
3+
4+
Permission is hereby granted, free of charge, to any person obtaining a copy
5+
of this software and associated documentation files (the "Software"), to deal
6+
in the Software without restriction, including without limitation the rights
7+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
copies of the Software, and to permit persons to whom the Software is
9+
furnished to do so, subject to the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included in
12+
all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
THE SOFTWARE.
21+
*/
22+
23+
#ifndef ELFIO_ARRAY_HPP
24+
#define ELFIO_ARRAY_HPP
25+
26+
#include <algorithm>
27+
28+
namespace ELFIO {
29+
30+
//------------------------------------------------------------------------------
31+
template <class S> class array_section_accessor_template
32+
{
33+
public:
34+
//------------------------------------------------------------------------------
35+
array_section_accessor_template( const elfio& elf_file, S* section )
36+
: elf_file( elf_file ), array_section( section )
37+
{
38+
}
39+
40+
//------------------------------------------------------------------------------
41+
Elf_Xword get_entries_num() const
42+
{
43+
Elf_Xword entry_size = elf_file.get_class() == ELFCLASS32
44+
? sizeof( Elf32_Addr )
45+
: sizeof( Elf64_Addr );
46+
return array_section->get_size() / entry_size;
47+
}
48+
49+
//------------------------------------------------------------------------------
50+
bool get_entry( Elf_Xword index, Elf64_Addr& address ) const
51+
{
52+
if ( index >= get_entries_num() ) { // Is index valid
53+
return false;
54+
}
55+
56+
if ( elf_file.get_class() == ELFCLASS32 ) {
57+
generic_get_entry_arr<Elf32_Addr>( index, address );
58+
}
59+
else {
60+
generic_get_entry_arr<Elf64_Addr>( index, address );
61+
}
62+
63+
return true;
64+
}
65+
66+
//------------------------------------------------------------------------------
67+
void add_entry( Elf64_Addr address )
68+
{
69+
if ( elf_file.get_class() == ELFCLASS32 ) {
70+
generic_add_entry_arr<Elf32_Addr>( address );
71+
}
72+
else {
73+
generic_add_entry_arr<Elf64_Addr>( address );
74+
}
75+
}
76+
77+
private:
78+
//------------------------------------------------------------------------------
79+
template <class T>
80+
void generic_get_entry_arr( Elf_Xword index, Elf64_Addr& address ) const
81+
{
82+
const endianess_convertor& convertor = elf_file.get_convertor();
83+
84+
const T temp = *reinterpret_cast<const T*>( array_section->get_data() +
85+
index * sizeof( T ) );
86+
address = convertor( temp );
87+
}
88+
89+
//------------------------------------------------------------------------------
90+
template <class T> void generic_add_entry_arr( Elf64_Addr address )
91+
{
92+
const endianess_convertor& convertor = elf_file.get_convertor();
93+
94+
T temp = convertor( (T)address );
95+
array_section->append_data( reinterpret_cast<char*>( &temp ),
96+
sizeof( temp ) );
97+
}
98+
99+
//------------------------------------------------------------------------------
100+
private:
101+
const elfio& elf_file;
102+
S* array_section;
103+
};
104+
105+
using array_section_accessor = array_section_accessor_template<section>;
106+
using const_array_section_accessor =
107+
array_section_accessor_template<const section>;
108+
109+
} // namespace ELFIO
110+
111+
#endif // ELFIO_ARRAY_HPP

0 commit comments

Comments
 (0)