fix darwin build

This commit is contained in:
Joel Dice 2008-03-30 22:23:51 -06:00
parent 357bd29460
commit c37f0dcf18
2 changed files with 12 additions and 29 deletions

View File

@ -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 $(@)"

View File

@ -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<char*>(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(&sect1, 1, sizeof(sect1), out);
fwrite(&sect2, 1, sizeof(sect2), out);
fwrite(&sect, 1, sizeof(sect), out);
fwrite(&symbolTable, 1, sizeof(symbolTable), out);
fwrite(data, 1, size, out);