[PATCH] [lld] [mach-o] make lld respect alignment constraints more

Tim Northover t.p.northover at gmail.com
Fri Oct 17 11:47:15 PDT 2014


================
Comment at: lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp:266-267
@@ -265,4 +265,4 @@
       const dysymtab_command *d = reinterpret_cast<const dysymtab_command*>(lc);
-      indirectSymbolTableOffset = read32(swap, d->indirectsymoff);
-      indirectSymbolTableCount = read32(swap, d->nindirectsyms);
+      indirectSymbolTableOffset = read32((uint8_t *)&d->indirectsymoff, isBig);
+      indirectSymbolTableCount = read32((uint8_t *)&d->nindirectsyms, isBig);
       return true;
----------------
kledzik wrote:
> This is sad that the casts are needed.  Perhaps, read32() can be overloaded to take a uint32_t* so all these casts can be removed.
I was trying to avoid it (even creating improperly aligned pointers is very dodgy, anything making that easier is a worry), but there are a lot of casts here. I'll make them templated and put an assertion about pointer alignment in there.

http://reviews.llvm.org/D5811






More information about the llvm-commits mailing list