mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
support bootimage build on OS X
This commit is contained in:
parent
e55b59905e
commit
2622773eb4
11
makefile
11
makefile
@ -94,6 +94,9 @@ endif
|
||||
ifeq ($(platform),darwin)
|
||||
build-cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
||||
lflags = $(common-lflags) -ldl -framework CoreFoundation
|
||||
ifeq ($(bootimage),true)
|
||||
bootimage-lflags = -Wl,-segprot,__BOOT,rwx,rwx
|
||||
endif
|
||||
rdynamic =
|
||||
strip-all = -S -x
|
||||
binaryToMacho = $(native-build)/binaryToMacho
|
||||
@ -401,7 +404,7 @@ $(binaryToMacho): $(src)/binaryToMacho.cpp
|
||||
$(classpath-object): $(build)/classpath.jar $(binaryToMacho)
|
||||
@echo "creating $(@)"
|
||||
ifeq ($(platform),darwin)
|
||||
$(binaryToMacho) $(build)/classpath.jar \
|
||||
$(binaryToMacho) $(build)/classpath.jar __TEXT __text \
|
||||
__binary_classpath_jar_start __binary_classpath_jar_end > $(@)
|
||||
else
|
||||
(wd=$$(pwd); \
|
||||
@ -431,7 +434,7 @@ $(bootimage-bin): $(bootimage-generator)
|
||||
$(bootimage-object): $(bootimage-bin)
|
||||
@echo "creating $(@)"
|
||||
ifeq ($(platform),darwin)
|
||||
$(binaryToMacho) $(<) \
|
||||
$(binaryToMacho) $(<) __BOOT __boot \
|
||||
__binary_bootimage_bin_start __binary_bootimage_bin_end > $(@)
|
||||
else
|
||||
(wd=$$(pwd); \
|
||||
@ -451,7 +454,7 @@ ifeq ($(platform),windows)
|
||||
$(dlltool) -d $(@).def -e $(@).exp
|
||||
$(cc) $(@).exp $(^) $(lflags) -o $(@)
|
||||
else
|
||||
$(cc) $(^) $(rdynamic) $(lflags) -o $(@)
|
||||
$(cc) $(^) $(rdynamic) $(lflags) $(bootimage-lflags) -o $(@)
|
||||
endif
|
||||
$(strip) $(strip-all) $(@)
|
||||
|
||||
@ -480,7 +483,7 @@ $(dynamic-library): \
|
||||
$(vm-objects) $(dynamic-object) $(jni-objects) $(vm-heapwalk-objects) \
|
||||
$(boot-object) $(vm-classpath-object)
|
||||
@echo "linking $(@)"
|
||||
$(cc) $(^) $(shared) $(lflags) -o $(@)
|
||||
$(cc) $(^) $(shared) $(lflags) $(bootimage-lflags) -o $(@)
|
||||
$(strip) $(strip-all) $(@)
|
||||
|
||||
$(executable-dynamic): $(driver-dynamic-object) $(dynamic-library)
|
||||
|
@ -30,6 +30,7 @@ pad(unsigned n)
|
||||
|
||||
void
|
||||
writeObject(FILE* out, const uint8_t* data, unsigned size,
|
||||
const char* segmentName, const char* sectionName,
|
||||
const char* startName, const char* endName)
|
||||
{
|
||||
unsigned startNameLength = strlen(startName) + 1;
|
||||
@ -39,7 +40,7 @@ writeObject(FILE* out, const uint8_t* data, unsigned size,
|
||||
MH_MAGIC, // magic
|
||||
CPU_TYPE_I386, // cputype
|
||||
CPU_SUBTYPE_I386_ALL, // cpusubtype
|
||||
MH_OBJECT, // filetype,
|
||||
MH_OBJECT, // filetype
|
||||
2, // ncmds
|
||||
sizeof(segment_command)
|
||||
+ sizeof(section)
|
||||
@ -50,7 +51,7 @@ writeObject(FILE* out, const uint8_t* data, unsigned size,
|
||||
segment_command segment = {
|
||||
LC_SEGMENT, // cmd
|
||||
sizeof(segment_command) + sizeof(section), // cmdsize
|
||||
"__TEXT", // segname
|
||||
"", // segname
|
||||
0, // vmaddr
|
||||
pad(size), // vmsize
|
||||
sizeof(mach_header)
|
||||
@ -64,9 +65,11 @@ writeObject(FILE* out, const uint8_t* data, unsigned size,
|
||||
0 // flags
|
||||
};
|
||||
|
||||
strncpy(segment.segname, segmentName, sizeof(segment.segname));
|
||||
|
||||
section sect = {
|
||||
"__const", // sectname
|
||||
"__TEXT", // segname
|
||||
"", // sectname
|
||||
"", // segname
|
||||
0, // addr
|
||||
pad(size), // size
|
||||
sizeof(mach_header)
|
||||
@ -81,6 +84,9 @@ writeObject(FILE* out, const uint8_t* data, unsigned size,
|
||||
0, // reserved2
|
||||
};
|
||||
|
||||
strncpy(sect.segname, segmentName, sizeof(sect.segname));
|
||||
strncpy(sect.sectname, sectionName, sizeof(sect.sectname));
|
||||
|
||||
symtab_command symbolTable = {
|
||||
LC_SYMTAB, // cmd
|
||||
sizeof(symtab_command), // cmdsize
|
||||
@ -136,9 +142,10 @@ writeObject(FILE* out, const uint8_t* data, unsigned size,
|
||||
int
|
||||
main(int argc, const char** argv)
|
||||
{
|
||||
if (argc != 4) {
|
||||
if (argc != 6) {
|
||||
fprintf(stderr,
|
||||
"usage: %s <input file> <start symbol name> <end symbol name>\n",
|
||||
"usage: %s <input file> <segment name> <section name> "
|
||||
"<start symbol name> <end symbol name>\n",
|
||||
argv[0]);
|
||||
return -1;
|
||||
}
|
||||
@ -158,7 +165,7 @@ main(int argc, const char** argv)
|
||||
}
|
||||
|
||||
if (data) {
|
||||
writeObject(stdout, data, size, argv[2], argv[3]);
|
||||
writeObject(stdout, data, size, argv[2], argv[3], argv[4], argv[5]);
|
||||
munmap(data, size);
|
||||
return 0;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user