Bug 1360321 - 4a. Fix printf macro mismatches in mozglue; r=froydnj r=glandium

Fix printf macro mismatches where, for example, `PRIxPTR` is defined for
`long` but the ELF `Addr` type is defined as `long long`.

MozReview-Commit-ID: 8hXY1MpHPjS
This commit is contained in:
Jim Chen 2017-05-17 13:06:22 -04:00
parent 9579d51797
commit f5f1f202b1
4 changed files with 26 additions and 22 deletions

View File

@ -185,7 +185,7 @@ LoadedElf::InitDyn(const Phdr *pt_dyn)
switch (dyn->d_tag) {
case DT_HASH:
{
DEBUG_LOG("%s 0x%08" PRIxPTR, "DT_HASH", dyn->d_un.d_val);
DEBUG_LOG("%s 0x%08" PRIxPTR, "DT_HASH", uintptr_t(dyn->d_un.d_val));
const Elf::Word *hash_table_header = \
GetPtr<Elf::Word>(dyn->d_un.d_ptr);
symnum = hash_table_header[1];
@ -194,11 +194,11 @@ LoadedElf::InitDyn(const Phdr *pt_dyn)
}
break;
case DT_STRTAB:
DEBUG_LOG("%s 0x%08" PRIxPTR, "DT_STRTAB", dyn->d_un.d_val);
DEBUG_LOG("%s 0x%08" PRIxPTR, "DT_STRTAB", uintptr_t(dyn->d_un.d_val));
strtab.Init(GetPtr(dyn->d_un.d_ptr));
break;
case DT_SYMTAB:
DEBUG_LOG("%s 0x%08" PRIxPTR, "DT_SYMTAB", dyn->d_un.d_val);
DEBUG_LOG("%s 0x%08" PRIxPTR, "DT_SYMTAB", uintptr_t(dyn->d_un.d_val));
symtab.Init(GetPtr(dyn->d_un.d_ptr));
break;
}

View File

@ -65,8 +65,9 @@ void debug_phdr(const char *type, const Phdr *phdr)
"memsz: 0x%08" PRIxPTR ", "
"offset: 0x%08" PRIxPTR ", "
"flags: %c%c%c)",
type, phdr->p_vaddr, phdr->p_filesz, phdr->p_memsz,
phdr->p_offset, phdr->p_flags & PF_R ? 'r' : '-',
type, uintptr_t(phdr->p_vaddr), uintptr_t(phdr->p_filesz),
uintptr_t(phdr->p_memsz), uintptr_t(phdr->p_offset),
phdr->p_flags & PF_R ? 'r' : '-',
phdr->p_flags & PF_W ? 'w' : '-', phdr->p_flags & PF_X ? 'x' : '-');
}
@ -186,7 +187,7 @@ CustomElf::Load(Mappable *mappable, const char *path, int flags)
if (min_vaddr != 0) {
ERROR("%s: Unsupported minimal virtual address: 0x%08" PRIxPTR,
elf->GetPath(), min_vaddr);
elf->GetPath(), uintptr_t(min_vaddr));
return nullptr;
}
if (!dyn) {
@ -456,7 +457,7 @@ namespace {
void debug_dyn(const char *type, const Dyn *dyn)
{
DEBUG_LOG("%s 0x%08" PRIxPTR, type, dyn->d_un.d_val);
DEBUG_LOG("%s 0x%08" PRIxPTR, type, uintptr_t(dyn->d_un.d_val));
}
} /* anonymous namespace */
@ -587,7 +588,7 @@ CustomElf::InitDyn(const Phdr *pt_dyn)
flags &= ~DF_SYMBOLIC;
if (flags)
WARN("%s: unhandled flags #%" PRIxPTR" not handled",
GetPath(), flags);
GetPath(), uintptr_t(flags));
}
break;
case DT_SONAME: /* Should match GetName(), but doesn't matter */
@ -610,7 +611,7 @@ CustomElf::InitDyn(const Phdr *pt_dyn)
break;
default:
WARN("%s: dynamic header type #%" PRIxPTR" not handled",
GetPath(), dyn->d_tag);
GetPath(), uintptr_t(dyn->d_tag));
}
}
@ -671,7 +672,7 @@ CustomElf::Relocate()
if (symptr == nullptr)
WARN("%s: Relocation to NULL @0x%08" PRIxPTR,
GetPath(), rel->r_offset);
GetPath(), uintptr_t(rel->r_offset));
/* Apply relocation */
switch (ELF_R_TYPE(rel->r_info)) {
@ -685,7 +686,7 @@ CustomElf::Relocate()
break;
default:
ERROR("%s: Unsupported relocation type: 0x%" PRIxPTR,
GetPath(), ELF_R_TYPE(rel->r_info));
GetPath(), uintptr_t(ELF_R_TYPE(rel->r_info)));
return false;
}
}
@ -719,11 +720,11 @@ CustomElf::RelocateJumps()
if (ELF_ST_BIND(sym.st_info) == STB_WEAK) {
WARN("%s: Relocation to NULL @0x%08" PRIxPTR " for symbol \"%s\"",
GetPath(),
rel->r_offset, strtab.GetStringAt(sym.st_name));
uintptr_t(rel->r_offset), strtab.GetStringAt(sym.st_name));
} else {
ERROR("%s: Relocation to NULL @0x%08" PRIxPTR " for symbol \"%s\"",
GetPath(),
rel->r_offset, strtab.GetStringAt(sym.st_name));
uintptr_t(rel->r_offset), strtab.GetStringAt(sym.st_name));
return false;
}
}

