From b63355ef7736f4169c15e720d3f2dfcd90179323 Mon Sep 17 00:00:00 2001 From: Marek Sokolowski Date: Thu, 21 Sep 2017 20:36:38 +0000 Subject: [PATCH] [llvm-readobj] Fix big-endian byte swap in WindowsResourceDumper. 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 llvm-svn: 313912 --- llvm/tools/llvm-readobj/WindowsResourceDumper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp b/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp index a1ca929418f4..ac2745fdf3b9 100644 --- a/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp +++ b/llvm/tools/llvm-readobj/WindowsResourceDumper.cpp @@ -29,7 +29,7 @@ std::string stripUTF16(const ArrayRef &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