@@ -20,25 +20,27 @@ ItaniumVTableReader::ItaniumVTableReader(const std::shared_ptr<Executable>& imag
20
20
21
21
void ItaniumVTableReader::_initFormatConstants () {
22
22
if (dynamic_cast <format::ELF*>(mImage .get ())) {
23
- _constant.SEGMENT_DATA = " .data.rel.ro" ;
24
- _constant.SEGMENT_TEXT = " .text" ;
25
- _constant.PREFIX_VTABLE = " _ZTV" ;
26
- _constant.PREFIX_TYPEINFO = " _ZTI" ;
27
- _constant.SYM_CLASS_INFO = " _ZTVN10__cxxabiv117__class_type_infoE" ;
28
- _constant.SYM_SI_CLASS_INFO = " _ZTVN10__cxxabiv120__si_class_type_infoE" ;
29
- _constant.SYM_VMI_CLASS_INFO = " _ZTVN10__cxxabiv121__vmi_class_type_infoE" ;
30
- _constant.SYM_PURE_VFN = " __cxa_pure_virtual" ;
23
+ _constant.SEGMENT_DATA = " .data.rel.ro" ;
24
+ _constant.SEGMENT_READONLY_DATA = " .rodata" ;
25
+ _constant.SEGMENT_TEXT = " .text" ;
26
+ _constant.PREFIX_VTABLE = " _ZTV" ;
27
+ _constant.PREFIX_TYPEINFO = " _ZTI" ;
28
+ _constant.SYM_CLASS_INFO = " _ZTVN10__cxxabiv117__class_type_infoE" ;
29
+ _constant.SYM_SI_CLASS_INFO = " _ZTVN10__cxxabiv120__si_class_type_infoE" ;
30
+ _constant.SYM_VMI_CLASS_INFO = " _ZTVN10__cxxabiv121__vmi_class_type_infoE" ;
31
+ _constant.SYM_PURE_VFN = " __cxa_pure_virtual" ;
31
32
return ;
32
33
}
33
34
if (dynamic_cast <format::MachO*>(mImage .get ())) {
34
- _constant.SEGMENT_DATA = " __const" ;
35
- _constant.SEGMENT_TEXT = " __text" ;
36
- _constant.PREFIX_VTABLE = " _ZTV" ; // internal
37
- _constant.PREFIX_TYPEINFO = " _ZTI" ;
38
- _constant.SYM_CLASS_INFO = " __ZTVN10__cxxabiv117__class_type_infoE" ;
39
- _constant.SYM_SI_CLASS_INFO = " __ZTVN10__cxxabiv120__si_class_type_infoE" ;
40
- _constant.SYM_VMI_CLASS_INFO = " __ZTVN10__cxxabiv121__vmi_class_type_infoE" ;
41
- _constant.SYM_PURE_VFN = " ___cxa_pure_virtual" ;
35
+ _constant.SEGMENT_DATA = " __const" ;
36
+ _constant.SEGMENT_READONLY_DATA = " __const" ;
37
+ _constant.SEGMENT_TEXT = " __text" ;
38
+ _constant.PREFIX_VTABLE = " _ZTV" ; // internal
39
+ _constant.PREFIX_TYPEINFO = " _ZTI" ;
40
+ _constant.SYM_CLASS_INFO = " __ZTVN10__cxxabiv117__class_type_infoE" ;
41
+ _constant.SYM_SI_CLASS_INFO = " __ZTVN10__cxxabiv120__si_class_type_infoE" ;
42
+ _constant.SYM_VMI_CLASS_INFO = " __ZTVN10__cxxabiv121__vmi_class_type_infoE" ;
43
+ _constant.SYM_PURE_VFN = " ___cxa_pure_virtual" ;
42
44
return ;
43
45
}
44
46
}
@@ -93,7 +95,7 @@ DumpVFTableResult ItaniumVTableReader::dumpVFTable() {
93
95
std::string ItaniumVTableReader::_readZTS () {
94
96
auto value = mImage ->read <intptr_t >();
95
97
// spdlog::debug("\tReading ZTS at {:#x}", value);
96
- if (!mImage ->isInSection (value, _constant.SEGMENT_DATA )) return {};
98
+ if (!mImage ->isInSection (value, _constant.SEGMENT_READONLY_DATA )) return {};
97
99
auto str = mImage ->readCString (value, 2048 );
98
100
return str.empty () ? str : _constant.PREFIX_TYPEINFO + str;
99
101
}
@@ -147,15 +149,15 @@ std::optional<VTable> ItaniumVTableReader::readVTable() {
147
149
}
148
150
// read: TypeInfo
149
151
type = _readZTI ();
150
- if (!type.starts_with (_constant.PREFIX_TYPEINFO )) {
151
- spdlog::warn (
152
- " Failed to reading vtable at {:#x} in {}. [INVALID_TYPEINFO]" ,
153
- mImage ->last (),
154
- symbol.has_value () ? *symbol : " <unknown>"
155
- );
156
- return std::nullopt;
157
- }
158
152
if (!type.empty ()) {
153
+ if (!type.starts_with (_constant.PREFIX_TYPEINFO )) {
154
+ spdlog::warn (
155
+ " Failed to reading vtable at {:#x} in {}. [INVALID_TYPEINFO]" ,
156
+ mImage ->last (),
157
+ symbol.has_value () ? *symbol : " <unknown>"
158
+ );
159
+ return std::nullopt;
160
+ }
159
161
if (!symbol) symbol = _constant.PREFIX_VTABLE + StringRemovePrefix (type, _constant.PREFIX_TYPEINFO );
160
162
result.mTypeName = type;
161
163
}
0 commit comments