* dwarf2asm.c (size_of_encoded_value): New function.
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 May 2001 04:30:09 +0000 (04:30 +0000)
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>
Sun, 13 May 2001 04:30:09 +0000 (04:30 +0000)
        * dwarf2asm.h: Declare it.
        * except.c (output_function_exception_table): Align the TType
        array only as wide as the encoding.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@42028 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/dwarf2asm.c
gcc/dwarf2asm.h
gcc/except.c

index 3f91ca1..1ddf31a 100644 (file)
@@ -1,3 +1,10 @@
+2001-06-12  Richard Henderson  <rth@redhat.com>
+
+       * dwarf2asm.c (size_of_encoded_value): New function.
+       * dwarf2asm.h: Declare it.
+       * except.c (output_function_exception_table): Align the TType
+       array only as wide as the encoding.
+
 2001-05-12  Zack Weinberg  <zackw@stanford.edu>
 
        * extend.texi: Document #pragma GCC java_exceptions.
index 104879e..a18607a 100644 (file)
@@ -445,6 +445,31 @@ size_of_sleb128 (value)
   return size;
 }
 
+/* Given an encoding, return the number of bytes the format occupies.
+   This is only defined for fixed-size encodings, and so does not 
+   include leb128.  */
+
+int
+size_of_encoded_value (encoding)
+     int encoding;
+{
+  if (encoding == DW_EH_PE_omit)
+    return 0;
+
+  switch (encoding & 0x07)
+    {
+    case DW_EH_PE_absptr:
+      return POINTER_SIZE / BITS_PER_UNIT;
+    case DW_EH_PE_udata2:
+      return 2;
+    case DW_EH_PE_udata4:
+      return 4;
+    case DW_EH_PE_udata8:
+      return 8;
+    }
+  abort ();
+}
+
 /* Output an unsigned LEB128 quantity.  */
 
 void
index 4b663c9..7f3baed 100644 (file)
@@ -72,5 +72,6 @@ extern void dw2_asm_output_delta_sleb128 PARAMS ((const char *, const char *,
 
 extern int size_of_uleb128             PARAMS ((unsigned HOST_WIDE_INT));
 extern int size_of_sleb128             PARAMS ((HOST_WIDE_INT));
+extern int size_of_encoded_value       PARAMS ((int));
 
 extern void dw2_output_indirect_constants PARAMS ((void));
index 66ea787..3afb1ed 100644 (file)
@@ -3612,6 +3612,7 @@ output_function_exception_table ()
 #endif
   int have_tt_data;
   int funcdef_number;
+  int tt_format_size;
 
   /* Not all functions need anything.  */
   if (! cfun->uses_eh_lsda)
@@ -3634,8 +3635,19 @@ output_function_exception_table ()
   have_tt_data = (VARRAY_ACTIVE_SIZE (cfun->eh->ttype_data) > 0
                  || VARRAY_ACTIVE_SIZE (cfun->eh->ehspec_data) > 0);
 
-  if (have_tt_data)
-    assemble_eh_align (GET_MODE_ALIGNMENT (ptr_mode));
+  /* Indicate the format of the @TType entries.  */
+  if (! have_tt_data)
+    tt_format = DW_EH_PE_omit;
+  else
+    {
+      tt_format = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/1);
+#ifdef HAVE_AS_LEB128
+      ASM_GENERATE_INTERNAL_LABEL (ttype_label, "LLSDATT", funcdef_number);
+#endif
+      tt_format_size = size_of_encoded_value (tt_format);
+
+      assemble_eh_align (tt_format_size * BITS_PER_UNIT);
+    }
 
   ASM_OUTPUT_INTERNAL_LABEL (asm_out_file, "LLSDA", funcdef_number);
 
@@ -3653,16 +3665,6 @@ output_function_exception_table ()
 
   /* @LPStart pointer would go here.  */
 
-  /* Indicate the format of the @TType entries.  */
-  if (! have_tt_data)
-    tt_format = DW_EH_PE_omit;
-  else
-    {
-      tt_format = ASM_PREFERRED_EH_DATA_FORMAT (/*code=*/0, /*global=*/1);
-#ifdef HAVE_AS_LEB128
-      ASM_GENERATE_INTERNAL_LABEL (ttype_label, "LLSDATT", funcdef_number);
-#endif
-    }
   dw2_asm_output_data (1, tt_format, "@TType format (%s)",
                       eh_data_format_name (tt_format));
 
@@ -3685,14 +3687,14 @@ output_function_exception_table ()
       ASM_OUTPUT_LABEL (asm_out_file, ttype_after_disp_label);
 #else
       /* Ug.  Alignment queers things.  */
-      unsigned int before_disp, after_disp, last_disp, disp, align;
+      unsigned int before_disp, after_disp, last_disp, disp;
 
-      align = POINTER_SIZE / BITS_PER_UNIT;
       before_disp = 1 + 1;
       after_disp = (1 + size_of_uleb128 (call_site_len)
                    + call_site_len
                    + VARRAY_ACTIVE_SIZE (cfun->eh->action_record_data)
-                   + VARRAY_ACTIVE_SIZE (cfun->eh->ttype_data) * align);
+                   + (VARRAY_ACTIVE_SIZE (cfun->eh->ttype_data)
+                      * tt_format_size));
 
       disp = after_disp;
       do
@@ -3702,8 +3704,8 @@ output_function_exception_table ()
          last_disp = disp;
          disp_size = size_of_uleb128 (disp);
          pad = before_disp + disp_size + after_disp;
-         if (pad % align)
-           pad = align - (pad % align);
+         if (pad % tt_format_size)
+           pad = tt_format_size - (pad % tt_format_size);
          else
            pad = 0;
          disp = after_disp + pad;
@@ -3751,7 +3753,7 @@ output_function_exception_table ()
                         (i ? NULL : "Action record table"));
 
   if (have_tt_data)
-    assemble_eh_align (GET_MODE_ALIGNMENT (ptr_mode));
+    assemble_eh_align (tt_format_size * BITS_PER_UNIT);
 
   i = VARRAY_ACTIVE_SIZE (cfun->eh->ttype_data);
   while (i-- > 0)