Skip to content

Commit f298603

Browse files
committed
Reflection: remove unnecessary offset for ELF
Don't bother passing the slide for the ELF image as it is always 0.
1 parent 5b2e95d commit f298603

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

include/swift/Reflection/ReflectionContext.h

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ class ReflectionContext
448448
auto StrTab = reinterpret_cast<const char *>(StrTabBuf.get());
449449

450450
auto findELFSectionByName = [&](std::string Name)
451-
-> std::pair<std::pair<const char *, const char *>, uint64_t> {
451+
-> std::pair<const char *, const char *> {
452452
// Now for all the sections, find their name.
453453
for (const typename T::Section *Hdr : SecHdrVec) {
454454
uint32_t Offset = Hdr->sh_name;
@@ -460,9 +460,9 @@ class ReflectionContext
460460
auto SecSize = Hdr->sh_size;
461461
auto SecBuf = this->getReader().readBytes(SecStart, SecSize);
462462
auto SecContents = reinterpret_cast<const char *>(SecBuf.get());
463-
return {{SecContents, SecContents + SecSize}, 0};
463+
return {SecContents, SecContents + SecSize};
464464
}
465-
return {{nullptr, nullptr}, 0};
465+
return {nullptr, nullptr};
466466
};
467467

468468
auto FieldMdSec = findELFSectionByName("swift5_fieldmd");
@@ -474,28 +474,25 @@ class ReflectionContext
474474

475475
// We succeed if at least one of the sections is present in the
476476
// ELF executable.
477-
if (FieldMdSec.first.first == nullptr &&
478-
AssocTySec.first.first == nullptr &&
479-
BuiltinTySec.first.first == nullptr &&
480-
CaptureSec.first.first == nullptr &&
481-
TypeRefMdSec.first.first == nullptr &&
482-
ReflStrMdSec.first.first == nullptr)
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)
483483
return false;
484484

485485
auto LocalStartAddress = reinterpret_cast<uint64_t>(Buf.get());
486486
auto RemoteStartAddress =
487487
static_cast<uint64_t>(ImageStart.getAddressData());
488488

489489
ReflectionInfo info = {
490-
{{FieldMdSec.first.first, FieldMdSec.first.second}, FieldMdSec.second},
491-
{{AssocTySec.first.first, AssocTySec.first.second}, AssocTySec.second},
492-
{{BuiltinTySec.first.first, BuiltinTySec.first.second},
493-
BuiltinTySec.second},
494-
{{CaptureSec.first.first, CaptureSec.first.second}, CaptureSec.second},
495-
{{TypeRefMdSec.first.first, TypeRefMdSec.first.second},
496-
TypeRefMdSec.second},
497-
{{ReflStrMdSec.first.first, ReflStrMdSec.first.second},
498-
ReflStrMdSec.second},
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},
499496
LocalStartAddress,
500497
RemoteStartAddress};
501498

0 commit comments

Comments
 (0)