[llvm-commits] [lld] r149426 - in /lld/trunk/lib/Core: NativeFileFormat.h NativeReader.cpp NativeWriter.cpp
Michael J. Spencer
bigcheesegs at gmail.com
Tue Jan 31 13:45:53 PST 2012
Author: mspencer
Date: Tue Jan 31 15:45:53 2012
New Revision: 149426
URL: http://llvm.org/viewvc/llvm-project?rev=149426&view=rev
Log:
Flexible array members are not in C++03, and MSVC doesn't support them.
Modified:
lld/trunk/lib/Core/NativeFileFormat.h
lld/trunk/lib/Core/NativeReader.cpp
lld/trunk/lib/Core/NativeWriter.cpp
Modified: lld/trunk/lib/Core/NativeFileFormat.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeFileFormat.h?rev=149426&r1=149425&r2=149426&view=diff
==============================================================================
--- lld/trunk/lib/Core/NativeFileFormat.h (original)
+++ lld/trunk/lib/Core/NativeFileFormat.h Tue Jan 31 15:45:53 2012
@@ -80,7 +80,6 @@
uint32_t architecture;
uint32_t fileSize;
uint32_t chunkCount;
- NativeChunk chunks[];
};
//
Modified: lld/trunk/lib/Core/NativeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeReader.cpp?rev=149426&r1=149425&r2=149426&view=diff
==============================================================================
--- lld/trunk/lib/Core/NativeReader.cpp (original)
+++ lld/trunk/lib/Core/NativeReader.cpp Tue Jan 31 15:45:53 2012
@@ -175,6 +175,8 @@
reinterpret_cast<const uint8_t*>(mb->getBufferStart());
const NativeFileHeader* const header =
reinterpret_cast<const NativeFileHeader*>(base);
+ const NativeChunk *const chunks =
+ reinterpret_cast<const NativeChunk*>(base + sizeof(NativeFileHeader));
// make sure magic matches
if ( memcmp(header->magic, NATIVE_FILE_HEADER_MAGIC, 16) != 0 )
return make_error_code(unknown_file_format);
@@ -190,7 +192,7 @@
// process each chunk
for(uint32_t i=0; i < header->chunkCount; ++i) {
llvm::error_code ec;
- const NativeChunk* chunk = &header->chunks[i];
+ const NativeChunk* chunk = &chunks[i];
// sanity check chunk is within file
if ( chunk->fileOffset > fileSize )
return make_error_code(file_malformed);
Modified: lld/trunk/lib/Core/NativeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/NativeWriter.cpp?rev=149426&r1=149425&r2=149426&view=diff
==============================================================================
--- lld/trunk/lib/Core/NativeWriter.cpp (original)
+++ lld/trunk/lib/Core/NativeWriter.cpp Tue Jan 31 15:45:53 2012
@@ -71,6 +71,9 @@
_headerBufferSize = sizeof(NativeFileHeader) + 4*sizeof(NativeChunk);
_headerBuffer = reinterpret_cast<NativeFileHeader*>
(operator new(_headerBufferSize, std::nothrow));
+ NativeChunk *chunks =
+ reinterpret_cast<NativeChunk*>(reinterpret_cast<char*>(_headerBuffer)
+ + sizeof(NativeFileHeader));
memcpy(_headerBuffer->magic, NATIVE_FILE_HEADER_MAGIC, 16);
_headerBuffer->endian = NFH_LittleEndian;
_headerBuffer->architecture = 0;
@@ -78,25 +81,25 @@
_headerBuffer->chunkCount = 4;
// create chunk for atom ivar array
- NativeChunk& ch0 = _headerBuffer->chunks[0];
+ NativeChunk& ch0 = chunks[0];
ch0.signature = NCS_DefinedAtomsV1;
ch0.fileOffset = _headerBufferSize;
ch0.fileSize = _definedAtomIvars.size()*sizeof(NativeDefinedAtomIvarsV1);
ch0.elementCount = _definedAtomIvars.size();
- // create chunk for attributes
- NativeChunk& ch1 = _headerBuffer->chunks[1];
+ // create chunk for attributes
+ NativeChunk& ch1 = chunks[1];
ch1.signature = NCS_AttributesArrayV1;
ch1.fileOffset = ch0.fileOffset + ch0.fileSize;
ch1.fileSize = _attributes.size()*sizeof(NativeAtomAttributesV1);
ch1.elementCount = _attributes.size();
- // create chunk for content
- NativeChunk& ch2 = _headerBuffer->chunks[2];
+ // create chunk for content
+ NativeChunk& ch2 = chunks[2];
ch2.signature = NCS_Content;
ch2.fileOffset = ch1.fileOffset + ch1.fileSize;
ch2.fileSize = _contentPool.size();
ch2.elementCount = _contentPool.size();
// create chunk for symbol strings
- NativeChunk& ch3 = _headerBuffer->chunks[3];
+ NativeChunk& ch3 = chunks[3];
ch3.signature = NCS_Strings;
ch3.fileOffset = ch2.fileOffset + ch2.fileSize;
ch3.fileSize = _stringPool.size();
More information about the llvm-commits
mailing list