2003-05-20 15:58:07 +08:00
|
|
|
/* dw2gencfi.h - Support for generating Dwarf2 CFI information.
|
2009-09-02 15:25:43 +08:00
|
|
|
Copyright 2003, 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
|
2003-05-20 15:58:07 +08:00
|
|
|
Contributed by Michal Ludvig <mludvig@suse.cz>
|
|
|
|
|
|
|
|
This file is part of GAS, the GNU Assembler.
|
|
|
|
|
|
|
|
GAS is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-07-03 19:01:12 +08:00
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
2003-05-20 15:58:07 +08:00
|
|
|
any later version.
|
|
|
|
|
|
|
|
GAS is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
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
|
2005-05-05 17:13:19 +08:00
|
|
|
Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
|
|
|
|
02110-1301, USA. */
|
2003-05-20 15:58:07 +08:00
|
|
|
|
|
|
|
#ifndef DW2GENCFI_H
|
|
|
|
#define DW2GENCFI_H
|
|
|
|
|
2009-07-10 23:27:04 +08:00
|
|
|
#include "dwarf2.h"
|
2003-05-20 15:58:07 +08:00
|
|
|
|
2003-05-28 00:52:49 +08:00
|
|
|
struct symbol;
|
2003-05-20 15:58:07 +08:00
|
|
|
|
|
|
|
extern const pseudo_typeS cfi_pseudo_table[];
|
|
|
|
|
|
|
|
/* cfi_finish() is called at the end of file. It will complain if
|
|
|
|
the last CFI wasn't properly closed by .cfi_endproc. */
|
2003-05-28 00:52:49 +08:00
|
|
|
extern void cfi_finish (void);
|
|
|
|
|
|
|
|
/* Entry points for backends to add unwind information. */
|
|
|
|
extern void cfi_new_fde (struct symbol *);
|
|
|
|
extern void cfi_end_fde (struct symbol *);
|
|
|
|
extern void cfi_set_return_column (unsigned);
|
|
|
|
extern void cfi_add_advance_loc (struct symbol *);
|
2003-06-05 Michal Ludvig <mludvig@suse.cz>
* dw2gencfi.c (cfi_add_CFA_insn, cfi_add_CFA_insn_reg)
(cfi_add_CFA_insn_reg_reg, cfi_add_CFA_insn_reg_offset): New.
(cfi_add_CFA_offset, cfi_add_CFA_def_cfa)
(cfi_add_CFA_register, cfi_add_CFA_def_cfa_register)
(cfi_add_CFA_def_cfa_offset): Use cfi_add_CFA_insn_*().
(cfi_add_CFA_restore, cfi_add_CFA_undefined)
(cfi_add_CFA_same_value, cfi_add_CFA_remember_state)
(cfi_add_CFA_restore_state, cfi_add_CFA_nop): New.
(cfi_pseudo_table): New directives .cfi_return_column,
.cfi_restore, .cfi_undefined, .cfi_same_value,
.cfi_remember_state, .cfi_restore_state, .cfi_nop.
(dot_cfi, output_cfi_insn): Handle new directives.
* dw2gencfi.h (cfi_add_CFA_restore, cfi_add_CFA_undefined)
(cfi_add_CFA_same_value, cfi_add_CFA_remember_state)
(cfi_add_CFA_restore_state, cfi_add_CFA_nop): New prototypes.
2003-06-05 17:23:47 +08:00
|
|
|
|
2003-05-28 00:52:49 +08:00
|
|
|
extern void cfi_add_CFA_offset (unsigned, offsetT);
|
|
|
|
extern void cfi_add_CFA_def_cfa (unsigned, offsetT);
|
|
|
|
extern void cfi_add_CFA_register (unsigned, unsigned);
|
|
|
|
extern void cfi_add_CFA_def_cfa_register (unsigned);
|
|
|
|
extern void cfi_add_CFA_def_cfa_offset (offsetT);
|
2003-06-05 Michal Ludvig <mludvig@suse.cz>
* dw2gencfi.c (cfi_add_CFA_insn, cfi_add_CFA_insn_reg)
(cfi_add_CFA_insn_reg_reg, cfi_add_CFA_insn_reg_offset): New.
(cfi_add_CFA_offset, cfi_add_CFA_def_cfa)
(cfi_add_CFA_register, cfi_add_CFA_def_cfa_register)
(cfi_add_CFA_def_cfa_offset): Use cfi_add_CFA_insn_*().
(cfi_add_CFA_restore, cfi_add_CFA_undefined)
(cfi_add_CFA_same_value, cfi_add_CFA_remember_state)
(cfi_add_CFA_restore_state, cfi_add_CFA_nop): New.
(cfi_pseudo_table): New directives .cfi_return_column,
.cfi_restore, .cfi_undefined, .cfi_same_value,
.cfi_remember_state, .cfi_restore_state, .cfi_nop.
(dot_cfi, output_cfi_insn): Handle new directives.
* dw2gencfi.h (cfi_add_CFA_restore, cfi_add_CFA_undefined)
(cfi_add_CFA_same_value, cfi_add_CFA_remember_state)
(cfi_add_CFA_restore_state, cfi_add_CFA_nop): New prototypes.
2003-06-05 17:23:47 +08:00
|
|
|
extern void cfi_add_CFA_restore (unsigned);
|
|
|
|
extern void cfi_add_CFA_undefined (unsigned);
|
|
|
|
extern void cfi_add_CFA_same_value (unsigned);
|
|
|
|
extern void cfi_add_CFA_remember_state (void);
|
|
|
|
extern void cfi_add_CFA_restore_state (void);
|
2003-05-20 15:58:07 +08:00
|
|
|
|
2011-05-09 Paul Brook <paul@codesourcery.com>
bfd/
* elf32-tic6x.c (is_tic6x_elf_unwind_section_name,
elf32_tic6x_fake_sections): New functions.
(elf_backend_fake_sections): Define.
gas/
* config/tc-tic6x.c (streq): Define.
(tic6x_get_unwind): New.
(s_tic6x_cantunwind, s_tic6x_handlerdata, s_tic6x_endp,
s_tic6x_personalityindex, s_tic6x_personality): New functions.
(md_pseudo_table): Add "endp", "handlerdata", "personalityindex",
"personality" and "cantunwind".
(tic6x_regname_to_dw2regnum, tic6x_frame_initial_instructions,
tic6x_start_unwind_section, tic6x_unwind_frame_regs,
tic6x_pop_rts_offset_little, tic6x_pop_rts_offset_big,
tic6x_unwind_reg_from_dwarf, tic6x_flush_unwind_word,
tic6x_unwind_byte, tic6x_unwind_2byte, tic6x_unwind_uleb,
tic6x_cfi_startproc, output_exidx_entry, tic6x_output_unwinding,
tic6x_cfi_endproc): New.
* config/tc-tic6x.h (TIC6X_NUM_UNWIND_REGS): Define.
(tic6x_unwind_info): New.
(tic6x_segment_info_type): Add marked_pr_dependency, unwind and
text_unwind.
(TARGET_USE_CFIPOP, tc_regname_to_dw2regnum,
tc_cfi_frame_initial_instructions, DWARF2_DEFAULT_RETURN_COLUMN,
DWARF2_CIE_DATA_ALIGNMENT, tc_cfi_startproc, tc_cfi_endproc,
tc_cfi_section_name): Define.
* doc/c-tic6x.texi: Document new unwinding directives.
* dw2gencfi.c (tc_cfi_startproc, tc_cfi_endproc): Add default
definitions.
(cfi_insn_data, fde_entry, CFI_adjust_cfa_offset, CFI_return_column,
CFI_rel_offset, CFI_escape, CFI_signal_frame, CFI_val_encoded_addr):
Move to dw2gencfi.h.
(CFI_EMIT_target): Define.
(dot_cfi_sections): Check tc_cfi_section_name.
(dot_cfi_startproc): Use tc_cfi_startproc.
(dot_cfi_endproc): Use tc_cfi_endproc.
* dw2gencfi.h (cfi_insn_data, fde_entry, CFI_adjust_cfa_offset,
CFI_return_column, CFI_rel_offset, CFI_escape, CFI_signal_frame,
CFI_val_encoded_addr): Move to here from dw2gencfi.c.
gas/testsuite:
* gas/tic6x/unwind-1.d: New test.
* gas/tic6x/unwind-1.s: New test.
* gas/tic6x/unwind-2.d: New test.
* gas/tic6x/unwind-2.s: New test.
* gas/tic6x/unwind-3.d: New test.
* gas/tic6x/unwind-3.s: New test.
* gas/tic6x/unwind-bad-1.d: New test.
* gas/tic6x/unwind-bad-1.s: New test.
* gas/tic6x/unwind-bad-1.l: New test.
* gas/tic6x/unwind-bad-2.d: New test.
* gas/tic6x/unwind-bad-2.s: New test.
* gas/tic6x/unwind-bad-2.l: New test.
include/
* elf/tic6x.h (ELF_STRING_C6000_unwind,
ELF_STRING_C6000_unwind_info, ELF_STRING_C6000_unwind_once,
ELF_STRING_C6000_unwind_info_once): Define.
2011-05-09 21:17:58 +08:00
|
|
|
/* Structures for md_cfi_end. */
|
|
|
|
|
|
|
|
#if defined (TE_PE) || defined (TE_PEP)
|
|
|
|
#define SUPPORT_FRAME_LINKONCE 1
|
|
|
|
#else
|
|
|
|
#define SUPPORT_FRAME_LINKONCE 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct cfi_insn_data
|
|
|
|
{
|
|
|
|
struct cfi_insn_data *next;
|
|
|
|
#if SUPPORT_FRAME_LINKONCE
|
|
|
|
segT cur_seg;
|
|
|
|
#endif
|
|
|
|
int insn;
|
|
|
|
union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned reg;
|
|
|
|
offsetT offset;
|
|
|
|
} ri;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned reg1;
|
|
|
|
unsigned reg2;
|
|
|
|
} rr;
|
|
|
|
|
|
|
|
unsigned r;
|
|
|
|
offsetT i;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
symbolS *lab1;
|
|
|
|
symbolS *lab2;
|
|
|
|
} ll;
|
|
|
|
|
|
|
|
struct cfi_escape_data *esc;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned reg, encoding;
|
|
|
|
expressionS exp;
|
|
|
|
} ea;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct fde_entry
|
|
|
|
{
|
|
|
|
struct fde_entry *next;
|
|
|
|
#if SUPPORT_FRAME_LINKONCE
|
|
|
|
segT cur_seg;
|
|
|
|
#endif
|
|
|
|
symbolS *start_address;
|
|
|
|
symbolS *end_address;
|
|
|
|
struct cfi_insn_data *data;
|
|
|
|
struct cfi_insn_data **last;
|
|
|
|
unsigned char per_encoding;
|
|
|
|
unsigned char lsda_encoding;
|
|
|
|
expressionS personality;
|
|
|
|
expressionS lsda;
|
|
|
|
unsigned int return_column;
|
|
|
|
unsigned int signal_frame;
|
|
|
|
#if SUPPORT_FRAME_LINKONCE
|
|
|
|
int handled;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2011-08-08 00:32:20 +08:00
|
|
|
/* The list of all FDEs that have been collected. */
|
|
|
|
extern struct fde_entry *all_fde_data;
|
|
|
|
|
2011-05-09 Paul Brook <paul@codesourcery.com>
bfd/
* elf32-tic6x.c (is_tic6x_elf_unwind_section_name,
elf32_tic6x_fake_sections): New functions.
(elf_backend_fake_sections): Define.
gas/
* config/tc-tic6x.c (streq): Define.
(tic6x_get_unwind): New.
(s_tic6x_cantunwind, s_tic6x_handlerdata, s_tic6x_endp,
s_tic6x_personalityindex, s_tic6x_personality): New functions.
(md_pseudo_table): Add "endp", "handlerdata", "personalityindex",
"personality" and "cantunwind".
(tic6x_regname_to_dw2regnum, tic6x_frame_initial_instructions,
tic6x_start_unwind_section, tic6x_unwind_frame_regs,
tic6x_pop_rts_offset_little, tic6x_pop_rts_offset_big,
tic6x_unwind_reg_from_dwarf, tic6x_flush_unwind_word,
tic6x_unwind_byte, tic6x_unwind_2byte, tic6x_unwind_uleb,
tic6x_cfi_startproc, output_exidx_entry, tic6x_output_unwinding,
tic6x_cfi_endproc): New.
* config/tc-tic6x.h (TIC6X_NUM_UNWIND_REGS): Define.
(tic6x_unwind_info): New.
(tic6x_segment_info_type): Add marked_pr_dependency, unwind and
text_unwind.
(TARGET_USE_CFIPOP, tc_regname_to_dw2regnum,
tc_cfi_frame_initial_instructions, DWARF2_DEFAULT_RETURN_COLUMN,
DWARF2_CIE_DATA_ALIGNMENT, tc_cfi_startproc, tc_cfi_endproc,
tc_cfi_section_name): Define.
* doc/c-tic6x.texi: Document new unwinding directives.
* dw2gencfi.c (tc_cfi_startproc, tc_cfi_endproc): Add default
definitions.
(cfi_insn_data, fde_entry, CFI_adjust_cfa_offset, CFI_return_column,
CFI_rel_offset, CFI_escape, CFI_signal_frame, CFI_val_encoded_addr):
Move to dw2gencfi.h.
(CFI_EMIT_target): Define.
(dot_cfi_sections): Check tc_cfi_section_name.
(dot_cfi_startproc): Use tc_cfi_startproc.
(dot_cfi_endproc): Use tc_cfi_endproc.
* dw2gencfi.h (cfi_insn_data, fde_entry, CFI_adjust_cfa_offset,
CFI_return_column, CFI_rel_offset, CFI_escape, CFI_signal_frame,
CFI_val_encoded_addr): Move to here from dw2gencfi.c.
gas/testsuite:
* gas/tic6x/unwind-1.d: New test.
* gas/tic6x/unwind-1.s: New test.
* gas/tic6x/unwind-2.d: New test.
* gas/tic6x/unwind-2.s: New test.
* gas/tic6x/unwind-3.d: New test.
* gas/tic6x/unwind-3.s: New test.
* gas/tic6x/unwind-bad-1.d: New test.
* gas/tic6x/unwind-bad-1.s: New test.
* gas/tic6x/unwind-bad-1.l: New test.
* gas/tic6x/unwind-bad-2.d: New test.
* gas/tic6x/unwind-bad-2.s: New test.
* gas/tic6x/unwind-bad-2.l: New test.
include/
* elf/tic6x.h (ELF_STRING_C6000_unwind,
ELF_STRING_C6000_unwind_info, ELF_STRING_C6000_unwind_once,
ELF_STRING_C6000_unwind_info_once): Define.
2011-05-09 21:17:58 +08:00
|
|
|
/* Fake CFI type; outside the byte range of any real CFI insn. */
|
|
|
|
#define CFI_adjust_cfa_offset 0x100
|
|
|
|
#define CFI_return_column 0x101
|
|
|
|
#define CFI_rel_offset 0x102
|
|
|
|
#define CFI_escape 0x103
|
|
|
|
#define CFI_signal_frame 0x104
|
|
|
|
#define CFI_val_encoded_addr 0x105
|
|
|
|
|
2003-05-20 15:58:07 +08:00
|
|
|
#endif /* DW2GENCFI_H */
|