[llvm] r259103 - [RuntimeDyld][MachO] Fix handling of empty eh-frame sections.

Lang Hames via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 14:35:49 PST 2016


Author: lhames
Date: Thu Jan 28 16:35:48 2016
New Revision: 259103

URL: http://llvm.org/viewvc/llvm-project?rev=259103&view=rev
Log:
[RuntimeDyld][MachO] Fix handling of empty eh-frame sections.

This patch switches from an unguarded to a guarded loop for eh-frame record
fixups. In the unguarded version we would always make at least one call to
processFDE, which would then crash trying to fix up a frame that didn't exist.

Fixes <rdar://problem/24301582>


Added:
    llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_empty_ehframe.s
Modified:
    llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp

Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=259103&r1=259102&r2=259103&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Thu Jan 28 16:35:48 2016
@@ -302,9 +302,9 @@ void RuntimeDyldMachOCRTPBase<Impl>::reg
 
     uint8_t *P = EHFrame->getAddress();
     uint8_t *End = P + EHFrame->getSize();
-    do {
+    while (P != End) {
       P = processFDE(P, DeltaForText, DeltaForEH);
-    } while (P != End);
+    }
 
     MemMgr.registerEHFrames(EHFrame->getAddress(), EHFrame->getLoadAddress(),
                             EHFrame->getSize());

Added: llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_empty_ehframe.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_empty_ehframe.s?rev=259103&view=auto
==============================================================================
--- llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_empty_ehframe.s (added)
+++ llvm/trunk/test/ExecutionEngine/RuntimeDyld/X86/MachO_empty_ehframe.s Thu Jan 28 16:35:48 2016
@@ -0,0 +1,7 @@
+# RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj -o %T/empty_eh_frame.o %s
+# RUN: llvm-rtdyld -verify -triple=x86_64-apple-macosx10.9 %T/empty_eh_frame.o
+
+        .section        __TEXT,__eh_frame
+	.macosx_version_min 10, 10
+
+.subsections_via_symbols




More information about the llvm-commits mailing list