Changeset 74172 in webkit
- Timestamp:
- Dec 15, 2010 8:35:13 PM (13 years ago)
- Location:
- trunk/WebKit/mac
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/mac/ChangeLog
r74065 r74172 1 2010-12-15 Cameron Zwarich <zwarich@apple.com> 2 3 Reviewed by Darin Adler. 4 5 Clang -Wcast-align gives an error in WebBasePluginPackage.mm 6 https://bugs.webkit.org/show_bug.cgi?id=51144 7 8 Fix an alignment issue. OSSwapInt32 takes data that is 32-bit aligned on ARM, but 9 we were calling it on a byte array 32 bits at a time. While this is okay in practice, 10 since TCMalloc won't give us a non-32-bit aligned block array of bytes and Vector's 11 inline storage is at the beginning of the Vector, it is still better to fix this 12 and silence the warning. 13 14 * Plugins/WebBasePluginPackage.mm: 15 (swapIntsInHeader): 16 (-[WebBasePluginPackage isNativeLibraryData:]): 17 1 18 2010-12-14 Mark Rowe <mrowe@apple.com> 2 19 -
trunk/WebKit/mac/Plugins/WebBasePluginPackage.mm
r65021 r74172 344 344 } 345 345 346 static inline void swapIntsInHeader(uint 8_t* bytes, unsignedlength)347 { 348 for ( unsigned i = 0; i < length; i += 4)349 *(uint32_t*)(bytes + i) = OSSwapInt32(*(uint32_t *)(bytes + i));346 static inline void swapIntsInHeader(uint32_t* rawData, size_t length) 347 { 348 for (size_t i = 0; i < length; ++i) 349 rawData[i] = OSSwapInt32(rawData[i]); 350 350 } 351 351 352 352 - (BOOL)isNativeLibraryData:(NSData *)data 353 353 { 354 Vector<uint8_t, 512> bytes([data length]); 355 memcpy(bytes.data(), [data bytes], bytes.size()); 354 NSUInteger sizeInBytes = [data length]; 355 Vector<uint32_t, 128> rawData((sizeInBytes - 1) / 4 + 1); 356 memcpy(rawData.data(), [data bytes], sizeInBytes); 356 357 357 358 unsigned numArchs = 0; … … 359 360 struct fat_arch* archs = 0; 360 361 361 if ( bytes.size()>= sizeof(struct mach_header_64)) {362 uint32_t magic = *r einterpret_cast<uint32_t*>(bytes.data());362 if (sizeInBytes >= sizeof(struct mach_header_64)) { 363 uint32_t magic = *rawData.data(); 363 364 364 365 if (magic == MH_MAGIC || magic == MH_CIGAM) { 365 366 // We have a 32-bit thin binary 366 struct mach_header* header = (struct mach_header*) bytes.data();367 struct mach_header* header = (struct mach_header*)rawData.data(); 367 368 368 369 // Check if we need to swap the bytes 369 370 if (magic == MH_CIGAM) 370 swapIntsInHeader( bytes.data(), bytes.size());371 swapIntsInHeader(rawData.data(), rawData.size()); 371 372 372 373 singleArch.cputype = header->cputype; … … 377 378 } else if (magic == MH_MAGIC_64 || magic == MH_CIGAM_64) { 378 379 // We have a 64-bit thin binary 379 struct mach_header_64* header = (struct mach_header_64*) bytes.data();380 struct mach_header_64* header = (struct mach_header_64*)rawData.data(); 380 381 381 382 // Check if we need to swap the bytes 382 383 if (magic == MH_CIGAM_64) 383 swapIntsInHeader( bytes.data(), bytes.size());384 swapIntsInHeader(rawData.data(), rawData.size()); 384 385 385 386 singleArch.cputype = header->cputype; … … 393 394 // Check if we need to swap the bytes 394 395 if (magic == FAT_CIGAM) 395 swapIntsInHeader( bytes.data(), bytes.size());396 swapIntsInHeader(rawData.data(), rawData.size()); 396 397 397 archs = (struct fat_arch*)( bytes.data() + sizeof(struct fat_header));398 numArchs = ((struct fat_header *) bytes.data())->nfat_arch;398 archs = (struct fat_arch*)(rawData.data() + sizeof(struct fat_header)); 399 numArchs = ((struct fat_header *)rawData.data())->nfat_arch; 399 400 400 unsigned maxArchs = ( bytes.size()- sizeof(struct fat_header)) / sizeof(struct fat_arch);401 unsigned maxArchs = (sizeInBytes - sizeof(struct fat_header)) / sizeof(struct fat_arch); 401 402 if (numArchs > maxArchs) 402 403 numArchs = maxArchs;
Note: See TracChangeset
for help on using the changeset viewer.