/* dw2gencfi.c - Support for generating Dwarf2 CFI information.
- Copyright 2003, 2004 Free Software Foundation, Inc.
+ Copyright 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Michal Ludvig <mludvig@suse.cz>
This file is part of GAS, the GNU Assembler.
You should have received a copy of the GNU General Public License
along with GAS; see the file COPYING. If not, write to the Free
- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
- 02111-1307, USA. */
+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
+ 02110-1301, USA. */
#include "as.h"
#include "dw2gencfi.h"
#endif
#ifndef EH_FRAME_ALIGNMENT
-# ifdef BFD_ASSEMBLER
-# define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
-# else
-# define EH_FRAME_ALIGNMENT 2
-# endif
+# define EH_FRAME_ALIGNMENT (bfd_get_arch_size (stdoutput) == 64 ? 3 : 2)
#endif
#ifndef tc_cfi_frame_initial_instructions
struct cfi_insn_data *data;
struct cfi_insn_data **last;
unsigned int return_column;
+ unsigned int signal_frame;
};
struct cie_entry
struct cie_entry *next;
symbolS *start_address;
unsigned int return_column;
+ unsigned int signal_frame;
struct cfi_insn_data *first, *last;
};
#define CFI_return_column 0x101
#define CFI_rel_offset 0x102
#define CFI_escape 0x103
+#define CFI_signal_frame 0x104
const pseudo_typeS cfi_pseudo_table[] =
{
{ "cfi_restore_state", dot_cfi, DW_CFA_restore_state },
{ "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save },
{ "cfi_escape", dot_cfi_escape, 0 },
+ { "cfi_signal_frame", dot_cfi, CFI_signal_frame },
{ NULL, NULL, 0 }
};
}
#endif
- expression (&exp);
+ expression_and_evaluate (&exp);
switch (exp.X_op)
{
case O_register:
if (!cur_fde_data)
{
as_bad (_("CFI instruction used without previous .cfi_startproc"));
+ ignore_rest_of_line ();
return;
}
break;
case DW_CFA_restore:
- reg1 = cfi_parse_reg ();
- cfi_add_CFA_restore (reg1);
+ for (;;)
+ {
+ reg1 = cfi_parse_reg ();
+ cfi_add_CFA_restore (reg1);
+ SKIP_WHITESPACE ();
+ if (*input_line_pointer != ',')
+ break;
+ ++input_line_pointer;
+ }
break;
case DW_CFA_undefined:
- reg1 = cfi_parse_reg ();
- cfi_add_CFA_undefined (reg1);
+ for (;;)
+ {
+ reg1 = cfi_parse_reg ();
+ cfi_add_CFA_undefined (reg1);
+ SKIP_WHITESPACE ();
+ if (*input_line_pointer != ',')
+ break;
+ ++input_line_pointer;
+ }
break;
case DW_CFA_same_value:
cfi_add_CFA_insn (DW_CFA_GNU_window_save);
break;
+ case CFI_signal_frame:
+ cur_fde_data->signal_frame = 1;
+ break;
+
default:
abort ();
}
if (!cur_fde_data)
{
as_bad (_("CFI instruction used without previous .cfi_startproc"));
+ ignore_rest_of_line ();
return;
}
insn = alloc_cfi_insn_data ();
insn->insn = CFI_escape;
insn->u.esc = head;
+
+ --input_line_pointer;
+ demand_empty_rest_of_line ();
}
static void
if (cur_fde_data)
{
as_bad (_("previous CFI entry not closed (missing .cfi_endproc)"));
+ ignore_rest_of_line ();
return;
}
}
demand_empty_rest_of_line ();
+ cur_cfa_offset = 0;
if (!simple)
tc_cfi_frame_initial_instructions ();
}
if (! cur_fde_data)
{
as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
+ ignore_rest_of_line ();
return;
}
cfi_end_fde (symbol_temp_new_now ());
+
+ demand_empty_rest_of_line ();
}
\f
out_one (DW_CIE_VERSION); /* Version. */
out_one ('z'); /* Augmentation. */
out_one ('R');
+ if (cie->signal_frame)
+ out_one ('S');
out_one (0);
out_uleb128 (DWARF2_LINE_MIN_INSN_LENGTH); /* Code alignment. */
out_sleb128 (DWARF2_CIE_DATA_ALIGNMENT); /* Data alignment. */
for (i = cie->first; i != cie->last; i = i->next)
output_cfi_insn (i);
- frag_align (2, 0, 0);
+ frag_align (2, DW_CFA_nop, 0);
symbol_set_value_now (end_address);
}
for (; first; first = first->next)
output_cfi_insn (first);
- frag_align (align, 0, 0);
+ frag_align (align, DW_CFA_nop, 0);
symbol_set_value_now (end_address);
}
for (cie = cie_root; cie; cie = cie->next)
{
- if (cie->return_column != fde->return_column)
+ if (cie->return_column != fde->return_column
+ || cie->signal_frame != fde->signal_frame)
continue;
for (i = cie->first, j = fde->data;
i != cie->last && j != NULL;
cie->next = cie_root;
cie_root = cie;
cie->return_column = fde->return_column;
+ cie->signal_frame = fde->signal_frame;
cie->first = fde->data;
for (i = cie->first; i ; i = i->next)
/* Open .eh_frame section. */
cfi_seg = subseg_new (".eh_frame", 0);
-#ifdef BFD_ASSEMBLER
bfd_set_section_flags (stdoutput, cfi_seg,
SEC_ALLOC | SEC_LOAD | SEC_DATA | SEC_READONLY);
-#endif
subseg_set (cfi_seg, 0);
record_alignment (cfi_seg, EH_FRAME_ALIGNMENT);