[Lldb-commits] [lldb] r174665 - Fixing stale pointer problem in ELFObjectFile

Greg Clayton gclayton at apple.com
Thu Feb 7 13:54:40 PST 2013


Andrew:

In the change:

-            if (data_sp->GetByteSize() < length)
+            if (data_sp->GetByteSize() < length) {
                data_sp = file->MemoryMapFileContents(file_offset, length);
+                magic = data_sp->GetBytes() + data_offset;
+            }

data_offset should be set to zero when you mmap'ed new data. The data passed in in data_sp could have had a non-zero data_offset (the data might be the complete data for a static archive) or data_sp might have just contained 512 of the ELF header... So as soon as you mmap, you reset data_offset to zero so that when you put the data in m_data (the data extractor), it can use the right offset so you grad the correct bytes in all circumstances.

The fixed code is:

             if (data_sp->GetByteSize() < length) {
                 data_sp = file->MemoryMapFileContents(file_offset, length);
                 data_offset = 0;
                 magic = data_sp->GetBytes();
             }

This is fixed with:

% svn commit
Sending        source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
Transmitting file data .
Committed revision 174668.






More information about the lldb-commits mailing list