[Lldb-commits] [PATCH] Add assertion that byte-swapping is only performed on register-sized copies

Ed Maste emaste at freebsd.org
Wed Sep 18 08:24:46 PDT 2013


On 17 September 2013 14:51, Ed Maste <emaste at freebsd.org> wrote:
> I believe that we should only ever reverse a block that corresponds to (some) register size.

Adding the assert shows that ObjectFile::CopyData is the source of the
reversed output for "memory read" on a big-endian target.  There are
other instances that copy a block of target memory to a buffer
intended to remain in target byte order.  If there are any CopyData
callers that directly fetch a target word (and thus need endian
swapping), they can be changed to use a DataExtractor instead (via
ObjectFile::GetData).

This change fixes the "memory read" issue:

--- a/source/Symbol/ObjectFile.cpp
+++ b/source/Symbol/ObjectFile.cpp
@@ -459,7 +459,8 @@ size_t
 ObjectFile::CopyData (off_t offset, size_t length, void *dst) const
 {
     // The entire file has already been mmap'ed into m_data, so just
copy from there
-    return m_data.CopyByteOrderedData (offset, length, dst, length,
lldb::endian::InlHostByteOrder());
+    // Note that the data remains in target byte order.
+    return m_data.CopyByteOrderedData (offset, length, dst, length,
m_data.GetByteOrder());
}

This change and the assert in review D1701 should be NOPs for the
current x86 and arm little-endian targets.  I'd like to commit these
sorts of changes as I encounter them (even though there are many
remaining endianness issues), both to help FĂ©lix Cloutier's work on
the PPC target, and to help solidify expectations on endianness as
other development continues.  Does that seem reasonable?




More information about the lldb-commits mailing list