Changeset 310 for trunk/util
- Timestamp:
- 06/14/08 09:29:39 (7 months ago)
- Files:
-
- 1 modified
-
trunk/util/ldid.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/util/ldid.cpp
r302 r310 218 218 } 219 219 220 struct mach_header *operator ->() const { 221 return mach_header_; 222 } 223 220 224 void *GetBase() { 221 225 return base_; … … 242 246 #define CSMAGIC_EMBEDDED_SIGNATURE 0xfade0cc0 243 247 #define CSSLOT_CODEDIRECTORY 0 248 #define CSSLOT_REQUIREMENTS 2 244 249 245 250 struct BlobIndex { … … 347 352 allocate = "codesign_allocate"; 348 353 349 size_t size; { 354 size_t size = _not(size_t); 355 const char *arch; { 350 356 Framework framework(path); 351 size = framework.GetSize(); 357 _foreach (load_command, framework.GetLoadCommands()) { 358 uint32_t cmd(framework.Swap((*load_command)->cmd)); 359 if (cmd == LC_CODE_SIGNATURE) { 360 struct linkedit_data_command *signature = reinterpret_cast<struct linkedit_data_command *>(*load_command); 361 size = framework.Swap(signature->dataoff); 362 _assert(size < framework.GetSize()); 363 break; 364 } 365 } 366 367 if (size == _not(size_t)) 368 size = framework.GetSize(); 369 370 switch (framework->cputype) { 371 case 12: switch (framework->cpusubtype) { 372 case 0: arch = "arm"; break; 373 case 6: arch = "armv6"; break; 374 default: arch = NULL; break; 375 } break; 376 377 default: arch = NULL; break; 378 } 352 379 } 380 381 _assert(arch != NULL); 353 382 354 383 pid_t pid = fork(); … … 356 385 if (pid == 0) { 357 386 char *ssize; 358 asprintf(&ssize, "%u", (sizeof(struct SuperBlob) + sizeof(struct BlobIndex) + sizeof(struct CodeDirectory) + strlen(base) + 1 + (size + 0x1000 - 1) / 0x1000 * 0x14 + 15) / 16 * 16); 359 printf("%s\n", ssize); 360 execlp(allocate, allocate, "-i", path, "-a", "arm", ssize, "-o", temp, NULL); 387 asprintf(&ssize, "%u", (sizeof(struct SuperBlob) + 2 * sizeof(struct BlobIndex) + sizeof(struct CodeDirectory) + strlen(base) + 1 + (size + 0x1000 - 1) / 0x1000 * 0x14 + 0xc + 15) / 16 * 16); 388 execlp(allocate, allocate, "-i", path, "-a", arch, ssize, "-o", temp, NULL); 361 389 _assert(false); 362 390 } … … 424 452 super->magic = Swap(CSMAGIC_EMBEDDED_SIGNATURE); 425 453 426 uint32_t count = 1;454 uint32_t count = 2; 427 455 uint32_t offset = sizeof(struct SuperBlob) + count * sizeof(struct BlobIndex); 428 456 … … 465 493 directory->length = Swap(offset - begin); 466 494 495 super->index[1].type = Swap(CSSLOT_REQUIREMENTS); 496 super->index[1].offset = Swap(offset); 497 498 memcpy(blob + offset, "\xfa\xde\x0c\x01\x00\x00\x00\x0c\x00\x00\x00\x00", 0xc); 499 offset += 0xc; 500 467 501 super->count = Swap(count); 468 502 super->length = Swap(offset); 469 503 470 _assert(offset < size);504 _assert(offset <= size); 471 505 memset(blob + offset, 0, size - offset); 472 506 }
