@@ -322,14 +322,21 @@ class ReflectionContext
322322 : llvm::StringRef (COFFSec->Name , llvm::COFF::NameSize);
323323 if (SectionName != Name)
324324 continue ;
325- auto Addr = ImageStart.getAddressData () + COFFSec->PointerToRawData ;
325+ auto Addr = ImageStart.getAddressData () + COFFSec->VirtualAddress ;
326326 auto Buf = this ->getReader ().readBytes (RemoteAddress (Addr),
327327 COFFSec->VirtualSize );
328328 const char *Begin = reinterpret_cast <const char *>(Buf.get ());
329329 const char *End = Begin + COFFSec->VirtualSize ;
330330 savedBuffers.push_back (std::move (Buf));
331- return {{Begin, End},
332- COFFSec->VirtualAddress - COFFSec->PointerToRawData };
331+
332+ // FIXME: This code needs to be cleaned up and updated
333+ // to make it work for 32 bit platforms.
334+ if (SectionName != " .sw5cptr" ) {
335+ Begin += 8 ;
336+ End -= 8 ;
337+ }
338+
339+ return {{Begin, End}, 0 };
333340 }
334341 return {{nullptr , nullptr }, 0 };
335342 };
@@ -338,20 +345,15 @@ class ReflectionContext
338345 findCOFFSectionByName (" .sw5cptr" );
339346 std::pair<std::pair<const char *, const char *>, uint32_t > TypeRefMdSec =
340347 findCOFFSectionByName (" .sw5tyrf" );
341-
342- // FIXME: Make use of .sw5flmd section (the section content appears to be
343- // incorrect on Windows at the moment).
344- std::pair<std::pair<const char *, const char *>, uint32_t > FieldMdSec = {
345- {nullptr , nullptr }, 0 };
346- // FIXME: Make use of .sw5asty.
347- std::pair<std::pair<const char *, const char *>, uint32_t > AssocTySec = {
348- {nullptr , nullptr }, 0 };
349- // FIXME: Make use of .sw5bltn.
350- std::pair<std::pair<const char *, const char *>, uint32_t > BuiltinTySec = {
351- {nullptr , nullptr }, 0 };
352- // FIXME: Make use of .sw5repl.
353- std::pair<std::pair<const char *, const char *>, uint32_t > ReflStrMdSec = {
354- {nullptr , nullptr }, 0 };
348+ std::pair<std::pair<const char *, const char *>, uint32_t > FieldMdSec =
349+ findCOFFSectionByName (" .sw5flmd" );
350+ std::pair<std::pair<const char *, const char *>, uint32_t > AssocTySec =
351+ findCOFFSectionByName (" .sw5asty" );
352+ // FIXME: Use the section .sw5bltn instead.
353+ std::pair<std::pair<const char *, const char *>, uint32_t > BuiltinTySec =
354+ {{nullptr , nullptr }, 0 };
355+ std::pair<std::pair<const char *, const char *>, uint32_t > ReflStrMdSec =
356+ findCOFFSectionByName (" .sw5rfst" );
355357
356358 if (FieldMdSec.first .first == nullptr &&
357359 AssocTySec.first .first == nullptr &&
@@ -457,12 +459,11 @@ class ReflectionContext
457459 if (SecName != Name)
458460 continue ;
459461 auto SecStart =
460- RemoteAddress (ImageStart.getAddressData () + Hdr->sh_offset );
462+ RemoteAddress (ImageStart.getAddressData () + Hdr->sh_addr );
461463 auto SecSize = Hdr->sh_size ;
462464 auto SecBuf = this ->getReader ().readBytes (SecStart, SecSize);
463465 auto SecContents = reinterpret_cast <const char *>(SecBuf.get ());
464- return {{SecContents, SecContents + SecSize},
465- Hdr->sh_addr - Hdr->sh_offset };
466+ return {{SecContents, SecContents + SecSize}, 0 };
466467 }
467468 return {{nullptr , nullptr }, 0 };
468469 };
0 commit comments