Skip to content

Commit

Permalink
Add __printflike to lilu_os_log declaration (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhinakg authored Apr 27, 2023
1 parent 3f61754 commit f07e333
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Lilu/Headers/kern_util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ extern proc_t kernproc;
*
* @param format formatted string
*/
EXPORT extern "C" void lilu_os_log(const char *format, ...);
EXPORT extern "C" void lilu_os_log(const char *format, ...) __printflike(1, 2);

/**
* Two-way substring search
Expand Down
2 changes: 1 addition & 1 deletion Lilu/Sources/kern_compression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ static uint8_t *decompressInternal(uint32_t compression, uint32_t *dstlen, const

if (!buffer) Buffer::deleter(decompressedBuf);
} else {
SYSLOG("comp", "failed to allocate memory for decompression buffer of %u", dstlen);
SYSLOG("comp", "failed to allocate memory for decompression buffer of %u", *dstlen);
}

return 0;
Expand Down
14 changes: 7 additions & 7 deletions Lilu/Sources/kern_mach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ mach_vm_address_t MachInfo::solveSymbol(const char *symbol) {
// find if symbol matches
if (reinterpret_cast<uint8_t *>(symbolStr + symlen) <= endaddr && (nlist->n_type & N_STAB) == 0 && !strncmp(symbol, symbolStr, symlen)) {
DBGLOG("mach", "found symbol %s at 0x%llx (non-aslr 0x%llx), type %x, sect %x, desc %x", symbol, nlist->n_value + kaslr_slide,
nlist->n_value, nlist->n_type, nlist->n_sect, nlist->n_desc);
(uint64_t)nlist->n_value, nlist->n_type, nlist->n_sect, nlist->n_desc);
// the symbol values are without kernel ASLR so we need to add it
return nlist->n_value + kaslr_slide;
}
Expand Down Expand Up @@ -482,7 +482,7 @@ kern_return_t MachInfo::readSymbols(vnode_t vnode, vfs_context_t ctxt) {
// on 32-bit MH_OBJECT, symbols are not contained within a segment
sym_buf = Buffer::create<uint8_t>(sym_size);
if (!sym_buf) {
SYSLOG("mach", "Could not allocate enough memory (%lld) for symbols", sym_size);
SYSLOG("mach", "Could not allocate enough memory (%zu) for symbols", sym_size);
return KERN_FAILURE;
}

Expand All @@ -492,7 +492,7 @@ kern_return_t MachInfo::readSymbols(vnode_t vnode, vfs_context_t ctxt) {
lilu_os_memcpy(sym_buf, file_buf + sym_fileoff, sym_size);
return KERN_SUCCESS;
}
SYSLOG("mach", "requested linkedit (%llu %llu) exceeds file buf size (%u)", sym_fileoff, sym_size, file_buf_size);
SYSLOG("mach", "requested linkedit (%llu %zu) exceeds file buf size (%u)", sym_fileoff, sym_size, file_buf_size);
} else
#endif /* LILU_COMPRESSION_SUPPORT */
{
Expand Down Expand Up @@ -593,14 +593,14 @@ void MachInfo::findSectionBounds(void *ptr, size_t sourceSize, vm_address_t &vms
if (!strncmp(sect->sectname, sectionName, sizeof(sect->sectname))) {
auto sptr = static_cast<uint8_t *>(ptr) + sect->offset;
if (sptr + sect->size > endaddr) {
SYSLOG("mach", "found section %s size %u in segment %lu is invalid", sectionName, sno, vmsegment);
SYSLOG("mach", "found section %s size %u in segment %llu is invalid", sectionName, sno, (uint64_t)vmsegment);
return;
}
vmsegment = scmd->vmaddr;
vmsection = sect->addr;
sectionptr = sptr;
sectionSize = static_cast<size_t>(sect->size);
DBGLOG("mach", "found section %s size %u in segment %lu", sectionName, sno, vmsegment);
DBGLOG("mach", "found section %s size %u in segment %llu", sectionName, sno, (uint64_t)vmsegment);
return;
}

Expand All @@ -622,14 +622,14 @@ void MachInfo::findSectionBounds(void *ptr, size_t sourceSize, vm_address_t &vms
if (!strncmp(sect->sectname, sectionName, sizeof(sect->sectname))) {
auto sptr = static_cast<uint8_t *>(ptr) + sect->offset;
if (sptr + sect->size > endaddr) {
SYSLOG("mach", "found section %s size %u in segment %lu is invalid", sectionName, sno, vmsegment);
SYSLOG("mach", "found section %s size %u in segment %llu is invalid", sectionName, sno, (uint64_t)vmsegment);
return;
}
vmsegment = (vm_address_t)scmd->vmaddr;
vmsection = (vm_address_t)sect->addr;
sectionptr = sptr;
sectionSize = static_cast<size_t>(sect->size);
DBGLOG("mach", "found section %s size %u in segment %lu", sectionName, sno, vmsegment);
DBGLOG("mach", "found section %s size %u in segment %llu", sectionName, sno, (uint64_t)vmsegment);
return;
}

Expand Down
6 changes: 3 additions & 3 deletions Lilu/Sources/kern_user.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ void UserPatcher::patchSharedCache(vm_map_t taskPort, uint32_t slide, cpu_type_t
}

if (modStart && modEnd && offNum && patch.cpu == cpu) {
DBGLOG("user", "patch for %s in %lX %lX", mod->path, modStart, modEnd);
DBGLOG("user", "patch for %s in %llX %llX", mod->path, (uint64_t)modStart, (uint64_t)modEnd);
auto tmp = Buffer::create<uint8_t>(patch.size);
if (tmp) {
for (size_t k = 0; k < offNum; k++) {
Expand Down Expand Up @@ -860,7 +860,7 @@ bool UserPatcher::loadFilesForPatching() {
MachInfo::findSectionBounds(buf, fileSize, vmsegment, vmsection, sectionptr, size,
fileSegments[patch.segment], fileSections[patch.segment], patch.cpu);

DBGLOG("user", "findSectionBounds returned vmsegment %lX vmsection %lX sectionptr %p size %lu", vmsegment, vmsection, sectionptr, size);
DBGLOG("user", "findSectionBounds returned vmsegment %llX vmsection %llX sectionptr %p size %lu", (uint64_t)vmsegment, (uint64_t)vmsection, sectionptr, size);

if (size) {
uint8_t *start = reinterpret_cast<uint8_t *>(sectionptr);
Expand All @@ -881,7 +881,7 @@ bool UserPatcher::loadFilesForPatching() {
off_t valueOff = reinterpret_cast<uintptr_t>(start - pageOff - reinterpret_cast<uintptr_t>(sectionptr));
off_t segOff = vmsection-vmsegment+sectOff;

DBGLOG("user", "using it off %llX pageOff %llX new %lX segOff %llX", sectOff, pageOff, vmpage, segOff);
DBGLOG("user", "using it off %llX pageOff %llX new %llX segOff %llX", sectOff, (uint64_t)pageOff, (uint64_t)vmpage, segOff);

// We need binary entry, i.e. the page our patch belong to
LookupStorage *entry = nullptr;
Expand Down

0 comments on commit f07e333

Please sign in to comment.