]> granicus.if.org Git - llvm/commitdiff
[llvm-readobj] Fix big-endian byte swap in WindowsResourceDumper.
authorMarek Sokolowski <mnbvmar@gmail.com>
Thu, 21 Sep 2017 20:36:38 +0000 (20:36 +0000)
committerMarek Sokolowski <mnbvmar@gmail.com>
Thu, 21 Sep 2017 20:36:38 +0000 (20:36 +0000)
The previous version of dumper implemented UTF-16 byte swap incorrectly
on big-endian machines. This now gets fixed.

Thanks to Bill Seurer for testing the patch locally.

Differential Review: https://reviews.llvm.org/D38150

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

tools/llvm-readobj/WindowsResourceDumper.cpp

index a1ca929418f425e78d8bce6ff366b9effcd4f462..ac2745fdf3b9a790f867b74af93c49491664443b 100644 (file)
@@ -29,7 +29,7 @@ std::string stripUTF16(const ArrayRef<UTF16> &UTF16Str) {
   for (UTF16 Ch : UTF16Str) {
     // UTF16Str will have swapped byte order in case of big-endian machines.
     // Swap it back in such a case.
-    support::ulittle16_t ChValue(Ch);
+    uint16_t ChValue = support::endian::byte_swap(Ch, support::little);
     if (ChValue <= 0xFF)
       Result += ChValue;
     else