]> granicus.if.org Git - llvm/commitdiff
[llvm-readobj] Fix 'Teach readobj to dump .res files', pt 2.
authorMarek Sokolowski <mnbvmar@gmail.com>
Wed, 20 Sep 2017 23:07:39 +0000 (23:07 +0000)
committerMarek Sokolowski <mnbvmar@gmail.com>
Wed, 20 Sep 2017 23:07:39 +0000 (23:07 +0000)
Another fix-up for r313790. Big-endian hosts swapped byte order in
UTF16 words.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313833 91177308-0d34-0410-b5e6-96231b3b80d8

tools/llvm-readobj/WindowsResourceDumper.cpp

index d1d415d0916e6bc5929480f87f63cacad55451e6..bbe573d95284890c5e703034fe12ad48956d88a9 100644 (file)
@@ -26,8 +26,11 @@ std::string stripUTF16(const ArrayRef<UTF16> &UTF16Str) {
   Result.reserve(UTF16Str.size());
 
   for (UTF16 Ch : UTF16Str) {
-    if (Ch <= 0xFF)
-      Result += Ch;
+    // UTF16Str will have swapped byte order in case of big-endian machines.
+    // Swap it back in such a case.
+    ulittle16_t ChValue = Ch;
+    if (ChValue <= 0xFF)
+      Result += ChValue;
     else
       Result += '?';
   }