Fix couple of bugs connected with eh info:
authorAnton Korobeynikov <asl@math.spbu.ru>
Tue, 1 May 2007 22:23:12 +0000 (22:23 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Tue, 1 May 2007 22:23:12 +0000 (22:23 +0000)
1. Correct output offsets on Linux
2. Fix "style" of personality function. It shouldn't be indirect.

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

include/llvm/Target/TargetAsmInfo.h
lib/CodeGen/DwarfWriter.cpp
lib/Target/TargetAsmInfo.cpp
lib/Target/X86/X86TargetAsmInfo.cpp

index ceb2a3af475642b33c2a03018252515b3e50d1e6..0a9047beec015ebd16dd1f9d0f18c81e7d8567a4 100644 (file)
@@ -263,10 +263,14 @@ namespace llvm {
 
     //===--- Dwarf Emission Directives -----------------------------------===//
 
-    /// AbsoluteSectionOffsets - True if we should emit abolute section
-    /// offsets. Defaults to false.
-    bool AbsoluteSectionOffsets;
-    
+    /// AbsoluteDebugSectionOffsets - True if we should emit abolute section
+    /// offsets for debug information. Defaults to false.
+    bool AbsoluteDebugSectionOffsets;
+
+    /// AbsoluteEHSectionOffsets - True if we should emit abolute section
+    /// offsets for EH information. Defaults to false.
+    bool AbsoluteEHSectionOffsets;
+
     /// HasLEB128 - True if target asm supports leb128 directives.
     ///
     bool HasLEB128; // Defaults to false.
@@ -530,8 +534,11 @@ namespace llvm {
     const char *getProtectedDirective() const {
       return ProtectedDirective;
     }
-    bool isAbsoluteSectionOffsets() const {
-      return AbsoluteSectionOffsets;
+    bool isAbsoluteDebugSectionOffsets() const {
+      return AbsoluteDebugSectionOffsets;
+    }
+    bool isAbsoluteEHSectionOffsets() const {
+      return AbsoluteEHSectionOffsets;
     }
     bool hasLEB128() const {
       return HasLEB128;
index 1ca9e218375fddc30018d46cbc648fec037548f0..55c2b0984900526cdc3fa98ce08a13d2292c160a 100644 (file)
@@ -914,13 +914,20 @@ public:
 
   void EmitSectionOffset(const char* Label, const char* Section,
                          unsigned LabelNumber, unsigned SectionNumber,
-                         bool IsSmall = false) {
+                         bool IsSmall = false, bool isEH = false) {
+    bool printAbsolute = false;
     if (TAI->needsSet()) {
       O << "\t.set\t";
       PrintLabelName("set", SetCounter);
       O << ",";
       PrintLabelName(Label, LabelNumber, true);
-      if (!TAI->isAbsoluteSectionOffsets()) {
+
+      if (isEH)
+        printAbsolute = TAI->isAbsoluteEHSectionOffsets();
+      else
+        printAbsolute = TAI->isAbsoluteDebugSectionOffsets();
+      
+      if (!printAbsolute) {
         O << "-";
         PrintLabelName(Section, SectionNumber);
       }      
@@ -940,7 +947,13 @@ public:
         O << TAI->getData64bitsDirective();
         
       PrintLabelName(Label, LabelNumber, true);
-      if (!TAI->isAbsoluteSectionOffsets()) {
+
+      if (isEH)
+        printAbsolute = TAI->isAbsoluteEHSectionOffsets();
+      else
+        printAbsolute = TAI->isAbsoluteDebugSectionOffsets();
+
+      if (!printAbsolute) {
         O << "-";
         PrintLabelName(Section, SectionNumber);
       }
@@ -1688,7 +1701,7 @@ private:
   CompileUnit *NewCompileUnit(CompileUnitDesc *UnitDesc, unsigned ID) {
     // Construct debug information entry.
     DIE *Die = new DIE(DW_TAG_compile_unit);
-    if (TAI->isAbsoluteSectionOffsets())
+    if (TAI->isAbsoluteDebugSectionOffsets())
       AddLabel(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0));
     else
       AddDelta(Die, DW_AT_stmt_list, DW_FORM_data4, DWLabel("section_line", 0),
@@ -2107,7 +2120,7 @@ private:
                            
     Asm->EmitInt32(ContentSize);  Asm->EOL("Length of Compilation Unit Info");
     Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF version number");
-    EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true);
+    EmitSectionOffset("abbrev_begin", "section_abbrev", 0, 0, true, false);
     Asm->EOL("Offset Into Abbrev. Section");
     Asm->EmitInt8(TAI->getAddressSize()); Asm->EOL("Address Size (in bytes)");
   
@@ -2366,7 +2379,7 @@ private:
     
     EmitLabel("frame_begin", SubprogramCount);
 
-    EmitSectionOffset("frame_common_begin", "section_frame", 0, 0, true);
+    EmitSectionOffset("frame_common_begin", "section_frame", 0, 0, true, false);
     Asm->EOL("FDE CIE offset");
 
     EmitReference("func_begin", SubprogramCount);
@@ -2401,7 +2414,8 @@ private:
     
     Asm->EmitInt16(DWARF_VERSION); Asm->EOL("DWARF Version");
 
-    EmitSectionOffset("info_begin", "section_info", Unit->getID(), 0, true);
+    EmitSectionOffset("info_begin", "section_info",
+                      Unit->getID(), 0, true, false);
     Asm->EOL("Offset of Compilation Unit Info");
 
     EmitDifference("info_end", Unit->getID(), "info_begin", Unit->getID(),true);
@@ -2769,10 +2783,8 @@ private:
     if (Personality) {
       Asm->EmitULEB128Bytes(7);
       Asm->EOL("Augmentation Size");
-      Asm->EmitInt8(DW_EH_PE_indirect |
-                            DW_EH_PE_pcrel |
-                            DW_EH_PE_sdata4);
-      Asm->EOL("Personality (indirect pcrel sdata4)");
+      Asm->EmitInt8(DW_EH_PE_pcrel | DW_EH_PE_sdata4);
+      Asm->EOL("Personality (pcrel sdata4)");
       
       O << TAI->getData32bitsDirective();
       Asm->EmitExternalGlobal((const GlobalVariable *)(Personality));
@@ -2830,7 +2842,7 @@ private:
       EmitLabel("eh_frame_begin", SubprogramCount);
 
       EmitSectionOffset("eh_frame_begin", "section_eh_frame",
-                        SubprogramCount, 0, true);
+                        SubprogramCount, 0, true, true);
       Asm->EOL("FDE CIE offset");
 
       EmitReference("eh_func_begin", SubprogramCount, true);
@@ -2994,7 +3006,7 @@ private:
     for (unsigned i = 0, N = LandingPads.size(); i != N; ++i) {
       const LandingPadInfo &LandingPad = LandingPads[i];
       EmitSectionOffset("label", "eh_func_begin",
-                        LandingPad.BeginLabel, SubprogramCount);
+                        LandingPad.BeginLabel, SubprogramCount, false, true);
       Asm->EOL("Region start");
       
       EmitDifference("label", LandingPad.EndLabel,
@@ -3007,8 +3019,8 @@ private:
         else
           Asm->EmitInt64(0);
       } else {
-        EmitSectionOffset("label", "eh_func_begin",
-                          LandingPad.LandingPadLabel, SubprogramCount);
+        EmitSectionOffset("label", "eh_func_begin", LandingPad.LandingPadLabel,
+                          SubprogramCount, false, true);
       }
       Asm->EOL("Landing pad");
 
index 37ab073ffcddb2d93defe5cb819998fa7feba673..b7e34407669fe00345d94057472d3f626c9a66ff 100644 (file)
@@ -75,7 +75,8 @@ TargetAsmInfo::TargetAsmInfo() :
   WeakRefDirective(0),
   HiddenDirective("\t.hidden\t"),
   ProtectedDirective("\t.protected\t"),
-  AbsoluteSectionOffsets(false),
+  AbsoluteDebugSectionOffsets(false),
+  AbsoluteEHSectionOffsets(false),
   HasLEB128(false),
   HasDotLoc(false),
   HasDotFile(false),
index 6a27072e98726b495e6c9297bf8abcd71536a80a..85ac7a4421eb96e3652d985d9470cd6c53af2d37 100644 (file)
@@ -99,7 +99,8 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
   case X86Subtarget::isELF:
     // Set up DWARF directives
     HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
-    AbsoluteSectionOffsets = true;
+    AbsoluteDebugSectionOffsets = true;
+    AbsoluteEHSectionOffsets = false;
     // bool HasLEB128; // Defaults to false.
     // hasDotLoc - True if target asm supports .loc directives.
     // bool HasDotLoc; // Defaults to false.
@@ -141,7 +142,8 @@ X86TargetAsmInfo::X86TargetAsmInfo(const X86TargetMachine &TM) {
 
     // Set up DWARF directives
     HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
-    AbsoluteSectionOffsets = true;
+    AbsoluteDebugSectionOffsets = true;
+    AbsoluteEHSectionOffsets = false;
     PrivateGlobalPrefix = "L";  // Prefix for private global symbols
     WeakRefDirective = "\t.weak\t";
     SetDirective = "\t.set\t";