@@ -202,7 +202,7 @@ class ReflectionContext
202
202
RangeEnd - RangeStart);
203
203
204
204
auto findMachOSectionByName = [&](std::string Name)
205
- -> std::pair<const char *, const char *> {
205
+ -> std::pair<std::pair< const char *, const char *>, uint64_t > {
206
206
for (unsigned I = 0 ; I < NumSect; ++I) {
207
207
auto S = reinterpret_cast <typename T::Section *>(
208
208
SectionsBuf + (I * sizeof (typename T::Section)));
@@ -213,9 +213,9 @@ class ReflectionContext
213
213
auto LocalSectStart =
214
214
reinterpret_cast <const char *>(SectBufData + RemoteSecStart - RangeStart);
215
215
auto LocalSectEnd = reinterpret_cast <const char *>(LocalSectStart + S->size );
216
- return {LocalSectStart, LocalSectEnd};
216
+ return {{ LocalSectStart, LocalSectEnd}, 0 };
217
217
}
218
- return {nullptr , nullptr };
218
+ return {{ nullptr , nullptr }, 0 };
219
219
};
220
220
221
221
auto FieldMdSec = findMachOSectionByName (" __swift5_fieldmd" );
@@ -225,24 +225,24 @@ class ReflectionContext
225
225
auto TypeRefMdSec = findMachOSectionByName (" __swift5_typeref" );
226
226
auto ReflStrMdSec = findMachOSectionByName (" __swift5_reflstr" );
227
227
228
- if (FieldMdSec.first == nullptr &&
229
- AssocTySec.first == nullptr &&
230
- BuiltinTySec.first == nullptr &&
231
- CaptureSec.first == nullptr &&
232
- TypeRefMdSec.first == nullptr &&
233
- ReflStrMdSec.first == nullptr )
228
+ if (FieldMdSec.first . first == nullptr &&
229
+ AssocTySec.first . first == nullptr &&
230
+ BuiltinTySec.first . first == nullptr &&
231
+ CaptureSec.first . first == nullptr &&
232
+ TypeRefMdSec.first . first == nullptr &&
233
+ ReflStrMdSec.first . first == nullptr )
234
234
return false ;
235
235
236
236
auto LocalStartAddress = reinterpret_cast <uint64_t >(SectBuf.get ());
237
237
auto RemoteStartAddress = static_cast <uint64_t >(RangeStart);
238
238
239
239
ReflectionInfo info = {
240
- {{FieldMdSec.first , FieldMdSec.second }, 0 },
241
- {{AssocTySec.first , AssocTySec.second }, 0 },
242
- {{BuiltinTySec.first , BuiltinTySec.second }, 0 },
243
- {{CaptureSec.first , CaptureSec.second }, 0 },
244
- {{TypeRefMdSec.first , TypeRefMdSec.second }, 0 },
245
- {{ReflStrMdSec.first , ReflStrMdSec.second }, 0 },
240
+ {{FieldMdSec.first . first , FieldMdSec. first .second }, 0 },
241
+ {{AssocTySec.first . first , AssocTySec. first .second }, 0 },
242
+ {{BuiltinTySec.first . first , BuiltinTySec. first .second }, 0 },
243
+ {{CaptureSec.first . first , CaptureSec. first .second }, 0 },
244
+ {{TypeRefMdSec.first . first , TypeRefMdSec. first .second }, 0 },
245
+ {{ReflStrMdSec.first . first , ReflStrMdSec. first .second }, 0 },
246
246
LocalStartAddress,
247
247
RemoteStartAddress};
248
248
@@ -310,7 +310,7 @@ class ReflectionContext
310
310
sizeof (llvm::object::coff_section) * COFFFileHdr->NumberOfSections );
311
311
312
312
auto findCOFFSectionByName = [&](llvm::StringRef Name)
313
- -> std::pair<const char *, const char *> {
313
+ -> std::pair<std::pair< const char *, const char *>, uint32_t > {
314
314
for (size_t i = 0 ; i < COFFFileHdr->NumberOfSections ; ++i) {
315
315
const llvm::object::coff_section *COFFSec =
316
316
reinterpret_cast <const llvm::object::coff_section *>(
@@ -336,43 +336,45 @@ class ReflectionContext
336
336
End -= 8 ;
337
337
}
338
338
339
- return {Begin, End};
339
+ return {{ Begin, End}, 0 };
340
340
}
341
- return {nullptr , nullptr };
341
+ return {{ nullptr , nullptr }, 0 };
342
342
};
343
343
344
- std::pair<const char *, const char *> CaptureSec =
344
+ std::pair<std::pair< const char *, const char *>, uint32_t > CaptureSec =
345
345
findCOFFSectionByName (" .sw5cptr" );
346
- std::pair<const char *, const char *> TypeRefMdSec =
346
+ std::pair<std::pair< const char *, const char *>, uint32_t > TypeRefMdSec =
347
347
findCOFFSectionByName (" .sw5tyrf" );
348
- std::pair<const char *, const char *> FieldMdSec =
348
+ std::pair<std::pair< const char *, const char *>, uint32_t > FieldMdSec =
349
349
findCOFFSectionByName (" .sw5flmd" );
350
- std::pair<const char *, const char *> AssocTySec =
350
+ std::pair<std::pair< const char *, const char *>, uint32_t > AssocTySec =
351
351
findCOFFSectionByName (" .sw5asty" );
352
- std::pair<const char *, const char *> BuiltinTySec =
352
+ std::pair<std::pair< const char *, const char *>, uint32_t > BuiltinTySec =
353
353
findCOFFSectionByName (" .sw5bltn" );
354
- std::pair<const char *, const char *> ReflStrMdSec =
354
+ std::pair<std::pair< const char *, const char *>, uint32_t > ReflStrMdSec =
355
355
findCOFFSectionByName (" .sw5rfst" );
356
356
357
- if (FieldMdSec.first == nullptr &&
358
- AssocTySec.first == nullptr &&
359
- BuiltinTySec.first == nullptr &&
360
- CaptureSec.first == nullptr &&
361
- TypeRefMdSec.first == nullptr &&
362
- ReflStrMdSec.first == nullptr )
357
+ if (FieldMdSec.first . first == nullptr &&
358
+ AssocTySec.first . first == nullptr &&
359
+ BuiltinTySec.first . first == nullptr &&
360
+ CaptureSec.first . first == nullptr &&
361
+ TypeRefMdSec.first . first == nullptr &&
362
+ ReflStrMdSec.first . first == nullptr )
363
363
return false ;
364
-
365
364
auto LocalStartAddress = reinterpret_cast <uintptr_t >(DOSHdrBuf.get ());
366
365
auto RemoteStartAddress =
367
366
static_cast <uintptr_t >(ImageStart.getAddressData ());
368
367
369
368
ReflectionInfo Info = {
370
- {{FieldMdSec.first , FieldMdSec.second }, 0 },
371
- {{AssocTySec.first , AssocTySec.second }, 0 },
372
- {{BuiltinTySec.first , BuiltinTySec.second }, 0 },
373
- {{CaptureSec.first , CaptureSec.second }, 0 },
374
- {{TypeRefMdSec.first , TypeRefMdSec.second }, 0 },
375
- {{ReflStrMdSec.first , ReflStrMdSec.second }, 0 },
369
+ {{FieldMdSec.first .first , FieldMdSec.first .second }, FieldMdSec.second },
370
+ {{AssocTySec.first .first , AssocTySec.first .second }, AssocTySec.second },
371
+ {{BuiltinTySec.first .first , BuiltinTySec.first .second },
372
+ BuiltinTySec.second },
373
+ {{CaptureSec.first .first , CaptureSec.first .second }, CaptureSec.second },
374
+ {{TypeRefMdSec.first .first , TypeRefMdSec.first .second },
375
+ TypeRefMdSec.second },
376
+ {{ReflStrMdSec.first .first , ReflStrMdSec.first .second },
377
+ ReflStrMdSec.second },
376
378
LocalStartAddress,
377
379
RemoteStartAddress};
378
380
this ->addReflectionInfo (Info);
@@ -448,7 +450,7 @@ class ReflectionContext
448
450
auto StrTab = reinterpret_cast <const char *>(StrTabBuf.get ());
449
451
450
452
auto findELFSectionByName = [&](std::string Name)
451
- -> std::pair<const char *, const char *> {
453
+ -> std::pair<std::pair< const char *, const char *>, uint64_t > {
452
454
// Now for all the sections, find their name.
453
455
for (const typename T::Section *Hdr : SecHdrVec) {
454
456
uint32_t Offset = Hdr->sh_name ;
@@ -460,9 +462,9 @@ class ReflectionContext
460
462
auto SecSize = Hdr->sh_size ;
461
463
auto SecBuf = this ->getReader ().readBytes (SecStart, SecSize);
462
464
auto SecContents = reinterpret_cast <const char *>(SecBuf.get ());
463
- return {SecContents, SecContents + SecSize};
465
+ return {{ SecContents, SecContents + SecSize}, 0 };
464
466
}
465
- return {nullptr , nullptr };
467
+ return {{ nullptr , nullptr }, 0 };
466
468
};
467
469
468
470
auto FieldMdSec = findELFSectionByName (" swift5_fieldmd" );
@@ -474,25 +476,28 @@ class ReflectionContext
474
476
475
477
// We succeed if at least one of the sections is present in the
476
478
// ELF executable.
477
- if (FieldMdSec.first == nullptr &&
478
- AssocTySec.first == nullptr &&
479
- BuiltinTySec.first == nullptr &&
480
- CaptureSec.first == nullptr &&
481
- TypeRefMdSec.first == nullptr &&
482
- ReflStrMdSec.first == nullptr )
479
+ if (FieldMdSec.first . first == nullptr &&
480
+ AssocTySec.first . first == nullptr &&
481
+ BuiltinTySec.first . first == nullptr &&
482
+ CaptureSec.first . first == nullptr &&
483
+ TypeRefMdSec.first . first == nullptr &&
484
+ ReflStrMdSec.first . first == nullptr )
483
485
return false ;
484
486
485
487
auto LocalStartAddress = reinterpret_cast <uint64_t >(Buf.get ());
486
488
auto RemoteStartAddress =
487
489
static_cast <uint64_t >(ImageStart.getAddressData ());
488
490
489
491
ReflectionInfo info = {
490
- {{FieldMdSec.first , FieldMdSec.second }, 0 },
491
- {{AssocTySec.first , AssocTySec.second }, 0 },
492
- {{BuiltinTySec.first , BuiltinTySec.second }, 0 },
493
- {{CaptureSec.first , CaptureSec.second }, 0 },
494
- {{TypeRefMdSec.first , TypeRefMdSec.second }, 0 },
495
- {{ReflStrMdSec.first , ReflStrMdSec.second }, 0 },
492
+ {{FieldMdSec.first .first , FieldMdSec.first .second }, FieldMdSec.second },
493
+ {{AssocTySec.first .first , AssocTySec.first .second }, AssocTySec.second },
494
+ {{BuiltinTySec.first .first , BuiltinTySec.first .second },
495
+ BuiltinTySec.second },
496
+ {{CaptureSec.first .first , CaptureSec.first .second }, CaptureSec.second },
497
+ {{TypeRefMdSec.first .first , TypeRefMdSec.first .second },
498
+ TypeRefMdSec.second },
499
+ {{ReflStrMdSec.first .first , ReflStrMdSec.first .second },
500
+ ReflStrMdSec.second },
496
501
LocalStartAddress,
497
502
RemoteStartAddress};
498
503
0 commit comments