diff options
author | Greg Clayton <gclayton@apple.com> | 2013-01-25 18:06:21 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2013-01-25 18:06:21 +0000 |
commit | c7bece56faa5eef1c3d141d0c0b0b68b28a9aed2 (patch) | |
tree | 9a0132fc3b0bb4f38d06a0f352ee75ac57994771 /lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp | |
parent | d0ed6c249dbd6bd488b6491b536a387548c00f7e (diff) | |
download | llvm-c7bece56faa5eef1c3d141d0c0b0b68b28a9aed2.zip llvm-c7bece56faa5eef1c3d141d0c0b0b68b28a9aed2.tar.gz llvm-c7bece56faa5eef1c3d141d0c0b0b68b28a9aed2.tar.bz2 |
<rdar://problem/13069948>
Major fixed to allow reading files that are over 4GB. The main problems were that the DataExtractor was using 32 bit offsets as a data cursor, and since we mmap all of our object files we could run into cases where if we had a very large core file that was over 4GB, we were running into the 4GB boundary.
So I defined a new "lldb::offset_t" which should be used for all file offsets.
After making this change, I enabled warnings for data loss and for enexpected implicit conversions temporarily and found a ton of things that I fixed.
Any functions that take an index internally, should use "size_t" for any indexes and also should return "size_t" for any sizes of collections.
llvm-svn: 173463
Diffstat (limited to 'lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp')
-rw-r--r-- | lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp index bfff9f3..d9cac0d 100644 --- a/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp +++ b/lldb/source/Plugins/ObjectFile/ELF/ELFHeader.cpp @@ -23,20 +23,24 @@ using namespace llvm::ELF; // GetMaxU64 and GetMaxS64 wrap the similarly named methods from DataExtractor // with error handling code and provide for parsing a sequence of values. static bool -GetMaxU64(const lldb_private::DataExtractor &data, - uint32_t *offset, uint64_t *value, uint32_t byte_size) +GetMaxU64(const lldb_private::DataExtractor &data, + lldb::offset_t *offset, + uint64_t *value, + uint32_t byte_size) { - const uint32_t saved_offset = *offset; + const lldb::offset_t saved_offset = *offset; *value = data.GetMaxU64(offset, byte_size); return *offset != saved_offset; } static bool GetMaxU64(const lldb_private::DataExtractor &data, - uint32_t *offset, uint64_t *value, uint32_t byte_size, + lldb::offset_t *offset, + uint64_t *value, + uint32_t byte_size, uint32_t count) { - uint32_t saved_offset = *offset; + lldb::offset_t saved_offset = *offset; for (uint32_t i = 0; i < count; ++i, ++value) { @@ -51,19 +55,23 @@ GetMaxU64(const lldb_private::DataExtractor &data, static bool GetMaxS64(const lldb_private::DataExtractor &data, - uint32_t *offset, int64_t *value, uint32_t byte_size) + lldb::offset_t *offset, + int64_t *value, + uint32_t byte_size) { - const uint32_t saved_offset = *offset; + const lldb::offset_t saved_offset = *offset; *value = data.GetMaxS64(offset, byte_size); return *offset != saved_offset; } static bool GetMaxS64(const lldb_private::DataExtractor &data, - uint32_t *offset, int64_t *value, uint32_t byte_size, + lldb::offset_t *offset, + int64_t *value, + uint32_t byte_size, uint32_t count) { - uint32_t saved_offset = *offset; + lldb::offset_t saved_offset = *offset; for (uint32_t i = 0; i < count; ++i, ++value) { @@ -95,7 +103,7 @@ ELFHeader::GetByteOrder() const } bool -ELFHeader::Parse(lldb_private::DataExtractor &data, uint32_t *offset) +ELFHeader::Parse(lldb_private::DataExtractor &data, lldb::offset_t *offset) { // Read e_ident. This provides byte order and address size info. if (data.GetU8(offset, &e_ident, EI_NIDENT) == NULL) @@ -190,7 +198,7 @@ ELFSectionHeader::ELFSectionHeader() bool ELFSectionHeader::Parse(const lldb_private::DataExtractor &data, - uint32_t *offset) + lldb::offset_t *offset) { const unsigned byte_size = data.GetAddressByteSize(); @@ -226,7 +234,7 @@ ELFSymbol::ELFSymbol() } bool -ELFSymbol::Parse(const lldb_private::DataExtractor &data, uint32_t *offset) +ELFSymbol::Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset) { const unsigned byte_size = data.GetAddressByteSize(); const bool parsing_32 = byte_size == 4; @@ -276,7 +284,7 @@ ELFProgramHeader::ELFProgramHeader() bool ELFProgramHeader::Parse(const lldb_private::DataExtractor &data, - uint32_t *offset) + lldb::offset_t *offset) { const uint32_t byte_size = data.GetAddressByteSize(); const bool parsing_32 = byte_size == 4; @@ -320,7 +328,7 @@ ELFDynamic::ELFDynamic() } bool -ELFDynamic::Parse(const lldb_private::DataExtractor &data, uint32_t *offset) +ELFDynamic::Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset) { const unsigned byte_size = data.GetAddressByteSize(); return GetMaxS64(data, offset, &d_tag, byte_size, 2); @@ -335,7 +343,7 @@ ELFRel::ELFRel() } bool -ELFRel::Parse(const lldb_private::DataExtractor &data, uint32_t *offset) +ELFRel::Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset) { const unsigned byte_size = data.GetAddressByteSize(); @@ -355,7 +363,7 @@ ELFRela::ELFRela() } bool -ELFRela::Parse(const lldb_private::DataExtractor &data, uint32_t *offset) +ELFRela::Parse(const lldb_private::DataExtractor &data, lldb::offset_t *offset) { const unsigned byte_size = data.GetAddressByteSize(); |