@@ -205,36 +205,7 @@ class ReflectionContext
205
205
return false ;
206
206
207
207
auto Slide = ImageStart.getAddressData () - Command->vmaddr ;
208
- std::string Prefix = " __swift5" ;
209
- uint64_t RangeStart = UINT64_MAX;
210
- uint64_t RangeEnd = UINT64_MAX;
211
208
auto SectionsBuf = reinterpret_cast <const char *>(Sections.get ());
212
- for (unsigned I = 0 ; I < NumSect; ++I) {
213
- auto S = reinterpret_cast <typename T::Section *>(
214
- SectionsBuf + (I * sizeof (typename T::Section)));
215
- if (strncmp (S->sectname , Prefix.c_str (), strlen (Prefix.c_str ())) != 0 )
216
- continue ;
217
- if (RangeStart == UINT64_MAX && RangeEnd == UINT64_MAX) {
218
- RangeStart = S->addr + Slide;
219
- RangeEnd = S->addr + S->size + Slide;
220
- continue ;
221
- }
222
- RangeStart = std::min (RangeStart, (uint64_t )S->addr + Slide);
223
- RangeEnd = std::max (RangeEnd, (uint64_t )(S->addr + S->size + Slide));
224
- // Keep the range rounded to 8 byte alignment on both ends so we don't
225
- // introduce misaligned pointers mapping between local and remote
226
- // address space.
227
- RangeStart = RangeStart & ~7 ;
228
- RangeEnd = RangeEnd + 7 & ~7 ;
229
- }
230
-
231
- if (RangeStart == UINT64_MAX && RangeEnd == UINT64_MAX)
232
- return false ;
233
-
234
- auto SectBuf = this ->getReader ().readBytes (RemoteAddress (RangeStart),
235
- RangeEnd - RangeStart);
236
- if (!SectBuf)
237
- return false ;
238
209
239
210
auto findMachOSectionByName = [&](llvm::StringRef Name)
240
211
-> std::pair<RemoteRef<void >, uint64_t > {
@@ -244,11 +215,13 @@ class ReflectionContext
244
215
if (strncmp (S->sectname , Name.data (), strlen (Name.data ())) != 0 )
245
216
continue ;
246
217
auto RemoteSecStart = S->addr + Slide;
247
- auto SectBufData = reinterpret_cast <const char *>(SectBuf.get ());
248
- auto LocalSectStart =
249
- reinterpret_cast <const char *>(SectBufData + RemoteSecStart - RangeStart);
250
-
251
- auto StartRef = RemoteRef<void >(RemoteSecStart, LocalSectStart);
218
+ auto LocalSectBuf =
219
+ this ->getReader ().readBytes (RemoteAddress (RemoteSecStart), S->size );
220
+ if (!LocalSectBuf)
221
+ return {nullptr , 0 };
222
+
223
+ auto StartRef = RemoteRef<void >(RemoteSecStart, LocalSectBuf.get ());
224
+ savedBuffers.push_back (std::move (LocalSectBuf));
252
225
return {StartRef, S->size };
253
226
}
254
227
return {nullptr , 0 };
@@ -307,7 +280,6 @@ class ReflectionContext
307
280
}
308
281
309
282
savedBuffers.push_back (std::move (Buf));
310
- savedBuffers.push_back (std::move (SectBuf));
311
283
savedBuffers.push_back (std::move (Sections));
312
284
return true ;
313
285
}
0 commit comments