#define S_16BYTE_LITERALS 0xE
#endif
+#ifndef CPU_SUBTYPE_ARM_V5TEJ
+ #define CPU_SUBTYPE_ARM_V5TEJ ((cpu_subtype_t) 7)
+#endif
+#ifndef CPU_SUBTYPE_ARM_XSCALE
+ #define CPU_SUBTYPE_ARM_XSCALE ((cpu_subtype_t) 8)
+#endif
+#ifndef CPU_SUBTYPE_ARM_V7
+ #define CPU_SUBTYPE_ARM_V7 ((cpu_subtype_t) 9)
+#endif
+#ifndef CPU_SUBTYPE_ARM_V7F
+ #define CPU_SUBTYPE_ARM_V7F ((cpu_subtype_t) 10)
+#endif
+#ifndef CPU_SUBTYPE_ARM_V7K
+ #define CPU_SUBTYPE_ARM_V7K ((cpu_subtype_t) 12)
+#endif
+#ifndef CPU_SUBTYPE_ARM_V7S
+ #define CPU_SUBTYPE_ARM_V7S ((cpu_subtype_t) 11)
+#endif
+
+#ifndef LC_LOAD_UPWARD_DYLIB
+ #define LC_LOAD_UPWARD_DYLIB (0x23|LC_REQ_DYLD) /* load of dylib whose initializers run later */
+#endif
+
+#ifndef EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER
+ #define EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER 0x10
+#endif
+#ifndef EXPORT_SYMBOL_FLAGS_REEXPORT
+ #define EXPORT_SYMBOL_FLAGS_REEXPORT 0x08
+#endif
+
+#ifndef LC_FUNCTION_STARTS
+ #define LC_FUNCTION_STARTS 0x26
+#endif
+
+#ifndef LC_DATA_IN_CODE
+ #define LC_DATA_IN_CODE 0x29
+#endif
+
+#ifndef LC_DYLIB_CODE_SIGN_DRS
+ #define LC_DYLIB_CODE_SIGN_DRS 0x2B
+#endif
+
+
#include "FileAbstraction.hpp"
#include "Architectures.hpp"
const macho_segment_command<P>* getSegment(const char *segname) const
{
- const macho_load_command<P>* const cmds = (macho_load_command<P>*)((uint8_t*)this + sizeof(macho_header<P>));
- const uint32_t cmd_count = this->ncmds();
+ const macho_load_command<P>* cmds = (macho_load_command<P>*)((uint8_t*)this + sizeof(macho_header<P>));
+ uint32_t cmd_count = this->ncmds();
const macho_load_command<P>* cmd = cmds;
for (uint32_t i = 0; i < cmd_count; ++i) {
if ( cmd->cmd() == macho_segment_command<P>::CMD ) {
- const macho_segment_command<P>* segcmd =
- (macho_segment_command<P>*)cmd;
+ const macho_segment_command<P>* segcmd = (macho_segment_command<P>*)cmd;
if (0 == strncmp(segname, segcmd->segname(), 16)) {
return segcmd;
}
}
- cmd = (const macho_load_command<P>*)(((uint8_t*)cmd)+cmd->cmdsize());
+ cmd = (macho_load_command<P>*)(((uint8_t*)cmd)+cmd->cmdsize());
}
return NULL;
}
const macho_section<P>* getSection(const char *segname, const char *sectname) const
{
- const macho_segment_command<P>* const segcmd = getSegment(segname);
+ const macho_segment_command<P>* segcmd = getSegment(segname);
if (!segcmd) return NULL;
const macho_section<P>* sectcmd = (macho_section<P>*)(segcmd+1);
- const uint32_t section_count = segcmd->nsects();
+ uint32_t section_count = segcmd->nsects();
for (uint32_t j = 0; j < section_count; ++j) {
if (0 == ::strncmp(sectcmd[j].sectname(), sectname, 16)) {
return sectcmd+j;
return NULL;
}
+ const macho_load_command<P>* getLoadCommand(int query) const
+ {
+ const macho_load_command<P>* cmds = (macho_load_command<P>*)((uint8_t*)this + sizeof(macho_header<P>));
+ uint32_t cmd_count = this->ncmds();
+ const macho_load_command<P>* cmd = cmds;
+ for (uint32_t i = 0; i < cmd_count; ++i) {
+ if ( cmd->cmd() == query ) {
+ return cmd;
+ }
+ cmd = (macho_load_command<P>*)(((uint8_t*)cmd)+cmd->cmdsize());
+ }
+ return NULL;
+ }
+
typedef typename P::E E;
private:
macho_header_content<P> header;