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