]> granicus.if.org Git - llvm/commitdiff
[JITLink] Remove an overly strict error check in JITLink's eh-frame parser.
authorLang Hames <lhames@gmail.com>
Sun, 21 Apr 2019 04:48:32 +0000 (04:48 +0000)
committerLang Hames <lhames@gmail.com>
Sun, 21 Apr 2019 04:48:32 +0000 (04:48 +0000)
The error check required FDEs to refer to the most recent CIE, but the eh-frame
spec allows them to refer to any previously seen CIE. This patch removes the
offending check.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358840 91177308-0d34-0410-b5e6-96231b3b80d8

lib/ExecutionEngine/JITLink/JITLink_EHFrameSupport.cpp
lib/ExecutionEngine/JITLink/JITLink_EHFrameSupportImpl.h

index 8d94e46cf22d6fa8c5f29b1a26e0bd7db0563382..2aa4a45600cd576b6ccfb9952dcff1eee36963ca 100644 (file)
@@ -164,7 +164,6 @@ Error EHFrameParser::processCIE() {
   LLVM_DEBUG(dbgs() << "  Record is CIE\n");
 
   /// Reset state for the new CIE.
-  MostRecentCIE = CurRecordAtom;
   LSDAFieldPresent = false;
 
   uint8_t Version = 0;
@@ -276,26 +275,19 @@ Error EHFrameParser::processFDE(JITTargetAddress CIEPointerAddress,
                                 uint32_t CIEPointer) {
   LLVM_DEBUG(dbgs() << "  Record is FDE\n");
 
-  // Sanity check the CIE pointer: if this is an FDE it must be proceeded by
-  // a CIE.
-  if (MostRecentCIE == nullptr)
-    return make_error<JITLinkError>("__eh_frame must start with CIE, not "
-                                    "FDE");
-
   LLVM_DEBUG({
     dbgs() << "  CIE pointer: "
            << format("0x%016" PRIx64, CIEPointerAddress - CIEPointer) << "\n";
   });
 
-  // Verify that this FDE's CIE pointer points to the most recent CIE entry.
-  if (CIEPointerAddress - CIEPointer != MostRecentCIE->getAddress())
-    return make_error<JITLinkError>("__eh_frame FDE's CIE Pointer does not "
-                                    "point at the most recent CIE");
+  auto CIEAtom = G.findAtomByAddress(CIEPointerAddress - CIEPointer);
+  if (!CIEAtom)
+    return CIEAtom.takeError();
 
   // The CIEPointer looks good. Add a relocation.
   CurRecordAtom->addEdge(FDEToCIERelocKind,
                          CIEPointerAddress - CurRecordAtom->getAddress(),
-                         *MostRecentCIE, 0);
+                         *CIEAtom, 0);
 
   // Read and sanity check the PC-start pointer and size.
   JITTargetAddress PCBeginAddress = EHFrameAddress + EHFrameReader.getOffset();
index 85b1b803c5d9a9b1522b159b7cbcdf9f09d46f6d..fe4b182401a68182cd1501fbcefcd2725ec286ff 100644 (file)
@@ -50,7 +50,6 @@ private:
   JITTargetAddress EHFrameAddress;
   BinaryStreamReader EHFrameReader;
   DefinedAtom *CurRecordAtom = nullptr;
-  DefinedAtom *MostRecentCIE = nullptr;
   bool LSDAFieldPresent = false;
   Edge::Kind FDEToCIERelocKind;
   Edge::Kind FDEToTargetRelocKind;