[PATCH] D35022: [MachO] Add missing byte-swaps when reading dyld_info

Tom Stellard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 5 10:27:34 PDT 2017


tstellar created this revision.

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


https://reviews.llvm.org/D35022

Files:
  lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp


Index: lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
===================================================================
--- lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
+++ lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
@@ -508,9 +508,9 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35022.105303.patch
Type: text/x-patch
Size: 1014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170705/76a5a754/attachment.bin>


More information about the llvm-commits mailing list