[llvm] r185422 - Fix ARM EHABI compact model 1 and 2 without handlerdata.

Logan Chien tzuhsiang.chien at gmail.com
Tue Jul 2 05:43:28 PDT 2013


Author: logan
Date: Tue Jul  2 07:43:27 2013
New Revision: 185422

URL: http://llvm.org/viewvc/llvm-project?rev=185422&view=rev
Log:
Fix ARM EHABI compact model 1 and 2 without handlerdata.

According to ARM EHABI section 9.2, if the
__aeabi_unwind_cpp_pr1() or __aeabi_unwind_cpp_pr2() is
used, then the handler data must be emitted after the unwind
opcodes.  The handler data consists of several words, and
should be terminated by zero.

In case that the .handlerdata directive is not specified by
the programmer, we should emit zero to terminate the handler
data.


Modified:
    llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
    llvm/trunk/test/MC/ARM/eh-compact-pr1.s

Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp?rev=185422&r1=185421&r2=185422&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp (original)
+++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMELFStreamer.cpp Tue Jul  2 07:43:27 2013
@@ -204,7 +204,7 @@ private:
 
   void EmitPersonalityFixup(StringRef Name);
   void FlushPendingOffset();
-  void FlushUnwindOpcodes(bool AllowCompactModel0);
+  void FlushUnwindOpcodes(bool NoHandlerData);
 
   void SwitchToEHSection(const char *Prefix, unsigned Type, unsigned Flags,
                          SectionKind Kind, const MCSymbol &Fn);
@@ -377,7 +377,7 @@ void ARMELFStreamer::FlushPendingOffset(
   }
 }
 
-void ARMELFStreamer::FlushUnwindOpcodes(bool AllowCompactModel0) {
+void ARMELFStreamer::FlushUnwindOpcodes(bool NoHandlerData) {
   // Emit the unwind opcode to restore $sp.
   if (UsedFP) {
     const MCRegisterInfo *MRI = getContext().getRegisterInfo();
@@ -394,7 +394,7 @@ void ARMELFStreamer::FlushUnwindOpcodes(
   // For compact model 0, we have to emit the unwind opcodes in the .ARM.exidx
   // section.  Thus, we don't have to create an entry in the .ARM.extab
   // section.
-  if (AllowCompactModel0 && PersonalityIndex == AEABI_UNWIND_CPP_PR0)
+  if (NoHandlerData && PersonalityIndex == AEABI_UNWIND_CPP_PR0)
     return;
 
   // Switch to .ARM.extab section.
@@ -418,6 +418,16 @@ void ARMELFStreamer::FlushUnwindOpcodes(
   // Emit unwind opcodes
   EmitBytes(StringRef(reinterpret_cast<const char *>(Opcodes.data()),
                       Opcodes.size()), 0);
+
+  // According to ARM EHABI section 9.2, if the __aeabi_unwind_cpp_pr1() or
+  // __aeabi_unwind_cpp_pr2() is used, then the handler data must be emitted
+  // after the unwind opcodes.  The handler data consists of several 32-bit
+  // words, and should be terminated by zero.
+  //
+  // In case that the .handlerdata directive is not specified by the
+  // programmer, we should emit zero to terminate the handler data.
+  if (NoHandlerData && !Personality)
+    EmitIntValue(0, 4);
 }
 
 void ARMELFStreamer::EmitHandlerData() {

Modified: llvm/trunk/test/MC/ARM/eh-compact-pr1.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/eh-compact-pr1.s?rev=185422&r1=185421&r2=185422&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/eh-compact-pr1.s (original)
+++ llvm/trunk/test/MC/ARM/eh-compact-pr1.s Tue Jul  2 07:43:27 2013
@@ -46,7 +46,7 @@ func1:
 @ 0xB0   = finish
 @-------------------------------------------------------------------------------
 @ CHECK:     SectionData (
-@ CHECK:       0000: 419B0181 B0B08384                    |A.......|
+@ CHECK:       0000: 419B0181 B0B08384 00000000           |A...........|
 @ CHECK:     )
 @ CHECK:   }
 





More information about the llvm-commits mailing list