diff --git a/dyld_decache.cpp b/dyld_decache.cpp index 76438ca..697d806 100644 --- a/dyld_decache.cpp +++ b/dyld_decache.cpp @@ -414,7 +414,6 @@ class ExtraStringRepository { boost::unordered_map _indices; std::vector _entries; - size_t _total_size; section _template; @@ -458,7 +457,7 @@ class ExtraStringRepository { } void increase_size_by(size_t delta) { _template.size += delta; } - size_t total_size() const { return _template.size; } + uint32_t total_size() const { return _template.size; } bool has_content() const { return _template.size != 0; } // Get the 'section' structure for the extra section this repository @@ -497,7 +496,7 @@ class ExtraBindRepository { } } - long optimize_and_write(FILE* f) { + uint32_t optimize_and_write(FILE* f) { typedef boost::unordered_map::value_type V; typedef boost::unordered_map > M; typedef std::pair P; @@ -512,7 +511,7 @@ class ExtraBindRepository { fputc(BIND_OPCODE_SET_TYPE_IMM | 1, f); - long size = 1; + uint32_t size = 1; BOOST_FOREACH(const M::value_type& pair, entries_by_libord) { int libord = pair.first; if (libord < 0x10) { @@ -671,15 +670,15 @@ class DecachingFile : public MachOFile { }; struct { - long rebase_off, bind_off, weak_bind_off, + uint32_t rebase_off, bind_off, weak_bind_off, lazy_bind_off, export_off, // dyld_info symoff, stroff, // symtab tocoff, modtaboff, extrefsymoff, indirectsymoff, extreloff, locreloff, // dysymtab dataoff, // linkedit_data_command (dummy) dataoff_cs, dataoff_ssi, dataoff_fs; - long bind_size; - int32_t strsize; + uint32_t bind_size; + uint32_t strsize; } _new_linkedit_offsets; private: @@ -1197,7 +1196,7 @@ class ProgramContext { _macho_files.clear(); for (uint32_t i = 0; i < _header->imagesCount; ++ i) { const mach_header* mh = _f->peek_data_at(this->from_vmaddr(_images[i].address)); - _macho_files.push_back(MachOFile(mh, this, _images[i].address)); + _macho_files.push_back(MachOFile(mh, this, static_cast(_images[i].address))); } for (uint32_t i = 0; i < _header->imagesCount; ++ i) { @@ -1278,7 +1277,7 @@ void DecachingFile::write_segment_content(const segment_command* segcmd) { ExtraStringRepository* repo = this->repo_for_segname(segcmd->segname); const char* data_ptr = _context->peek_char_at_vmaddr(segcmd->vmaddr); - long new_fileoff = ftell(_f); + uint32_t new_fileoff = static_cast(ftell(_f)); fwrite(data_ptr, 1, segcmd->filesize, _f); uint32_t filesize = segcmd->filesize; @@ -1309,8 +1308,8 @@ void DecachingFile::write_real_linkedit(const load_command* cmd) { // and pad to make sure the beginning is aligned with 'objsize' boundary. #define TRY_WRITE(offmem, countmem, objsize) \ if (cmdvar->offmem && cmdvar->countmem) { \ - long curloc = ftell(_f); \ - long extra = curloc % objsize; \ + uint32_t curloc = static_cast(ftell(_f)); \ + uint32_t extra = curloc % objsize; \ if (extra != 0) { \ char padding[objsize] = {0}; \ fwrite(padding, 1, objsize-extra, _f); \ @@ -1328,8 +1327,8 @@ void DecachingFile::write_real_linkedit(const load_command* cmd) { case LC_DYLD_INFO_ONLY: { const dyld_info_command* cmdvar = static_cast(cmd); TRY_WRITE(rebase_off, rebase_size, 1); - long curloc = ftell(_f); - long extra_size = _extra_bind.optimize_and_write(_f); + uint32_t curloc = static_cast(ftell(_f)); + uint32_t extra_size = _extra_bind.optimize_and_write(_f); TRY_WRITE(bind_off, bind_size, 1); _new_linkedit_offsets.bind_off = curloc; _new_linkedit_offsets.bind_size += extra_size; @@ -1346,7 +1345,7 @@ void DecachingFile::write_real_linkedit(const load_command* cmd) { // take those strings which are used by the symbol. const symtab_command* cmdvar = static_cast(cmd); if (cmdvar->symoff && cmdvar->nsyms) { - _new_linkedit_offsets.stroff = ftell(_f); + _new_linkedit_offsets.stroff = static_cast(ftell(_f)); nlist* syms = new nlist[cmdvar->nsyms]; memcpy(syms, _context->_f->peek_data_at(cmdvar->symoff), sizeof(*syms) * cmdvar->nsyms); @@ -1361,8 +1360,8 @@ void DecachingFile::write_real_linkedit(const load_command* cmd) { } _new_linkedit_offsets.strsize = cur_strx; - long curloc = ftell(_f); - long extra = curloc % sizeof(nlist); + uint32_t curloc = static_cast(ftell(_f)); + uint32_t extra = curloc % sizeof(nlist); if (extra != 0) { char padding[sizeof(nlist)] = {0}; fwrite(padding, 1, sizeof(nlist)-extra, _f);