Skip to content

Commit ce70995

Browse files
committed
feat(android-stl): FIx std::vector<bool> implementation
1 parent 95cadd9 commit ce70995

File tree

3 files changed

+34
-9
lines changed

3 files changed

+34
-9
lines changed

broma_ida/broma/codegen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BromaCodegen:
1212
FILE_HEADER = """// Generated by BromaIDA, do not modify
1313
#include <array>
1414
15-
#define BROMAIDA_PLATFORM_MACRO_NAME
15+
#define {BROMAIDA_PLATFORM_MACRO_NAME}
1616
#define BROMAIDA_USE_CUSTOM_GNUSTL {BROMAIDA_USE_CUSTOM_GNUSTL_VALUE}
1717
// platform shorthands
1818
#define BROMAIDA_IS_PLATFORM_MACHO {BROMAIDA_IS_PLATFORM_MACHO_VALUE}

broma_ida/broma/importer.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,16 @@ def set_function_signature(ea: int, binding: Binding):
320320
if "const" in binding.parameters[idx].type:
321321
stl_type.set_const()
322322

323-
function_data[
324-
idx + (0 if binding.is_static else 1)
325-
].type = stl_type
323+
try:
324+
function_data[
325+
idx + (0 if binding.is_static else 1)
326+
].type = stl_type
327+
except IndexError:
328+
ida_warning(
329+
"Couldn't fix STL parameters for "
330+
f"""function {binding.qualified_name}!""",
331+
)
332+
return
326333

327334
if ret_has_stl_type:
328335
stl_type = ida_tinfo_t()

broma_ida/types/stl_includes.hpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,16 @@ struct custom_less : std::less<T>
188188
bool pad;
189189
};
190190

191+
#if BROMAIDA_IS_PLATFORM_ANDROID
192+
namespace stl
193+
{
194+
struct _bit_iterator {
195+
std::uintptr_t* m_bitptr;
196+
unsigned int m_offset;
197+
};
198+
}
199+
#endif
200+
191201
namespace std
192202
{
193203
// providing custom specializations for standard library templates is
@@ -216,12 +226,20 @@ namespace std
216226

217227
#if BROMAIDA_IS_PLATFORM_ANDROID
218228
template <>
219-
class vector<bool, allocator<bool>>
220-
{
221-
_Bit_iterator _M_start;
222-
_Bit_iterator _M_finish;
223-
_Bit_type* _M_end_of_storage;
229+
class vector<bool> {
230+
protected:
231+
stl::_bit_iterator m_start;
232+
stl::_bit_iterator m_end;
233+
std::uintptr_t* m_capacity_end;
224234
};
235+
236+
// template <>
237+
// class vector<bool, allocator<bool>>
238+
// {
239+
// _Bit_iterator _M_start;
240+
// _Bit_iterator _M_finish;
241+
// _Bit_type* _M_end_of_storage;
242+
// };
225243
#elif BROMAIDA_IS_PLATFORM_MACHO
226244
template <>
227245
class vector<bool, allocator<bool>>

0 commit comments

Comments
 (0)