enable powerpc build for process=interpret (won't run yet, though)

This commit is contained in:
dicej 2008-06-04 17:09:09 -06:00
parent 9e0f0a17a7
commit f375f6e85c
3 changed files with 31 additions and 8 deletions

View File

@ -346,7 +346,7 @@ $(binaryToMacho): $(src)/binaryToMacho.cpp
$(classpath-object): $(build)/classpath.jar $(binaryToMacho) $(classpath-object): $(build)/classpath.jar $(binaryToMacho)
@echo "creating $(@)" @echo "creating $(@)"
ifeq ($(platform),darwin) ifeq ($(platform),darwin)
$(binaryToMacho) $(build)/classpath.jar \ $(binaryToMacho) $(asm) $(build)/classpath.jar \
__binary_classpath_jar_start __binary_classpath_jar_end > $(@) __binary_classpath_jar_start __binary_classpath_jar_end > $(@)
else else
(wd=$$(pwd); \ (wd=$$(pwd); \

View File

@ -20,6 +20,8 @@
#include "mach-o/loader.h" #include "mach-o/loader.h"
#include "mach-o/nlist.h" #include "mach-o/nlist.h"
namespace { namespace {
inline unsigned inline unsigned
@ -29,16 +31,27 @@ pad(unsigned n)
} }
void void
writeObject(FILE* out, const uint8_t* data, unsigned size, writeObject(const char* architecture,
FILE* out, const uint8_t* data, unsigned size,
const char* startName, const char* endName) const char* startName, const char* endName)
{ {
unsigned startNameLength = strlen(startName) + 1; unsigned startNameLength = strlen(startName) + 1;
unsigned endNameLength = strlen(endName) + 1; unsigned endNameLength = strlen(endName) + 1;
cpu_type_t cpuType;
cpu_subtype_t cpuSubtype;
if (strcmp(architecture, "x86") == 0) {
cpuType = CPU_TYPE_I386;
cpuSubtype = CPU_SUBTYPE_I386_ALL;
} else if (strcmp(architecture, "powerpc") == 0) {
cpuType = CPU_TYPE_POWERPC;
cpuSubtype = CPU_SUBTYPE_POWERPC_ALL;
}
mach_header header = { mach_header header = {
MH_MAGIC, // magic MH_MAGIC, // magic
CPU_TYPE_I386, // cputype cpuType,
CPU_SUBTYPE_I386_ALL, // cpusubtype cpuSubtype,
MH_OBJECT, // filetype, MH_OBJECT, // filetype,
2, // ncmds 2, // ncmds
sizeof(segment_command) sizeof(segment_command)
@ -136,16 +149,17 @@ writeObject(FILE* out, const uint8_t* data, unsigned size,
int int
main(int argc, const char** argv) main(int argc, const char** argv)
{ {
if (argc != 4) { if (argc != 5) {
fprintf(stderr, fprintf(stderr,
"usage: %s <input file> <start symbol name> <end symbol name>\n", "usage: %s <architecture> <input file> <start symbol name> "
"<end symbol name>\n",
argv[0]); argv[0]);
return -1; return -1;
} }
uint8_t* data = 0; uint8_t* data = 0;
unsigned size; unsigned size;
int fd = open(argv[1], O_RDONLY); int fd = open(argv[2], O_RDONLY);
if (fd != -1) { if (fd != -1) {
struct stat s; struct stat s;
int r = fstat(fd, &s); int r = fstat(fd, &s);
@ -158,7 +172,7 @@ main(int argc, const char** argv)
} }
if (data) { if (data) {
writeObject(stdout, data, size, argv[2], argv[3]); writeObject(argv[1], stdout, data, size, argv[3], argv[4]);
munmap(data, size); munmap(data, size);
return 0; return 0;
} else { } else {

View File

@ -29,3 +29,12 @@ vmNativeCall:
;; mtlr r0 ; into the link register ;; mtlr r0 ; into the link register
;; addi r1,r1,spaceToSaveAligned ; restore stack pointer ;; addi r1,r1,spaceToSaveAligned ; restore stack pointer
blr ; and branch to the return address blr ; and branch to the return address
#ifdef __APPLE__
.globl _vmJump
_vmJump:
#else
.globl vmJump
vmJump:
#endif
blr