@@ -374,23 +374,28 @@ bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
374
374
375
375
// Get LC_UUID and LC_BUILD_VERSION.
376
376
MachO::uuid_command UUIDCmd;
377
- MachO::build_version_command BuildVersionCmd;
377
+ SmallVector< MachO::build_version_command, 2 > BuildVersionCmd;
378
378
memset (&UUIDCmd, 0 , sizeof (UUIDCmd));
379
- memset (&BuildVersionCmd, 0 , sizeof (BuildVersionCmd));
380
379
for (auto &LCI : InputBinary.load_commands ()) {
381
380
switch (LCI.C .cmd ) {
382
381
case MachO::LC_UUID:
382
+ if (UUIDCmd.cmd )
383
+ return error (" Binary contains more than one UUID" );
383
384
UUIDCmd = InputBinary.getUuidCommand (LCI);
384
385
++NumLoadCommands;
385
- LoadCommandSize += sizeof (MachO::uuid_command );
386
+ LoadCommandSize += sizeof (UUIDCmd );
386
387
break ;
387
- case MachO::LC_BUILD_VERSION:
388
- BuildVersionCmd = InputBinary.getBuildVersionLoadCommand (LCI);
388
+ case MachO::LC_BUILD_VERSION: {
389
+ MachO::build_version_command Cmd;
390
+ memset (&Cmd, 0 , sizeof (Cmd));
391
+ Cmd = InputBinary.getBuildVersionLoadCommand (LCI);
389
392
++NumLoadCommands;
390
- LoadCommandSize += sizeof (MachO::build_version_command );
393
+ LoadCommandSize += sizeof (Cmd );
391
394
// LLDB doesn't care about the build tools for now.
392
- BuildVersionCmd.ntools = 0 ;
395
+ Cmd.ntools = 0 ;
396
+ BuildVersionCmd.push_back (Cmd);
393
397
break ;
398
+ }
394
399
default :
395
400
break ;
396
401
}
@@ -463,13 +468,13 @@ bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
463
468
OutFile.write (reinterpret_cast <const char *>(UUIDCmd.uuid ), 16 );
464
469
assert (OutFile.tell () == HeaderSize + sizeof (UUIDCmd));
465
470
}
466
- if (BuildVersionCmd. cmd != 0 ) {
467
- Writer.W .write <uint32_t >(BuildVersionCmd .cmd );
468
- Writer.W .write <uint32_t >(sizeof (BuildVersionCmd ));
469
- Writer.W .write <uint32_t >(BuildVersionCmd .platform );
470
- Writer.W .write <uint32_t >(BuildVersionCmd .minos );
471
- Writer.W .write <uint32_t >(BuildVersionCmd .sdk );
472
- Writer.W .write <uint32_t >(BuildVersionCmd .ntools );
471
+ for ( auto Cmd : BuildVersionCmd ) {
472
+ Writer.W .write <uint32_t >(Cmd .cmd );
473
+ Writer.W .write <uint32_t >(sizeof (Cmd ));
474
+ Writer.W .write <uint32_t >(Cmd .platform );
475
+ Writer.W .write <uint32_t >(Cmd .minos );
476
+ Writer.W .write <uint32_t >(Cmd .sdk );
477
+ Writer.W .write <uint32_t >(Cmd .ntools );
473
478
}
474
479
475
480
assert (SymtabCmd.cmd && " No symbol table." );
0 commit comments