mirror of
https://github.com/corda/corda.git
synced 2025-06-18 15:18:16 +00:00
add use-clang option for building with LLVM Clang instead of GCC
This also fixes several errors and warnings emitted by Clang.
This commit is contained in:
@ -131,8 +131,9 @@ unsigned getElfPlatform(PlatformInfo::Architecture arch) {
|
||||
return EM_ARM;
|
||||
case PlatformInfo::PowerPC:
|
||||
return EM_PPC;
|
||||
default:
|
||||
return ~0;
|
||||
}
|
||||
return ~0;
|
||||
}
|
||||
|
||||
const char* getSectionName(unsigned accessFlags, unsigned& sectionFlags) {
|
||||
@ -255,8 +256,8 @@ public:
|
||||
SectionWriter(FileWriter& file):
|
||||
file(file),
|
||||
name(""),
|
||||
data(0),
|
||||
dataSize(0)
|
||||
dataSize(0),
|
||||
data(0)
|
||||
{
|
||||
memset(&header, 0, sizeof(SectionHeader));
|
||||
file.sectionCount++;
|
||||
@ -279,8 +280,8 @@ public:
|
||||
|
||||
file(file),
|
||||
name(chname),
|
||||
data(data),
|
||||
dataSize(dataSize)
|
||||
dataSize(dataSize),
|
||||
data(data)
|
||||
{
|
||||
if(strcmp(chname, ".shstrtab") == 0) {
|
||||
file.sectionStringTableSectionNumber = file.sectionCount;
|
||||
@ -359,11 +360,11 @@ public:
|
||||
|
||||
file.writeHeader(out);
|
||||
|
||||
for(int i = 0; i < file.sectionCount; i++) {
|
||||
for(unsigned i = 0; i < file.sectionCount; i++) {
|
||||
sections[i].writeHeader(out);
|
||||
}
|
||||
|
||||
for(int i = 0; i < file.sectionCount; i++) {
|
||||
for(unsigned i = 0; i < file.sectionCount; i++) {
|
||||
sections[i].writeData(out);
|
||||
}
|
||||
|
||||
|
@ -183,14 +183,14 @@ public:
|
||||
|
||||
FileHeader header = {
|
||||
V4(Magic), // magic
|
||||
V4(cpuType),
|
||||
V4(cpuSubType),
|
||||
static_cast<cpu_type_t>(V4(cpuType)),
|
||||
static_cast<cpu_subtype_t>(V4(cpuSubType)),
|
||||
V4(MH_OBJECT), // filetype,
|
||||
V4(2), // ncmds
|
||||
V4(sizeof(SegmentCommand)
|
||||
+ sizeof(Section)
|
||||
+ sizeof(SymtabCommand)), // sizeofcmds
|
||||
V4(0) // flags
|
||||
{ V4(0) } // flags
|
||||
};
|
||||
|
||||
AddrTy finalSize = pad(data.count);
|
||||
@ -206,8 +206,8 @@ public:
|
||||
+ sizeof(Section)
|
||||
+ sizeof(SymtabCommand))), // fileoff
|
||||
VANY(static_cast<AddrTy>(finalSize)), // filesize
|
||||
V4(7), // maxprot
|
||||
V4(7), // initprot
|
||||
static_cast<vm_prot_t>(V4(7)), // maxprot
|
||||
static_cast<vm_prot_t>(V4(7)), // initprot
|
||||
V4(1), // nsects
|
||||
V4(0) // flags
|
||||
};
|
||||
@ -243,7 +243,7 @@ public:
|
||||
strings.write("_", 1);
|
||||
strings.add(sym->name);
|
||||
NList symbol = {
|
||||
V4(offset), // n_un
|
||||
{ V4(offset) }, // n_un
|
||||
V1(N_SECT | N_EXT), // n_type
|
||||
V1(1), // n_sect
|
||||
V2(0), // n_desc
|
||||
@ -281,6 +281,8 @@ public:
|
||||
out->writeChunk(symbolList.data, symbolList.length);
|
||||
|
||||
out->writeChunk(strings.data, strings.length);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
MachOPlatform(PlatformInfo::Architecture arch):
|
||||
|
@ -33,7 +33,7 @@ void* operator new(size_t size) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
void operator delete(void* mem) { abort(); }
|
||||
void operator delete(void*) { abort(); }
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -129,11 +129,11 @@ public:
|
||||
void addSymbol(String name, unsigned addr, unsigned sectionNumber, unsigned type, unsigned storageClass) {
|
||||
unsigned nameOffset = strings.add(name);
|
||||
IMAGE_SYMBOL symbol = {
|
||||
{ 0 }, // Name
|
||||
{ { 0, 0 } }, // Name
|
||||
addr, // Value
|
||||
sectionNumber, // SectionNumber
|
||||
type, // Type
|
||||
storageClass, // StorageClass
|
||||
static_cast<int16_t>(sectionNumber), // SectionNumber
|
||||
static_cast<uint16_t>(type), // Type
|
||||
static_cast<uint8_t>(storageClass), // StorageClass
|
||||
0, // NumberOfAuxSymbols
|
||||
};
|
||||
symbol.N.Name.Long = nameOffset+4;
|
||||
@ -165,9 +165,9 @@ public:
|
||||
size_t dataSize):
|
||||
|
||||
file(file),
|
||||
data(data),
|
||||
dataSize(dataSize),
|
||||
finalSize(pad(dataSize))
|
||||
finalSize(pad(dataSize)),
|
||||
data(data)
|
||||
{
|
||||
file.sectionCount++;
|
||||
file.dataStart += sizeof(IMAGE_SECTION_HEADER);
|
||||
|
Reference in New Issue
Block a user