From c37f0dcf184afd6e9f81de760a10d5a1bd5d33a7 Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sun, 30 Mar 2008 22:23:51 -0600 Subject: [PATCH] fix darwin build --- makefile | 4 +++- src/binaryToMacho.cpp | 37 +++++++++---------------------------- 2 files changed, 12 insertions(+), 29 deletions(-) diff --git a/makefile b/makefile index ca220ec3aa..d2b2f9b0a5 100644 --- a/makefile +++ b/makefile @@ -90,6 +90,7 @@ ifeq ($(platform),darwin) build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \ -I$(JAVA_HOME)/include/linux -I$(src) lflags = $(common-lflags) -ldl -framework CoreFoundation + rdynamic = strip-all = -S -x binaryToMacho = $(native-build)/binaryToMacho so-suffix = .jnilib @@ -330,6 +331,7 @@ $(binaryToMacho): $(src)/binaryToMacho.cpp $(cxx) $(^) -o $(@) $(classpath-object): $(build)/classpath.jar $(binaryToMacho) + @echo "creating $(@)" ifeq ($(platform),darwin) $(binaryToMacho) $(build)/classpath.jar \ __binary_classpath_jar_start __binary_classpath_jar_end > $(@) @@ -373,7 +375,7 @@ $(dynamic-library): \ $(boot-object) @echo "linking $(@)" $(cc) $(^) $(shared) $(lflags) -o $(@) - $(strip) $(@) + $(strip) $(strip-all) $(@) $(executable-dynamic): $(driver-dynamic-object) $(dynamic-library) @echo "linking $(@)" diff --git a/src/binaryToMacho.cpp b/src/binaryToMacho.cpp index c295470782..013b9bfc7f 100644 --- a/src/binaryToMacho.cpp +++ b/src/binaryToMacho.cpp @@ -42,7 +42,7 @@ writeObject(FILE* out, const uint8_t* data, unsigned size, MH_OBJECT, // filetype, 2, // ncmds sizeof(segment_command) - + (sizeof(section) * 2) + + sizeof(section) + sizeof(symtab_command), // sizeofcmds 0 // flags }; @@ -55,23 +55,23 @@ writeObject(FILE* out, const uint8_t* data, unsigned size, pad(size), // vmsize sizeof(mach_header) + sizeof(segment_command) - + (sizeof(section) * 2) + + sizeof(section) + sizeof(symtab_command), // fileoff pad(size), // filesize 7, // maxprot 7, // initprot - 2, // nsects + 1, // nsects 0 // flags }; - section sect1 = { + section sect = { "__const", // sectname "__TEXT", // segname 0, // addr pad(size), // size sizeof(mach_header) + sizeof(segment_command) - + (sizeof(section) * 2) + + sizeof(section) + sizeof(symtab_command), // offset 0, // align 0, // reloff @@ -81,30 +81,12 @@ writeObject(FILE* out, const uint8_t* data, unsigned size, 0, // reserved2 }; - section sect2 = { - "__const", // sectname - "__TEXT", // segname - 0, // addr - 0, // size - sizeof(mach_header) - + sizeof(segment_command) - + (sizeof(section) * 2) - + sizeof(symtab_command) - + size, // offset - 0, // align - 0, // reloff - 0, // nreloc - S_REGULAR, // flags - 0, // reserved1 - 0, // reserved2 - }; - symtab_command symbolTable = { LC_SYMTAB, // cmd sizeof(symtab_command), // cmdsize sizeof(mach_header) + sizeof(segment_command) - + (sizeof(section) * 2) + + sizeof(section) + sizeof(symtab_command) + pad(size), // symoff 2, // nsyms @@ -128,16 +110,15 @@ writeObject(FILE* out, const uint8_t* data, unsigned size, { reinterpret_cast(1 + startNameLength), // n_un N_SECT | N_EXT, // n_type - 2, // n_sect + 1, // n_sect 0, // n_desc - 0 // n_value + size // n_value } }; fwrite(&header, 1, sizeof(header), out); fwrite(&segment, 1, sizeof(segment), out); - fwrite(§1, 1, sizeof(sect1), out); - fwrite(§2, 1, sizeof(sect2), out); + fwrite(§, 1, sizeof(sect), out); fwrite(&symbolTable, 1, sizeof(symbolTable), out); fwrite(data, 1, size, out);