[lld] r307405 - [MachO] Add missing byte-swaps when reading dyld_info

Tom Stellard via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 7 08:20:17 PDT 2017


Author: tstellar
Date: Fri Jul  7 08:20:17 2017
New Revision: 307405

URL: http://llvm.org/viewvc/llvm-project?rev=307405&view=rev
Log:
[MachO] Add missing byte-swaps when reading dyld_info

Summary:
This fixes the following tests on big-endian hosts:

lld :: mach-o/dylib-install-names.yaml
lld :: mach-o/force_load-dylib.yaml
lld :: mach-o/lib-search-paths.yaml
lld :: mach-o/upward-dylib-load-command.yaml

Reviewers: lhames, kledzik, ruiu

Reviewed By: ruiu

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D35022

Modified:
    lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp

Modified: lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp?rev=307405&r1=307404&r2=307405&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp (original)
+++ lld/trunk/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp Fri Jul  7 08:20:17 2017
@@ -508,9 +508,9 @@ readBinary(std::unique_ptr<MemoryBuffer>
   if (dyldInfo) {
     // If any exports, extract and add to normalized exportInfo vector.
     if (dyldInfo->export_size) {
-      const uint8_t *trieStart = reinterpret_cast<const uint8_t*>(start +
-                                                          dyldInfo->export_off);
-      ArrayRef<uint8_t> trie(trieStart, dyldInfo->export_size);
+      const uint8_t *trieStart = reinterpret_cast<const uint8_t *>(
+          start + read32(&dyldInfo->export_off, isBig));
+      ArrayRef<uint8_t> trie(trieStart, read32(&dyldInfo->export_size, isBig));
       for (const ExportEntry &trieExport : MachOObjectFile::exports(trie)) {
         Export normExport;
         normExport.name = trieExport.name().copy(f->ownedAllocations);




More information about the llvm-commits mailing list