}
static void $strlcpy(char *dst, const char *src, size_t size) {
+ if (src == NULL)
+ src = "(null)";
if (size == 0)
return;
size_t i(0);
} dst[i] = '\0';
}
+__attribute__((__unused__))
+static void $snprintfp(char *dst, size_t size, const void *pointer) {
+ uintptr_t value(reinterpret_cast<uintptr_t>(pointer));
+ char buffer[32];
+ char *end(buffer + sizeof(buffer));
+ *--end = '\0';
+ if (value == 0)
+ *--end = '0';
+ else do {
+ unsigned digit(value & 0xf);
+ value >>= 4;
+ *--end = (digit < 10 ? '0' : 'a' - 10) + digit;
+ } while (value != 0);
+ *--end = 'x';
+ *--end = '0';
+ $strlcpy(dst, end, size);
+}
+
#ifdef __LP64__
typedef struct mach_header_64 mach_header_xx;
typedef struct nlist_64 nlist_xx;
lcp->cmdsize % sizeof(long) != 0 || lcp->cmdsize <= 0 || \
reinterpret_cast<const uint8_t *>(lcp) + lcp->cmdsize > reinterpret_cast<const uint8_t *>(load_commands) + mach->sizeofcmds \
) \
- return NULL; \
+ break; \
else if (lcp->cmd != lc) \
continue; \
else if (lcp->cmdsize < sizeof(type)) \
- return NULL; \
+ break; \
else if (const type *command = reinterpret_cast<const type *>(lcp))
static const mach_header_xx *Library(struct dyld_all_image_infos *infos, const char *name) {