@@ -10,6 +10,7 @@ Module: Read ELF
10
10
// / Read ELF
11
11
12
12
#include " elf_reader.h"
13
+ #include < util/exception_utils.h>
13
14
14
15
#include < istream>
15
16
@@ -21,13 +22,13 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
21
22
sizeof (elf32_header));
22
23
23
24
if (!in)
24
- throw " failed to read ELF header" ;
25
+ throw deserialization_exceptiont ( " failed to read ELF header" ) ;
25
26
26
27
if (elf32_header.e_ident [0 ]!=0x7f ||
27
28
elf32_header.e_ident [1 ]!=' E' ||
28
29
elf32_header.e_ident [2 ]!=' L' ||
29
30
elf32_header.e_ident [3 ]!=' F' )
30
- throw " ELF header malformed (magic)" ; // NOLINT(readability/throw)
31
+ throw deserialization_exceptiont ( " ELF header malformed (magic)" );
31
32
32
33
elf_class=(elf_classt)elf32_header.e_ident [4 ];
33
34
@@ -40,15 +41,15 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
40
41
else if (ei_data==2 )
41
42
little_endian=false ;
42
43
else
43
- throw " ELF32 header malformed (EI_DATA)" ; // NOLINT(readability/throw)
44
+ throw deserialization_exceptiont ( " ELF32 header malformed (EI_DATA)" );
44
45
45
46
if (elf32_header.e_version !=1 )
46
- throw " unknown ELF32 version" ;
47
+ throw deserialization_exceptiont ( " unknown ELF32 version" ) ;
47
48
48
49
// get offset for section header
49
50
if (elf32_header.e_shoff ==0 ||
50
51
elf32_header.e_shnum ==0 )
51
- throw " ELF32 without section header" ; // NOLINT(readability/throw)
52
+ throw deserialization_exceptiont ( " ELF32 without section header" );
52
53
53
54
elf32_section_header_table.resize (elf32_header.e_shnum );
54
55
number_of_sections=elf32_header.e_shnum ;
@@ -68,7 +69,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
68
69
// string table
69
70
unsigned string_table_nr=elf32_header.e_shstrndx ;
70
71
if (string_table_nr>=elf32_section_header_table.size ())
71
- throw " ELF32 without string table" ; // NOLINT(readability/throw)
72
+ throw deserialization_exceptiont ( " ELF32 without string table" );
72
73
73
74
string_table_offset=section_offset (string_table_nr);
74
75
}
@@ -87,15 +88,15 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
87
88
else if (ei_data==2 )
88
89
little_endian=false ;
89
90
else
90
- throw " ELF64 header malformed (EI_DATA)" ; // NOLINT(readability/throw)
91
+ throw deserialization_exceptiont ( " ELF64 header malformed (EI_DATA)" );
91
92
92
93
if (elf64_header.e_version !=1 )
93
- throw " unknown ELF64 version" ;
94
+ throw deserialization_exceptiont ( " unknown ELF64 version" ) ;
94
95
95
96
// get offset for section header
96
97
if (elf64_header.e_shoff ==0 ||
97
98
elf64_header.e_shnum ==0 )
98
- throw " ELF64 without section header" ; // NOLINT(readability/throw)
99
+ throw deserialization_exceptiont ( " ELF64 without section header" );
99
100
100
101
elf64_section_header_table.resize (elf64_header.e_shnum );
101
102
number_of_sections=elf64_header.e_shnum ;
@@ -115,7 +116,7 @@ elf_readert::elf_readert(std::istream &_in):in(_in)
115
116
// string table
116
117
unsigned string_table_nr=elf64_header.e_shstrndx ;
117
118
if (string_table_nr>=elf64_section_header_table.size ())
118
- throw " ELF64 without string table" ; // NOLINT(readability/throw)
119
+ throw deserialization_exceptiont ( " ELF64 without string table" );
119
120
120
121
string_table_offset=section_offset (string_table_nr);
121
122
}
0 commit comments