From ae4d8ad40ef292d3044674bd51a01a25ebba564a Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 30 Jan 2013 01:35:08 -0800 Subject: [PATCH] Code fixes to get things somewhat compiling on Windows. --- include/xenia/atomic.h | 2 +- include/xenia/cpu/codegen/module_generator.h | 2 - include/xenia/cpu/exec_module.h | 2 - include/xenia/cpu/processor.h | 1 - include/xenia/logging.h | 2 + include/xenia/platform_includes.h | 11 ++++ include/xenia/string.h | 14 +++-- include/xenia/types.h | 1 - src/cpu/codegen/function_generator.cc | 15 ++--- src/cpu/codegen/module_generator.cc | 6 +- src/cpu/exec_module.cc | 16 ++--- src/cpu/ppc/instr.cc | 42 +++++++------ src/cpu/ppc/instr_tables.h | 2 +- src/cpu/ppc/state.cc | 2 +- src/cpu/processor.cc | 8 ++- src/cpu/sdb.cc | 62 +++++++++++--------- src/kernel/export.cc | 2 +- src/kernel/modules/xbdm/xbdm_table.h | 1 + src/kernel/runtime.cc | 7 ++- src/kernel/xex2.cc | 8 +-- third_party/pe/pe_image.h | 6 ++ tools/xenia-info/xenia-info.cc | 4 +- tools/xenia-run/xenia-run.cc | 4 +- tools/xenia-test/xenia-test.cc | 2 +- xenia-build.py | 6 +- 25 files changed, 136 insertions(+), 92 deletions(-) diff --git a/include/xenia/atomic.h b/include/xenia/atomic.h index 4e0d114c3..47c515ffd 100644 --- a/include/xenia/atomic.h +++ b/include/xenia/atomic.h @@ -61,7 +61,7 @@ XEFORCEINLINE void* xe_atomic_stack_dequeue(xe_atomic_stack_t* stack, const size_t offset) { void* ptr = (void*)InterlockedPopEntrySList((PSLIST_HEADER)stack); if (ptr) { - return (void*)(((byte*)ptr) - offset); + return (void*)(((uint8_t*)ptr) - offset); } else { return NULL; } diff --git a/include/xenia/cpu/codegen/module_generator.h b/include/xenia/cpu/codegen/module_generator.h index e0a2541ee..addcda89f 100644 --- a/include/xenia/cpu/codegen/module_generator.h +++ b/include/xenia/cpu/codegen/module_generator.h @@ -13,8 +13,6 @@ #include #include -#include - #include #include #include diff --git a/include/xenia/cpu/exec_module.h b/include/xenia/cpu/exec_module.h index 752665f1a..dec1cf36d 100644 --- a/include/xenia/cpu/exec_module.h +++ b/include/xenia/cpu/exec_module.h @@ -13,8 +13,6 @@ #include #include -#include - #include #include #include diff --git a/include/xenia/cpu/processor.h b/include/xenia/cpu/processor.h index d4c78757a..fa925c2e2 100644 --- a/include/xenia/cpu/processor.h +++ b/include/xenia/cpu/processor.h @@ -12,7 +12,6 @@ #include -#include #include #include diff --git a/include/xenia/logging.h b/include/xenia/logging.h index 582717887..5e26ee80e 100644 --- a/include/xenia/logging.h +++ b/include/xenia/logging.h @@ -10,6 +10,8 @@ #ifndef XENIA_LOGGING_H_ #define XENIA_LOGGING_H_ +#include +#include #include #include diff --git a/include/xenia/platform_includes.h b/include/xenia/platform_includes.h index 2309b942b..039216591 100644 --- a/include/xenia/platform_includes.h +++ b/include/xenia/platform_includes.h @@ -19,6 +19,8 @@ #endif #include #include +#undef min +#undef max #endif // WINCE || WIN32 #if XE_PLATFORM(XBOX360) @@ -46,6 +48,15 @@ #include #include #include +#include + +#if XE_COMPILER(MSVC) +#include +#include +#else +#include +#include +#endif // MSVC #endif // XENIA_PLATFORM_INCLUDES_H_ diff --git a/include/xenia/string.h b/include/xenia/string.h index 03d604509..15f97e24d 100644 --- a/include/xenia/string.h +++ b/include/xenia/string.h @@ -23,15 +23,20 @@ int strncpy_s(char* dest, size_t destLength, const char* source, size_t count); #define strcpy_s(dest, destLength, source) !(strcpy(dest, source) == dest + (destLength*0)) #define strcat_s(dest, destLength, source) !(strcat(dest, source) == dest + (destLength*0)) -#define _snprintf_s(dest, destLength, format, ...) snprintf(dest, destLength, format, ##__VA_ARGS__) +#define _snprintf_s(dest, destLength, x, format, ...) snprintf(dest, destLength, format, ##__VA_ARGS__) +#define xestrdupa strdup +#define xestrtoulla strtoull #else #define strcasecmp _stricmp +#define xestrdupa _strdup +#define xestrtoullw _wcstoui64 +#define xestrtoulla _strtoui64 #endif #define xestrlenw wcslen #define xestrcmpw wcscmp #define xestrcasecmpw _wcsicmp -#define xsstrdupw wcsdup +#define xestrdupw wcsdup #define xestrchrw wcschr #define xestrrchrw wcsrchr #define xestrstrw wcsstr @@ -45,14 +50,13 @@ int strncpy_s(char* dest, size_t destLength, const char* source, size_t count); #define xestrlena strlen #define xestrcmpa strcmp #define xestrcasecmpa strcasecmp -#define xestrdupa strdup #define xestrchra strchr #define xestrrchra strrchr #define xestrstra strstr #define xestrcpya(dest, destLength, source) (strcpy_s(dest, destLength, source) == 0) #define xestrncpya(dest, destLength, source, count) (strncpy_s(dest, destLength, source, count) == 0) #define xestrcata(dest, destLength, source) (strcat_s(dest, destLength, source) == 0) -#define xesnprintfa(buffer, bufferCount, format, ...) _snprintf_s(buffer, bufferCount, format, ##__VA_ARGS__) +#define xesnprintfa(buffer, bufferCount, format, ...) _snprintf_s(buffer, bufferCount, bufferCount, format, ##__VA_ARGS__) #define xevsnprintfa(buffer, bufferCount, format, args) vsnprintf(buffer, bufferCount, format, args) #if XE_PLATFORM(WIN32) @@ -68,6 +72,7 @@ typedef wchar_t xechar_t; #define xestrchr xestrchrw #define xestrrchr xestrrchrw #define xestrstr xestrstrw +#define xestrtoull xestrtoullw #define xestrcpy xestrcpyw #define xestrncpy xestrncpyw #define xestrcat xestrcatw @@ -89,6 +94,7 @@ typedef char xechar_t; #define xestrchr xestrchra #define xestrrchr xestrrchra #define xestrstr xestrstra +#define xestrtoull xestrtoulla #define xestrcpy xestrcpya #define xestrncpy xestrncpya #define xestrcat xestrcata diff --git a/include/xenia/types.h b/include/xenia/types.h index e2cb4c46e..67a0add7c 100644 --- a/include/xenia/types.h +++ b/include/xenia/types.h @@ -13,7 +13,6 @@ #include #include -#include namespace xe { // TODO(benvanik): support other compilers/etc using std::auto_ptr; diff --git a/src/cpu/codegen/function_generator.cc b/src/cpu/codegen/function_generator.cc index 36a11dc99..76170f274 100644 --- a/src/cpu/codegen/function_generator.cc +++ b/src/cpu/codegen/function_generator.cc @@ -209,7 +209,7 @@ void FunctionGenerator::GenerateSharedBlocks() { SwitchInst* switch_i = b.CreateSwitch( b.CreateLoad(locals_.indirection_target), external_indirection_block_, - bbs_.size()); + static_cast(bbs_.size())); for (std::map::iterator it = bbs_.begin(); it != bbs_.end(); ++it) { switch_i->addCase(b.getInt64(it->first), it->second); @@ -301,7 +301,7 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) { } if (!i.type) { - XELOGCPU("Invalid instruction %.8X %.8X", ia, i.code); + XELOGCPU(XT("Invalid instruction %.8X %.8X"), ia, i.code); SpillRegisters(); b.CreateCall3( invalidInstruction, @@ -334,7 +334,7 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) { // This printf is handy for sort/uniquify to find instructions. //printf("unimplinstr %s\n", i.type->name); - XELOGCPU("Unimplemented instr %.8X %.8X %s", + XELOGCPU(XT("Unimplemented instr %.8X %.8X %s"), ia, i.code, i.type->name); SpillRegisters(); b.CreateCall3( @@ -353,8 +353,8 @@ void FunctionGenerator::GenerateBasicBlock(FunctionBlock* block) { } else if (block->outgoing_type == FunctionBlock::kTargetUnknown) { // Hrm. // TODO(benvanik): assert this doesn't occur - means a bad sdb run! - XELOGCPU("SDB function scan error in %.8X: bb %.8X has unknown exit\n", - fn_->start_address, block->start_address); + XELOGCPU(XT("SDB function scan error in %.8X: bb %.8X has unknown exit"), + fn_->start_address, block->start_address); b.CreateRetVoid(); } @@ -386,7 +386,8 @@ BasicBlock* FunctionGenerator::GetReturnBasicBlock() { Function* FunctionGenerator::GetFunction(FunctionSymbol* fn) { Function* result = gen_module_->getFunction(StringRef(fn->name)); if (!result) { - XELOGE("Static function not found: %.8X %s\n", fn->start_address, fn->name); + XELOGE(XT("Static function not found: %.8X %s"), + fn->start_address, fn->name); } XEASSERTNOTNULL(result); return result; @@ -601,7 +602,7 @@ void FunctionGenerator::FillRegisters() { } // Note that we skip zero. - for (size_t n = 0; n < XECOUNT(locals_.gpr); n++) { + for (int n = 0; n < XECOUNT(locals_.gpr); n++) { if (locals_.gpr[n]) { b.CreateStore(LoadStateValue( offsetof(xe_ppc_state_t, r) + 8 * n, diff --git a/src/cpu/codegen/module_generator.cc b/src/cpu/codegen/module_generator.cc index c4a698e2a..f1a0343e5 100644 --- a/src/cpu/codegen/module_generator.cc +++ b/src/cpu/codegen/module_generator.cc @@ -71,9 +71,9 @@ int ModuleGenerator::Generate() { // Setup a debug info builder. // This is used when creating any debug info. We may want to go more // fine grained than this, but for now it's something. - xechar_t dir[2048]; - XEIGNORE(xestrcpy(dir, XECOUNT(dir), module_path_)); - xechar_t* slash = xestrrchr(dir, '/'); + char dir[2048]; + XEIGNORE(xestrcpya(dir, XECOUNT(dir), module_path_)); + char* slash = xestrrchra(dir, '/'); if (slash) { *(slash + 1) = 0; } diff --git a/src/cpu/exec_module.cc b/src/cpu/exec_module.cc index cf07ac128..98948698b 100644 --- a/src/cpu/exec_module.cc +++ b/src/cpu/exec_module.cc @@ -138,8 +138,8 @@ int ExecModule::Prepare() { // Dump the symbol database. if (FLAGS_dump_module_map) { - xesnprintf(file_name, XECOUNT(file_name), - "%s%s.map", FLAGS_dump_path.c_str(), module_name_); + xesnprintfa(file_name, XECOUNT(file_name), + "%s%s.map", FLAGS_dump_path.c_str(), module_name_); sdb_->Write(file_name); } @@ -171,8 +171,8 @@ int ExecModule::Prepare() { // Dump pre-optimized module to disk. if (FLAGS_dump_module_bitcode) { - xesnprintf(file_name, XECOUNT(file_name), - "%s%s-preopt.bc", FLAGS_dump_path.c_str(), module_name_); + xesnprintfa(file_name, XECOUNT(file_name), + "%s%s-preopt.bc", FLAGS_dump_path.c_str(), module_name_); outs = auto_ptr(new raw_fd_ostream( file_name, error_message, raw_fd_ostream::F_Binary)); XEEXPECTTRUE(error_message.empty()); @@ -203,8 +203,8 @@ int ExecModule::Prepare() { // Dump post-optimized module to disk. if (FLAGS_optimize_ir_modules && FLAGS_dump_module_bitcode) { - xesnprintf(file_name, XECOUNT(file_name), - "%s%s.bc", FLAGS_dump_path.c_str(), module_name_); + xesnprintfa(file_name, XECOUNT(file_name), + "%s%s.bc", FLAGS_dump_path.c_str(), module_name_); outs = auto_ptr(new raw_fd_ostream( file_name, error_message, raw_fd_ostream::F_Binary)); XEEXPECTTRUE(error_message.empty()); @@ -397,7 +397,7 @@ int ExecModule::Init() { } else { // Not implemented - write with a dummy value. *slot = XESWAP32BE(0xDEADBEEF); - XELOGCPU("WARNING: imported a variable with no value: %s", + XELOGCPU(XT("WARNING: imported a variable with no value: %s"), kernel_export->name); } } @@ -411,7 +411,7 @@ int ExecModule::Init() { std::vector args; GenericValue ret = engine_->runFunction(xe_module_init, args); - return ret.IntVal.getSExtValue(); + return static_cast(ret.IntVal.getSExtValue()); } int ExecModule::Uninit() { diff --git a/src/cpu/ppc/instr.cc b/src/cpu/ppc/instr.cc index 6bb3dcc4f..689878ccd 100644 --- a/src/cpu/ppc/instr.cc +++ b/src/cpu/ppc/instr.cc @@ -150,26 +150,30 @@ void InstrDisasm::Init(std::string name, std::string info, uint32_t flags) { if (flags & InstrDisasm::kOE) { name += "o"; - special_registers.push_back((InstrRegister){ + InstrRegister i = { InstrRegister::kXER, 0, InstrRegister::kReadWrite - }); + }; + special_registers.push_back(i); } if (flags & InstrDisasm::kRc) { name += "."; - special_registers.push_back((InstrRegister){ + InstrRegister i = { InstrRegister::kCR, 0, InstrRegister::kWrite - }); + }; + special_registers.push_back(i); } if (flags & InstrDisasm::kCA) { - special_registers.push_back((InstrRegister){ + InstrRegister i = { InstrRegister::kXER, 0, InstrRegister::kReadWrite - }); + }; + special_registers.push_back(i); } if (flags & InstrDisasm::kLR) { name += "l"; - special_registers.push_back((InstrRegister){ + InstrRegister i = { InstrRegister::kLR, 0, InstrRegister::kWrite - }); + }; + special_registers.push_back(i); } XEIGNORE(xestrcpya(this->name, XECOUNT(this->name), name.c_str())); @@ -178,31 +182,35 @@ void InstrDisasm::Init(std::string name, std::string info, uint32_t flags) { } void InstrDisasm::AddLR(InstrRegister::Access access) { - special_registers.push_back((InstrRegister){ + InstrRegister i = { InstrRegister::kLR, 0, access - }); + }; + special_registers.push_back(i); } void InstrDisasm::AddCTR(InstrRegister::Access access) { - special_registers.push_back((InstrRegister){ + InstrRegister i = { InstrRegister::kCTR, 0, access - }); + }; + special_registers.push_back(i); } void InstrDisasm::AddCR(uint32_t bf, InstrRegister::Access access) { - special_registers.push_back((InstrRegister){ + InstrRegister i = { InstrRegister::kCR, bf, access - }); + }; + special_registers.push_back(i); } void InstrDisasm::AddRegOperand( InstrRegister::RegisterSet set, uint32_t ordinal, InstrRegister::Access access, std::string display) { - InstrOperand o; - o.type = InstrOperand::kRegister; - o.reg = (InstrRegister){ + InstrRegister i = { set, ordinal, access }; + InstrOperand o; + o.type = InstrOperand::kRegister; + o.reg = i; if (!display.size()) { std::stringstream display_out; switch (set) { diff --git a/src/cpu/ppc/instr_tables.h b/src/cpu/ppc/instr_tables.h index 21967797b..c87156494 100644 --- a/src/cpu/ppc/instr_tables.h +++ b/src/cpu/ppc/instr_tables.h @@ -21,7 +21,7 @@ namespace tables { static InstrType* instr_table_prep( InstrType* unprep, int unprep_count, int a, int b) { - int prep_count = pow(2, b - a + 1); + int prep_count = pow(2.0, b - a + 1); InstrType* prep = (InstrType*)xe_calloc(prep_count * sizeof(InstrType)); for (int n = 0; n < unprep_count; n++) { int ordinal = XESELECTBITS(unprep[n].opcode, a, b); diff --git a/src/cpu/ppc/state.cc b/src/cpu/ppc/state.cc index 9d4779644..6e744ff50 100644 --- a/src/cpu/ppc/state.cc +++ b/src/cpu/ppc/state.cc @@ -15,7 +15,7 @@ namespace { uint64_t ParseInt64(const char* value) { - return strtoull(value, NULL, 0); + return xestrtoulla(value, NULL, 0); } } diff --git a/src/cpu/processor.cc b/src/cpu/processor.cc index 6fc087ddb..12f54d292 100644 --- a/src/cpu/processor.cc +++ b/src/cpu/processor.cc @@ -135,8 +135,12 @@ int Processor::PrepareModule( int Processor::PrepareModule(UserModule* user_module, shared_ptr export_resolver) { + char name_a[2048]; + char path_a[2048]; + XEIGNORE(xestrnarrow(name_a, XECOUNT(name_a), user_module->name())); + XEIGNORE(xestrnarrow(path_a, XECOUNT(path_a), user_module->path())); ExecModule* exec_module = new ExecModule( - memory_, export_resolver, user_module->name(), user_module->path(), + memory_, export_resolver, name_a, path_a, engine_); if (exec_module->PrepareUserModule(user_module)) { @@ -173,7 +177,7 @@ int Processor::Execute(ThreadState* thread_state, uint32_t address) { // Find the function to execute. Function* f = GetFunction(address); if (!f) { - XELOGCPU("Failed to find function %.8X to execute.\n", address); + XELOGCPU(XT("Failed to find function %.8X to execute."), address); return 1; } diff --git a/src/cpu/sdb.cc b/src/cpu/sdb.cc index 7dc0038a6..42bcb6371 100644 --- a/src/cpu/sdb.cc +++ b/src/cpu/sdb.cc @@ -173,7 +173,7 @@ FunctionSymbol* SymbolDatabase::GetOrInsertFunction(uint32_t address) { // Ignore values outside of the .text range. if (!IsValueInTextRange(address)) { - XELOGSDB("Ignoring function outside of .text: %.8X\n", address); + XELOGSDB(XT("Ignoring function outside of .text: %.8X"), address); return NULL; } @@ -340,7 +340,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { if (*((uint32_t*)(p + fn->start_address)) == 0) { // Function starts with 0x00000000 - we want to skip this and split. - XELOGSDB("function starts with 0: %.8X\n", fn->start_address); + XELOGSDB(XT("function starts with 0: %.8X"), fn->start_address); symbols_.erase(fn->start_address); if (!GetFunction(fn->start_address + 4)) { fn->start_address += 4; @@ -352,13 +352,13 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { return 0; } - XELOGSDB("Analyzing function %.8X...\n", fn->start_address); + XELOGSDB(XT("Analyzing function %.8X..."), fn->start_address); // Set a default name, if it hasn't been named already. if (!fn->name) { char name[32]; xesnprintfa(name, XECOUNT(name), "sub_%.8X", fn->start_address); - fn->name = xestrdup(name); + fn->name = xestrdupa(name); } // Set type, if needed. We assume user if not set. @@ -378,13 +378,13 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { // If we fetched 0 assume that we somehow hit one of the awesome // 'no really we meant to end after that bl' functions. if (!i.code) { - XELOGSDB("function end %.8X (0x00000000 read)\n", addr); + XELOGSDB(XT("function end %.8X (0x00000000 read)"), addr); break; } if (!i.type) { // Invalid instruction. - XELOGSDB("Invalid instruction at %.8X: %.8X\n", addr, i.code); + XELOGSDB(XT("Invalid instruction at %.8X: %.8X"), addr, i.code); return 1; } @@ -405,10 +405,10 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { block->outgoing_type = FunctionBlock::kTargetLR; if (furthest_target > addr) { // Remaining targets within function, not end. - XELOGSDB("ignoring blr %.8X (branch to %.8X)\n", addr, furthest_target); + XELOGSDB(XT("ignoring blr %.8X (branch to %.8X)"), addr, furthest_target); } else { // Function end point. - XELOGSDB("function end %.8X\n", addr); + XELOGSDB(XT("function end %.8X"), addr); ends_fn = true; } ends_block = true; @@ -418,11 +418,11 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { block->outgoing_type = FunctionBlock::kTargetCTR; if (furthest_target > addr) { // Remaining targets within function, not end. - XELOGSDB("ignoring bctr %.8X (branch to %.8X)\n", addr, + XELOGSDB(XT("ignoring bctr %.8X (branch to %.8X)"), addr, furthest_target); } else { // Function end point. - XELOGSDB("function end %.8X\n", addr); + XELOGSDB(XT("function end %.8X"), addr); ends_fn = true; } ends_block = true; @@ -432,17 +432,17 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { block->outgoing_address = target; if (i.I.LK) { - XELOGSDB("bl %.8X -> %.8X\n", addr, target); + XELOGSDB(XT("bl %.8X -> %.8X"), addr, target); // Queue call target if needed. GetOrInsertFunction(target); } else { - XELOGSDB("b %.8X -> %.8X\n", addr, target); + XELOGSDB(XT("b %.8X -> %.8X"), addr, target); // If the target is back into the function and there's no further target // we are at the end of a function. if (target >= fn->start_address && target < addr && furthest_target <= addr) { - XELOGSDB("function end %.8X (back b)\n", addr); + XELOGSDB(XT("function end %.8X (back b)"), addr); ends_fn = true; } @@ -452,7 +452,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { // it. if (!ends_fn && furthest_target <= addr && IsRestGprLr(target)) { - XELOGSDB("function end %.8X (__restgprlr_*)\n", addr); + XELOGSDB(XT("function end %.8X (__restgprlr_*)"), addr); ends_fn = true; } @@ -466,9 +466,9 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { uint32_t target = XEEXTS16(i.B.BD << 2) + (i.B.AA ? 0 : (int32_t)addr); block->outgoing_address = target; if (i.B.LK) { - XELOGSDB("bcl %.8X -> %.8X\n", addr, target); + XELOGSDB(XT("bcl %.8X -> %.8X"), addr, target); } else { - XELOGSDB("bc %.8X -> %.8X\n", addr, target); + XELOGSDB(XT("bc %.8X -> %.8X"), addr, target); furthest_target = MAX(furthest_target, target); } @@ -477,18 +477,18 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { // bclr/bclrl block->outgoing_type = FunctionBlock::kTargetLR; if (i.XL.LK) { - XELOGSDB("bclrl %.8X\n", addr); + XELOGSDB(XT("bclrl %.8X"), addr); } else { - XELOGSDB("bclr %.8X\n", addr); + XELOGSDB(XT("bclr %.8X"), addr); } ends_block = true; } else if (i.type->opcode == 0x4C000420) { // bcctr/bcctrl block->outgoing_type = FunctionBlock::kTargetCTR; if (i.XL.LK) { - XELOGSDB("bcctrl %.8X\n", addr); + XELOGSDB(XT("bcctrl %.8X"), addr); } else { - XELOGSDB("bcctr %.8X\n", addr); + XELOGSDB(XT("bcctr %.8X"), addr); } ends_block = true; } @@ -508,8 +508,8 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { addr += 4; if (fn->end_address && addr > fn->end_address) { // Hmm.... - XELOGSDB("Ran over function bounds! %.8X-%.8X\n", - fn->start_address, fn->end_address); + XELOGSDB(XT("Ran over function bounds! %.8X-%.8X"), + fn->start_address, fn->end_address); break; } } @@ -519,7 +519,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { // from someplace valid (like method hints) this may indicate an error. // It's also possible that we guessed in hole-filling and there's another // function below this one. - XELOGSDB("Function ran under: %.8X-%.8X ended at %.8X\n", + XELOGSDB(XT("Function ran under: %.8X-%.8X ended at %.8X"), fn->start_address, fn->end_address, addr + 4); } fn->end_address = addr; @@ -532,7 +532,7 @@ int SymbolDatabase::AnalyzeFunction(FunctionSymbol* fn) { // - if present, flag function as needing a stack // - record prolog/epilog lengths/stack size/etc - XELOGSDB("Finished analyzing %.8X\n", fn->start_address); + XELOGSDB(XT("Finished analyzing %.8X"), fn->start_address); return 0; } @@ -573,10 +573,12 @@ int SymbolDatabase::CompleteFunctionGraph(FunctionSymbol* fn) { return 0; } +namespace { typedef struct { uint32_t start_address; uint32_t end_address; } HoleInfo; +} bool SymbolDatabase::FillHoles() { // If 4b, check if 0x00000000 and ignore (alignment padding) @@ -611,11 +613,13 @@ bool SymbolDatabase::FillHoles() { ees.push_back(previous); } else { // Probably legit. - holes.push_back((HoleInfo){previous, fn->start_address}); + HoleInfo hole_info = {previous, fn->start_address}; + holes.push_back(hole_info); } } else { // Probably legit. - holes.push_back((HoleInfo){previous, fn->start_address}); + HoleInfo hole_info = {previous, fn->start_address}; + holes.push_back(hole_info); } } previous = fn->end_address + 4; @@ -666,7 +670,7 @@ int SymbolDatabase::FlushQueue() { FunctionSymbol* fn = scan_queue_.front(); scan_queue_.pop_front(); if (AnalyzeFunction(fn)) { - XELOGSDB("Aborting analysis!\n"); + XELOGSDB(XT("Aborting analysis!")); return 1; } } @@ -806,7 +810,7 @@ int XexSymbolDatabase::FindGplr() { char name[32]; uint32_t address = gplr_start; for (int n = 14; n <= 31; n++) { - xesnprintf(name, XECOUNT(name), "__savegprlr_%d", n); + xesnprintfa(name, XECOUNT(name), "__savegprlr_%d", n); FunctionSymbol* fn = GetOrInsertFunction(address); fn->end_address = fn->start_address + (31 - n) * 4 + 2 * 4; fn->name = xestrdupa(name); @@ -816,7 +820,7 @@ int XexSymbolDatabase::FindGplr() { } address = gplr_start + 20 * 4; for (int n = 14; n <= 31; n++) { - xesnprintf(name, XECOUNT(name), "__restgprlr_%d", n); + xesnprintfa(name, XECOUNT(name), "__restgprlr_%d", n); FunctionSymbol* fn = GetOrInsertFunction(address); fn->end_address = fn->start_address + (31 - n) * 4 + 3 * 4; fn->name = xestrdupa(name); diff --git a/src/kernel/export.cc b/src/kernel/export.cc index 13d788cc7..e3245e0ad 100644 --- a/src/kernel/export.cc +++ b/src/kernel/export.cc @@ -41,7 +41,7 @@ KernelExport* ExportResolver::GetExportByOrdinal(const char* library_name, const uint32_t ordinal) { for (std::vector::iterator it = tables_.begin(); it != tables_.end(); ++it) { - if (!xestrcmp(library_name, it->name)) { + if (!xestrcmpa(library_name, it->name)) { // TODO(benvanik): binary search? for (size_t n = 0; n < it->count; n++) { if (it->exports[n].ordinal == ordinal) { diff --git a/src/kernel/modules/xbdm/xbdm_table.h b/src/kernel/modules/xbdm/xbdm_table.h index 62078ec43..db482629b 100644 --- a/src/kernel/modules/xbdm/xbdm_table.h +++ b/src/kernel/modules/xbdm/xbdm_table.h @@ -22,6 +22,7 @@ namespace xbdm { static KernelExport xbdm_export_table[] = { + 0, }; diff --git a/src/kernel/runtime.cc b/src/kernel/runtime.cc index 4bb136141..819ef1a77 100644 --- a/src/kernel/runtime.cc +++ b/src/kernel/runtime.cc @@ -85,8 +85,13 @@ int Runtime::LoadBinaryModule(const xechar_t* path, uint32_t start_address) { addr, length)); // Prepare the module. + char name_a[2048]; + XEEXPECTTRUE(xestrnarrow(name_a, XECOUNT(name_a), name)); + char path_a[2048]; + XEEXPECTTRUE(xestrnarrow(path_a, XECOUNT(path_a), path)); XEEXPECTZERO(processor_->PrepareModule( - name, path, start_address, start_address + length, export_resolver_)); + name_a, path_a, start_address, start_address + length, + export_resolver_)); result_code = 0; XECLEANUP: diff --git a/src/kernel/xex2.cc b/src/kernel/xex2.cc index 00358fae7..00a1dc480 100644 --- a/src/kernel/xex2.cc +++ b/src/kernel/xex2.cc @@ -205,8 +205,8 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, size_t count = XEGETUINT32BE(pp + 0x08); XEASSERT(count <= max_count); if (count > max_count) { - XELOGW(XT("ignoring %zu extra entries in " - "XEX_HEADER_IMPORT_LIBRARIES"), (max_count - count)); + XELOGW(XT("ignoring %zu extra entries in ") + XT("XEX_HEADER_IMPORT_LIBRARIES"), (max_count - count)); count = max_count; } header->import_library_count = count; @@ -259,8 +259,8 @@ int xe_xex2_read_header(const uint8_t *addr, const size_t length, size_t count = (opt_header->length - 4) / 16; XEASSERT(count <= max_count); if (count > max_count) { - XELOGW(XT("ignoring %zu extra entries in " - "XEX_HEADER_STATIC_LIBRARIES"), (max_count - count)); + XELOGW(XT("ignoring %zu extra entries in ") + XT("XEX_HEADER_STATIC_LIBRARIES"), (max_count - count)); count = max_count; } header->static_library_count = count; diff --git a/third_party/pe/pe_image.h b/third_party/pe/pe_image.h index a734e7623..e2e694bbd 100644 --- a/third_party/pe/pe_image.h +++ b/third_party/pe/pe_image.h @@ -12,6 +12,12 @@ #pragma pack (1) #endif +// MODIFIED: on Windows a few definitions aren't in WINNT +#ifdef IMAGE_NT_SIGNATURE +#define IMAGE_SIZEOF_NT_OPTIONAL_HEADER 224 +#define IMAGE_FILE_MACHINE_POWERPCBE 0x01F2 // IBM PowerPC Big-Endian +#endif + /* Skip if WINNT.H already included. We check IMAGE_NT_SIGNATURE instead of _WINNT_, * because WinCE's version of WINNT.H defines _WINNT_ but it doesn't include everything here */ diff --git a/tools/xenia-info/xenia-info.cc b/tools/xenia-info/xenia-info.cc index 742c8bf80..15cee825c 100644 --- a/tools/xenia-info/xenia-info.cc +++ b/tools/xenia-info/xenia-info.cc @@ -19,7 +19,7 @@ using namespace xe::kernel; int xenia_info(int argc, xechar_t **argv) { std::string usage = "usage: "; - usage = usage + argv[0] + " some.xex"; + usage += "xenia-info some.xex"; google::SetUsageMessage(usage); google::SetVersionString("1.0"); google::ParseCommandLineFlags(&argc, &argv, true); @@ -33,7 +33,7 @@ int xenia_info(int argc, xechar_t **argv) { // Grab path. if (argc < 2) { - google::ShowUsageWithFlags(argv[0]); + google::ShowUsageWithFlags("xenia-info"); return 1; } const xechar_t *path = argv[1]; diff --git a/tools/xenia-run/xenia-run.cc b/tools/xenia-run/xenia-run.cc index 20e25683e..ba8a5edcd 100644 --- a/tools/xenia-run/xenia-run.cc +++ b/tools/xenia-run/xenia-run.cc @@ -81,7 +81,7 @@ int Run::Launch() { int xenia_run(int argc, xechar_t **argv) { std::string usage = "usage: "; - usage = usage + argv[0] + " some.xex"; + usage += "xenia-run some.xex"; google::SetUsageMessage(usage); google::SetVersionString("1.0"); google::ParseCommandLineFlags(&argc, &argv, true); @@ -93,7 +93,7 @@ int xenia_run(int argc, xechar_t **argv) { // Grab path. if (argc < 2) { - google::ShowUsageWithFlags(argv[0]); + google::ShowUsageWithFlags("xenia-run"); return 1; } const xechar_t *path = argv[1]; diff --git a/tools/xenia-test/xenia-test.cc b/tools/xenia-test/xenia-test.cc index c5ff80905..4c93daa8a 100644 --- a/tools/xenia-test/xenia-test.cc +++ b/tools/xenia-test/xenia-test.cc @@ -226,7 +226,7 @@ XECLEANUP: int xenia_test(int argc, xechar_t **argv) { string usage = "usage: "; - usage = usage + argv[0] + " some.xex"; + usage += "xenia-test some.xex"; google::SetUsageMessage(usage); google::SetVersionString("1.0"); google::ParseCommandLineFlags(&argc, &argv, true); diff --git a/xenia-build.py b/xenia-build.py index 70b5fe269..7558914b2 100755 --- a/xenia-build.py +++ b/xenia-build.py @@ -364,8 +364,10 @@ def run_all_gyps(): """Runs all gyp configurations. """ run_gyp('ninja') - run_gyp('xcode') - run_gyp('msvs') + if sys.platform == 'darwin': + run_gyp('xcode') + elif sys.platform == 'win32': + run_gyp('msvs') class GypCommand(Command):