mirror of
https://github.com/corda/corda.git
synced 2025-01-04 04:04:27 +00:00
clean up binary format code
Linux, FreeBSD, and QNX all use ELF, so no need to distinguish between them when generating object files. To avoid confusion, I've switch from using operating system names to using binary format names where applicable.
This commit is contained in:
parent
e641f23e6c
commit
f03e5e8e55
31
makefile
31
makefile
@ -24,7 +24,6 @@ target-arch = $(arch)
|
|||||||
bootimage-platform = \
|
bootimage-platform = \
|
||||||
$(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
|
$(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))
|
||||||
platform = $(bootimage-platform)
|
platform = $(bootimage-platform)
|
||||||
target-platform = $(platform)
|
|
||||||
|
|
||||||
mode = fast
|
mode = fast
|
||||||
process = compile
|
process = compile
|
||||||
@ -165,6 +164,8 @@ ifneq ($(platform),darwin)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
target-format = elf
|
||||||
|
|
||||||
cxx = $(build-cxx) $(mflag)
|
cxx = $(build-cxx) $(mflag)
|
||||||
cc = $(build-cc) $(mflag)
|
cc = $(build-cc) $(mflag)
|
||||||
|
|
||||||
@ -211,7 +212,7 @@ build-cflags = $(common-cflags) -fPIC -fvisibility=hidden \
|
|||||||
converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject -Isrc/ \
|
converter-cflags = -D__STDC_CONSTANT_MACROS -Isrc/binaryToObject -Isrc/ \
|
||||||
-fno-rtti -fno-exceptions \
|
-fno-rtti -fno-exceptions \
|
||||||
-DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \
|
-DAVIAN_TARGET_ARCH=AVIAN_ARCH_UNKNOWN \
|
||||||
-DAVIAN_TARGET_PLATFORM=AVIAN_PLATFORM_UNKNOWN \
|
-DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_UNKNOWN \
|
||||||
-Wall -Wextra -Werror -Wunused-parameter -Winit-self -Wno-non-virtual-dtor
|
-Wall -Wextra -Werror -Wunused-parameter -Winit-self -Wno-non-virtual-dtor
|
||||||
|
|
||||||
cflags = $(build-cflags)
|
cflags = $(build-cflags)
|
||||||
@ -314,7 +315,6 @@ ifeq ($(build-platform),darwin)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(platform),qnx)
|
ifeq ($(platform),qnx)
|
||||||
target-platform = linux
|
|
||||||
cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
cflags = $(common-cflags) -fPIC -fvisibility=hidden -I$(src)
|
||||||
lflags = $(common-lflags) -lsocket
|
lflags = $(common-lflags) -lsocket
|
||||||
ifeq ($(build-platform),qnx)
|
ifeq ($(build-platform),qnx)
|
||||||
@ -346,6 +346,7 @@ ifeq ($(platform),freebsd)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(platform),darwin)
|
ifeq ($(platform),darwin)
|
||||||
|
target-format = macho
|
||||||
ifeq (${OSX_SDK_SYSROOT},)
|
ifeq (${OSX_SDK_SYSROOT},)
|
||||||
OSX_SDK_SYSROOT = 10.4u
|
OSX_SDK_SYSROOT = 10.4u
|
||||||
endif
|
endif
|
||||||
@ -427,6 +428,8 @@ ifeq ($(platform),darwin)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(platform),windows)
|
ifeq ($(platform),windows)
|
||||||
|
target-format = pe
|
||||||
|
|
||||||
inc = "$(win32)/include"
|
inc = "$(win32)/include"
|
||||||
lib = "$(win32)/lib"
|
lib = "$(win32)/lib"
|
||||||
|
|
||||||
@ -854,20 +857,16 @@ ifeq ($(target-arch),arm)
|
|||||||
cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_ARM
|
cflags += -DAVIAN_TARGET_ARCH=AVIAN_ARCH_ARM
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(target-platform),linux)
|
ifeq ($(target-format),elf)
|
||||||
cflags += -DAVIAN_TARGET_PLATFORM=AVIAN_PLATFORM_LINUX
|
cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_ELF
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(target-platform),windows)
|
ifeq ($(target-format),pe)
|
||||||
cflags += -DAVIAN_TARGET_PLATFORM=AVIAN_PLATFORM_WINDOWS
|
cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_PE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(target-platform),darwin)
|
ifeq ($(target-format),macho)
|
||||||
cflags += -DAVIAN_TARGET_PLATFORM=AVIAN_PLATFORM_DARWIN
|
cflags += -DAVIAN_TARGET_FORMAT=AVIAN_FORMAT_MACHO
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(target-platform),freebsd)
|
|
||||||
cflags += -DAVIAN_TARGET_PLATFORM=AVIAN_PLATFORM_FREEBSD
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
class-name = $(patsubst $(1)/%.class,%,$(2))
|
class-name = $(patsubst $(1)/%.class,%,$(2))
|
||||||
@ -1050,7 +1049,7 @@ $(build)/classpath.jar: $(classpath-dep) $(classpath-jar-dep)
|
|||||||
$(classpath-object): $(build)/classpath.jar $(converter)
|
$(classpath-object): $(build)/classpath.jar $(converter)
|
||||||
@echo "creating $(@)"
|
@echo "creating $(@)"
|
||||||
$(converter) $(<) $(@) _binary_classpath_jar_start \
|
$(converter) $(<) $(@) _binary_classpath_jar_start \
|
||||||
_binary_classpath_jar_end $(target-platform) $(arch)
|
_binary_classpath_jar_end $(target-format) $(arch)
|
||||||
|
|
||||||
$(build)/javahome.jar:
|
$(build)/javahome.jar:
|
||||||
@echo "creating $(@)"
|
@echo "creating $(@)"
|
||||||
@ -1061,7 +1060,7 @@ $(build)/javahome.jar:
|
|||||||
$(javahome-object): $(build)/javahome.jar $(converter)
|
$(javahome-object): $(build)/javahome.jar $(converter)
|
||||||
@echo "creating $(@)"
|
@echo "creating $(@)"
|
||||||
$(converter) $(<) $(@) _binary_javahome_jar_start \
|
$(converter) $(<) $(@) _binary_javahome_jar_start \
|
||||||
_binary_javahome_jar_end $(target-platform) $(arch)
|
_binary_javahome_jar_end $(target-format) $(arch)
|
||||||
|
|
||||||
define compile-generator-object
|
define compile-generator-object
|
||||||
@echo "compiling $(@)"
|
@echo "compiling $(@)"
|
||||||
@ -1122,7 +1121,7 @@ $(bootimage-generator): $(bootimage-generator-objects)
|
|||||||
arch=$(build-arch) \
|
arch=$(build-arch) \
|
||||||
target-arch=$(arch) \
|
target-arch=$(arch) \
|
||||||
platform=$(bootimage-platform) \
|
platform=$(bootimage-platform) \
|
||||||
target-platform=$(target-platform) \
|
target-format=$(target-format) \
|
||||||
openjdk=$(openjdk) \
|
openjdk=$(openjdk) \
|
||||||
openjdk-src=$(openjdk-src) \
|
openjdk-src=$(openjdk-src) \
|
||||||
bootimage-generator= \
|
bootimage-generator= \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* arm.S: JNI gluecode for ARM/Linux
|
/* arm.S: JNI gluecode for ARM
|
||||||
Copyright (c) 2008-2011, Avian Contributors
|
Copyright (c) 2008-2011, Avian Contributors
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software
|
Permission to use, copy, modify, and/or distribute this software
|
||||||
|
@ -197,8 +197,8 @@ public:
|
|||||||
|
|
||||||
const unsigned machine;
|
const unsigned machine;
|
||||||
|
|
||||||
ElfPlatform(PlatformInfo::OperatingSystem os, PlatformInfo::Architecture arch):
|
ElfPlatform(PlatformInfo::Architecture arch):
|
||||||
Platform(PlatformInfo(os, arch)),
|
Platform(PlatformInfo(PlatformInfo::Elf, arch)),
|
||||||
machine(getElfPlatform(arch)) {}
|
machine(getElfPlatform(arch)) {}
|
||||||
|
|
||||||
class FileWriter {
|
class FileWriter {
|
||||||
@ -372,15 +372,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ElfPlatform<uint32_t> elfLinuxX86Platform(PlatformInfo::Linux, PlatformInfo::x86);
|
ElfPlatform<uint32_t> elfX86Platform(PlatformInfo::x86);
|
||||||
ElfPlatform<uint32_t> elfLinuxArmPlatform(PlatformInfo::Linux, PlatformInfo::Arm);
|
ElfPlatform<uint32_t> elfArmPlatform(PlatformInfo::Arm);
|
||||||
ElfPlatform<uint32_t, false> elfLinuxPowerPCPlatform(PlatformInfo::Linux, PlatformInfo::PowerPC);
|
ElfPlatform<uint32_t, false> elfPowerPCPlatform(PlatformInfo::PowerPC);
|
||||||
ElfPlatform<uint64_t> elfLinuxX86_64Platform(PlatformInfo::Linux, PlatformInfo::x86_64);
|
ElfPlatform<uint64_t> elfX86_64Platform(PlatformInfo::x86_64);
|
||||||
|
|
||||||
ElfPlatform<uint32_t> elfFreeBSDx86Platform(PlatformInfo::FreeBSD, PlatformInfo::x86);
|
|
||||||
ElfPlatform<uint32_t> elfFreeBSDArmPlatform(PlatformInfo::FreeBSD, PlatformInfo::Arm);
|
|
||||||
ElfPlatform<uint32_t, false> elfFreeBSDPowerPCPlatform(PlatformInfo::FreeBSD, PlatformInfo::PowerPC);
|
|
||||||
ElfPlatform<uint64_t> elfFreeBSDx86_64Platform(PlatformInfo::FreeBSD, PlatformInfo::x86_64);
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -286,7 +286,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
MachOPlatform(PlatformInfo::Architecture arch):
|
MachOPlatform(PlatformInfo::Architecture arch):
|
||||||
Platform(PlatformInfo(PlatformInfo::Darwin, arch)) {}
|
Platform(PlatformInfo(PlatformInfo::MachO, arch)) {}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,14 +41,14 @@ using namespace avian::tools;
|
|||||||
|
|
||||||
bool
|
bool
|
||||||
writeObject(uint8_t* data, size_t size, OutputStream* out, const char* startName,
|
writeObject(uint8_t* data, size_t size, OutputStream* out, const char* startName,
|
||||||
const char* endName, const char* os,
|
const char* endName, const char* format,
|
||||||
const char* architecture, unsigned alignment, bool writable,
|
const char* architecture, unsigned alignment, bool writable,
|
||||||
bool executable)
|
bool executable)
|
||||||
{
|
{
|
||||||
Platform* platform = Platform::getPlatform(PlatformInfo(PlatformInfo::osFromString(os), PlatformInfo::archFromString(architecture)));
|
Platform* platform = Platform::getPlatform(PlatformInfo(PlatformInfo::formatFromString(format), PlatformInfo::archFromString(architecture)));
|
||||||
|
|
||||||
if(!platform) {
|
if(!platform) {
|
||||||
fprintf(stderr, "unsupported platform: %s/%s\n", os, architecture);
|
fprintf(stderr, "unsupported platform: %s/%s\n", format, architecture);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
WindowsPlatform():
|
WindowsPlatform():
|
||||||
Platform(PlatformInfo(PlatformInfo::Windows, BytesPerWord == 4 ? PlatformInfo::x86 : PlatformInfo::x86_64)) {}
|
Platform(PlatformInfo(PlatformInfo::Pe, BytesPerWord == 4 ? PlatformInfo::x86 : PlatformInfo::x86_64)) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
WindowsPlatform<4> windows32Platform;
|
WindowsPlatform<4> windows32Platform;
|
||||||
|
@ -85,17 +85,23 @@ void FileOutputStream::write(uint8_t byte) {
|
|||||||
|
|
||||||
Platform* Platform::first = 0;
|
Platform* Platform::first = 0;
|
||||||
|
|
||||||
PlatformInfo::OperatingSystem PlatformInfo::osFromString(const char* os) {
|
PlatformInfo::Format PlatformInfo::formatFromString(const char* format) {
|
||||||
if(strcmp(os, "linux") == 0) {
|
if (strcmp(format, "elf") == 0
|
||||||
return Linux;
|
or strcmp(format, "linux") == 0
|
||||||
} else if(strcmp(os, "windows") == 0) {
|
or strcmp(format, "freebsd") == 0
|
||||||
return Windows;
|
or strcmp(format, "qnx") == 0)
|
||||||
} else if(strcmp(os, "darwin") == 0) {
|
{
|
||||||
return Darwin;
|
return Elf;
|
||||||
} else if(strcmp(os, "freebsd") == 0) {
|
} else if (strcmp(format, "pe") == 0
|
||||||
return FreeBSD;
|
or strcmp(format, "windows") == 0)
|
||||||
|
{
|
||||||
|
return Pe;
|
||||||
|
} else if (strcmp(format, "macho") == 0
|
||||||
|
or strcmp(format, "darwin") == 0)
|
||||||
|
{
|
||||||
|
return MachO;
|
||||||
} else {
|
} else {
|
||||||
return UnknownOS;
|
return UnknownFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,12 +131,11 @@ public:
|
|||||||
|
|
||||||
class PlatformInfo {
|
class PlatformInfo {
|
||||||
public:
|
public:
|
||||||
enum OperatingSystem {
|
enum Format {
|
||||||
Linux = AVIAN_PLATFORM_LINUX,
|
Elf = AVIAN_FORMAT_ELF,
|
||||||
Windows = AVIAN_PLATFORM_WINDOWS,
|
Pe = AVIAN_FORMAT_PE,
|
||||||
Darwin = AVIAN_PLATFORM_DARWIN,
|
MachO = AVIAN_FORMAT_MACHO,
|
||||||
FreeBSD = AVIAN_PLATFORM_FREEBSD,
|
UnknownFormat = AVIAN_FORMAT_UNKNOWN
|
||||||
UnknownOS = AVIAN_PLATFORM_UNKNOWN
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Architecture {
|
enum Architecture {
|
||||||
@ -147,18 +146,18 @@ public:
|
|||||||
UnknownArch = AVIAN_ARCH_UNKNOWN
|
UnknownArch = AVIAN_ARCH_UNKNOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
const OperatingSystem os;
|
const Format format;
|
||||||
const Architecture arch;
|
const Architecture arch;
|
||||||
|
|
||||||
static OperatingSystem osFromString(const char* os);
|
static Format formatFromString(const char* format);
|
||||||
static Architecture archFromString(const char* arch);
|
static Architecture archFromString(const char* arch);
|
||||||
|
|
||||||
inline PlatformInfo(OperatingSystem os, Architecture arch):
|
inline PlatformInfo(Format format, Architecture arch):
|
||||||
os(os),
|
format(format),
|
||||||
arch(arch) {}
|
arch(arch) {}
|
||||||
|
|
||||||
inline bool operator == (const PlatformInfo& other) {
|
inline bool operator == (const PlatformInfo& other) {
|
||||||
return os == other.os && arch == other.arch;
|
return format == other.format && arch == other.arch;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool isLittleEndian() {
|
inline bool isLittleEndian() {
|
||||||
|
@ -1647,7 +1647,7 @@ writeBootImage2(Thread* t, OutputStream* bootimageOutput, OutputStream* codeOutp
|
|||||||
|
|
||||||
// fwrite(code, pad(image->codeSize, TargetBytesPerWord), 1, codeOutput);
|
// fwrite(code, pad(image->codeSize, TargetBytesPerWord), 1, codeOutput);
|
||||||
|
|
||||||
Platform* platform = Platform::getPlatform(PlatformInfo((PlatformInfo::OperatingSystem)AVIAN_TARGET_PLATFORM, (PlatformInfo::Architecture)AVIAN_TARGET_ARCH));
|
Platform* platform = Platform::getPlatform(PlatformInfo((PlatformInfo::Format)AVIAN_TARGET_FORMAT, (PlatformInfo::Architecture)AVIAN_TARGET_ARCH));
|
||||||
|
|
||||||
// if(!platform) {
|
// if(!platform) {
|
||||||
// fprintf(stderr, "unsupported platform: %s/%s\n", os, architecture);
|
// fprintf(stderr, "unsupported platform: %s/%s\n", os, architecture);
|
||||||
|
@ -11,19 +11,18 @@
|
|||||||
#ifndef AVIAN_ENVIRONMENT_H
|
#ifndef AVIAN_ENVIRONMENT_H
|
||||||
#define AVIAN_ENVIRONMENT_H
|
#define AVIAN_ENVIRONMENT_H
|
||||||
|
|
||||||
#ifndef AVIAN_TARGET_PLATFORM
|
#ifndef AVIAN_TARGET_FORMAT
|
||||||
#error build system should have defined AVIAN_TARGET_PLATFORM
|
#error build system should have defined AVIAN_TARGET_FORMAT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef AVIAN_TARGET_ARCH
|
#ifndef AVIAN_TARGET_ARCH
|
||||||
#error build system should have defined AVIAN_TARGET_ARCH
|
#error build system should have defined AVIAN_TARGET_ARCH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define AVIAN_PLATFORM_UNKNOWN 0
|
#define AVIAN_FORMAT_UNKNOWN 0
|
||||||
#define AVIAN_PLATFORM_LINUX 1
|
#define AVIAN_FORMAT_ELF 1
|
||||||
#define AVIAN_PLATFORM_WINDOWS 2
|
#define AVIAN_FORMAT_PE 2
|
||||||
#define AVIAN_PLATFORM_DARWIN 3
|
#define AVIAN_FORMAT_MACHO 3
|
||||||
#define AVIAN_PLATFORM_FREEBSD 4
|
|
||||||
|
|
||||||
#define AVIAN_ARCH_UNKNOWN 0
|
#define AVIAN_ARCH_UNKNOWN 0
|
||||||
#define AVIAN_ARCH_X86 (1 << 8)
|
#define AVIAN_ARCH_X86 (1 << 8)
|
||||||
|
@ -2781,7 +2781,7 @@ class MyArchitecture: public Assembler::Architecture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual unsigned frameFootprint(unsigned footprint) {
|
virtual unsigned frameFootprint(unsigned footprint) {
|
||||||
#if AVIAN_TARGET_PLATFORM == AVIAN_PLATFORM_WINDOWS
|
#if AVIAN_TARGET_FORMAT == AVIAN_FORMAT_PE
|
||||||
return max(footprint, StackAlignmentInWords);
|
return max(footprint, StackAlignmentInWords);
|
||||||
#else
|
#else
|
||||||
return max(footprint > argumentRegisterCount() ?
|
return max(footprint > argumentRegisterCount() ?
|
||||||
@ -2803,7 +2803,7 @@ class MyArchitecture: public Assembler::Architecture {
|
|||||||
}
|
}
|
||||||
|
|
||||||
virtual unsigned argumentRegisterCount() {
|
virtual unsigned argumentRegisterCount() {
|
||||||
#if AVIAN_TARGET_PLATFORM == AVIAN_PLATFORM_WINDOWS
|
#if AVIAN_TARGET_FORMAT == AVIAN_FORMAT_PE
|
||||||
if (TargetBytesPerWord == 8) return 4; else
|
if (TargetBytesPerWord == 8) return 4; else
|
||||||
#else
|
#else
|
||||||
if (TargetBytesPerWord == 8) return 6; else
|
if (TargetBytesPerWord == 8) return 6; else
|
||||||
@ -2814,7 +2814,7 @@ class MyArchitecture: public Assembler::Architecture {
|
|||||||
virtual int argumentRegister(unsigned index) {
|
virtual int argumentRegister(unsigned index) {
|
||||||
assert(&c, TargetBytesPerWord == 8);
|
assert(&c, TargetBytesPerWord == 8);
|
||||||
switch (index) {
|
switch (index) {
|
||||||
#if AVIAN_TARGET_PLATFORM == AVIAN_PLATFORM_WINDOWS
|
#if AVIAN_TARGET_FORMAT == AVIAN_FORMAT_PE
|
||||||
case 0:
|
case 0:
|
||||||
return rcx;
|
return rcx;
|
||||||
case 1:
|
case 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user