View File

@ -609,12 +609,12 @@ ElfLoader::~ElfLoader()
it < list.rend(); ++it) {
if ((*it)->AsSystemElf()) {
DEBUG_LOG("ElfLoader::~ElfLoader(): Remaining handle for \"%s\" "
"[%d direct refs, %d refs total]", (*it)->GetPath(),
(*it)->DirectRefCount(), (*it)->refCount());
"[%" PRIdPTR " direct refs, %" PRIdPTR " refs total]",
(*it)->GetPath(), (*it)->DirectRefCount(), (*it)->refCount());
} else {
DEBUG_LOG("ElfLoader::~ElfLoader(): Unexpected remaining handle for \"%s\" "
"[%d direct refs, %d refs total]", (*it)->GetPath(),
(*it)->DirectRefCount(), (*it)->refCount());
"[%" PRIdPTR " direct refs, %" PRIdPTR " refs total]",
(*it)->GetPath(), (*it)->DirectRefCount(), (*it)->refCount());
/* Not removing, since it could have references to other libraries,
* destroying them as a side effect, and possibly leaving dangling
* pointers in the handle list we're scanning */

View File

@ -13,6 +13,7 @@
#include "Mappable.h"
#include "mozilla/IntegerPrintfMacros.h"
#include "mozilla/SizePrintfMacros.h"
#include "mozilla/UniquePtr.h"
@ -212,7 +213,8 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
ERROR("Couldn't initialize XZ decoder");
return nullptr;
}
DEBUG_LOG("XZStream created, compressed=%u, uncompressed=%u",
DEBUG_LOG("XZStream created, compressed=%" PRIuPTR
", uncompressed=%" PRIuPTR,
xzStream.Size(), xzStream.UncompressedSize());
if (ftruncate(fd, xzStream.UncompressedSize()) == -1) {
@ -226,7 +228,7 @@ MappableExtractFile::Create(const char *name, Zip *zip, Zip::Stream *stream)
return nullptr;
}
const size_t written = xzStream.Decode(buffer, buffer.GetLength());
DEBUG_LOG("XZStream decoded %u", written);
DEBUG_LOG("XZStream decoded %" PRIuPTR, written);
if (written != buffer.GetLength()) {
ERROR("Error decoding XZ file %s", file.get());
return nullptr;
@ -299,7 +301,8 @@ public:
if (buf != MAP_FAILED) {
::mmap(AlignedEndPtr(reinterpret_cast<char *>(buf) + length, PAGE_SIZE),
PAGE_SIZE, PROT_NONE, MAP_FIXED | MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
DEBUG_LOG("Decompression buffer of size 0x%x in ashmem \"%s\", mapped @%p",
DEBUG_LOG("Decompression buffer of size 0x%" PRIxPTR
" in ashmem \"%s\", mapped @%p",
length, str, buf);
return new _MappableBuffer(fd.forget(), buf, length);
}
@ -319,8 +322,8 @@ public:
return nullptr;
}
DEBUG_LOG("Decompression buffer of size 0x%x in ashmem \"%s\", mapped @%p",
length, str, actual_buf);
DEBUG_LOG("Decompression buffer of size 0x%" PRIxPTR
" in ashmem \"%s\", mapped @%p", length, str, actual_buf);
return new _MappableBuffer(fd.forget(), actual_buf, length);
}
#else