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

Kaylor, Andrew andrew.kaylor at intel.com
Thu Feb 7 14:40:12 PST 2013


OK, thanks.

The data_offset was already zero when I was debugging this, so I wasn't sure what to do with it.

-Andy

-----Original Message-----
From: Greg Clayton [mailto:gclayton at apple.com] 
Sent: Thursday, February 07, 2013 1:55 PM
To: Kaylor, Andrew
Cc: lldb-commits at cs.uiuc.edu
Subject: Re: [Lldb-commits] [lldb] r174665 - Fixing stale pointer problem in ELFObjectFile

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