* subsegs.h (struct frchain): Add frch_cfi_data field.

* dw2gencfi.c: Include subsegs.h.
	(cur_fde_data, last_address, cur_cfa_offset, cfa_save_stack): Removed.
	(struct frch_cfi_data): New type.
	(unused_cfi_data): New variable.
	(alloc_fde_entry): Move cur_fde_data, last_address, cur_cfa_offset
	and cfa_save_stack static vars into a structure pointed from
	each frchain.
	(alloc_cfi_insn_data, cfi_new_fde, cfi_end_fde, cfi_set_return_column,
	cfi_add_advance_loc, cfi_add_CFA_def_cfa, cfi_add_CFA_def_cfa_offset,
	cfi_add_CFA_remember_state, cfi_add_CFA_restore_state, dot_cfi,
	dot_cfi_escape, dot_cfi_startproc, dot_cfi_endproc, cfi_finish):
	Likewise.

	* gas/cfi/cfi-common-5.d: New test.
	* gas/cfi/cfi-common-5.s: New.
	* gas/cfi/cfi.exp: Add cfi-common-5 test.
This commit is contained in:
Jakub Jelinek 2006-11-03 07:27:39 +00:00
parent b1e24c0220
commit ae424f8246
7 changed files with 123 additions and 39 deletions

View File

@ -1,3 +1,19 @@
2006-11-03 Jakub Jelinek <jakub@redhat.com>
* subsegs.h (struct frchain): Add frch_cfi_data field.
* dw2gencfi.c: Include subsegs.h.
(cur_fde_data, last_address, cur_cfa_offset, cfa_save_stack): Removed.
(struct frch_cfi_data): New type.
(unused_cfi_data): New variable.
(alloc_fde_entry): Move cur_fde_data, last_address, cur_cfa_offset
and cfa_save_stack static vars into a structure pointed from
each frchain.
(alloc_cfi_insn_data, cfi_new_fde, cfi_end_fde, cfi_set_return_column,
cfi_add_advance_loc, cfi_add_CFA_def_cfa, cfi_add_CFA_def_cfa_offset,
cfi_add_CFA_remember_state, cfi_add_CFA_restore_state, dot_cfi,
dot_cfi_escape, dot_cfi_startproc, dot_cfi_endproc, cfi_finish):
Likewise.
2006-11-02 Daniel Jacobowitz <dan@codesourcery.com>
* config/tc-h8300.c (build_bytes): Fix const warning.

View File

@ -21,6 +21,7 @@
#include "as.h"
#include "dw2gencfi.h"
#include "subsegs.h"
/* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field
@ -101,11 +102,6 @@ struct cie_entry
};
/* Current open FDE entry. */
static struct fde_entry *cur_fde_data;
static symbolS *last_address;
static offsetT cur_cfa_offset;
/* List of FDE entries. */
static struct fde_entry *all_fde_data;
static struct fde_entry **last_fde_data = &all_fde_data;
@ -120,7 +116,14 @@ struct cfa_save_data
offsetT cfa_offset;
};
static struct cfa_save_data *cfa_save_stack;
/* Current open FDE entry. */
struct frch_cfi_data
{
struct fde_entry *cur_fde_data;
symbolS *last_address;
offsetT cur_cfa_offset;
struct cfa_save_data *cfa_save_stack;
};
/* Construct a new FDE structure and add it to the end of the fde list. */
@ -129,7 +132,8 @@ alloc_fde_entry (void)
{
struct fde_entry *fde = xcalloc (1, sizeof (struct fde_entry));
cur_fde_data = fde;
frchain_now->frch_cfi_data = xcalloc (1, sizeof (struct frch_cfi_data));
frchain_now->frch_cfi_data->cur_fde_data = fde;
*last_fde_data = fde;
last_fde_data = &fde->next;
@ -149,6 +153,7 @@ static struct cfi_insn_data *
alloc_cfi_insn_data (void)
{
struct cfi_insn_data *insn = xcalloc (1, sizeof (struct cfi_insn_data));
struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data;
*cur_fde_data->last = insn;
cur_fde_data->last = &insn->next;
@ -163,7 +168,7 @@ cfi_new_fde (symbolS *label)
{
struct fde_entry *fde = alloc_fde_entry ();
fde->start_address = label;
last_address = label;
frchain_now->frch_cfi_data->last_address = label;
}
/* End the currently open FDE. */
@ -171,8 +176,9 @@ cfi_new_fde (symbolS *label)
void
cfi_end_fde (symbolS *label)
{
cur_fde_data->end_address = label;
cur_fde_data = NULL;
frchain_now->frch_cfi_data->cur_fde_data->end_address = label;
free (frchain_now->frch_cfi_data);
frchain_now->frch_cfi_data = NULL;
}
/* Set the return column for the current FDE. */
@ -180,7 +186,7 @@ cfi_end_fde (symbolS *label)
void
cfi_set_return_column (unsigned regno)
{
cur_fde_data->return_column = regno;
frchain_now->frch_cfi_data->cur_fde_data->return_column = regno;
}
/* Universal functions to store new instructions. */
@ -239,10 +245,10 @@ cfi_add_advance_loc (symbolS *label)
struct cfi_insn_data *insn = alloc_cfi_insn_data ();
insn->insn = DW_CFA_advance_loc;
insn->u.ll.lab1 = last_address;
insn->u.ll.lab1 = frchain_now->frch_cfi_data->last_address;
insn->u.ll.lab2 = label;
last_address = label;
frchain_now->frch_cfi_data->last_address = label;
}
/* Add a DW_CFA_offset record to the CFI data. */
@ -267,7 +273,7 @@ void
cfi_add_CFA_def_cfa (unsigned regno, offsetT offset)
{
cfi_add_CFA_insn_reg_offset (DW_CFA_def_cfa, regno, offset);
cur_cfa_offset = offset;
frchain_now->frch_cfi_data->cur_cfa_offset = offset;
}
/* Add a DW_CFA_register record to the CFI data. */
@ -292,7 +298,7 @@ void
cfi_add_CFA_def_cfa_offset (offsetT offset)
{
cfi_add_CFA_insn_offset (DW_CFA_def_cfa_offset, offset);
cur_cfa_offset = offset;
frchain_now->frch_cfi_data->cur_cfa_offset = offset;
}
void
@ -321,9 +327,9 @@ cfi_add_CFA_remember_state (void)
cfi_add_CFA_insn (DW_CFA_remember_state);
p = xmalloc (sizeof (*p));
p->cfa_offset = cur_cfa_offset;
p->next = cfa_save_stack;
cfa_save_stack = p;
p->cfa_offset = frchain_now->frch_cfi_data->cur_cfa_offset;
p->next = frchain_now->frch_cfi_data->cfa_save_stack;
frchain_now->frch_cfi_data->cfa_save_stack = p;
}
void
@ -333,11 +339,11 @@ cfi_add_CFA_restore_state (void)
cfi_add_CFA_insn (DW_CFA_restore_state);
p = cfa_save_stack;
p = frchain_now->frch_cfi_data->cfa_save_stack;
if (p)
{
cur_cfa_offset = p->cfa_offset;
cfa_save_stack = p->next;
frchain_now->frch_cfi_data->cur_cfa_offset = p->cfa_offset;
frchain_now->frch_cfi_data->cfa_save_stack = p->next;
free (p);
}
else
@ -449,7 +455,7 @@ dot_cfi (int arg)
offsetT offset;
unsigned reg1, reg2;
if (!cur_fde_data)
if (frchain_now->frch_cfi_data == NULL)
{
as_bad (_("CFI instruction used without previous .cfi_startproc"));
ignore_rest_of_line ();
@ -457,8 +463,9 @@ dot_cfi (int arg)
}
/* If the last address was not at the current PC, advance to current. */
if (symbol_get_frag (last_address) != frag_now
|| S_GET_VALUE (last_address) != frag_now_fix ())
if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now
|| S_GET_VALUE (frchain_now->frch_cfi_data->last_address)
!= frag_now_fix ())
cfi_add_advance_loc (symbol_temp_new_now ());
switch (arg)
@ -474,7 +481,8 @@ dot_cfi (int arg)
reg1 = cfi_parse_reg ();
cfi_parse_separator ();
offset = cfi_parse_const ();
cfi_add_CFA_offset (reg1, offset - cur_cfa_offset);
cfi_add_CFA_offset (reg1,
offset - frchain_now->frch_cfi_data->cur_cfa_offset);
break;
case DW_CFA_def_cfa:
@ -503,7 +511,8 @@ dot_cfi (int arg)
case CFI_adjust_cfa_offset:
offset = cfi_parse_const ();
cfi_add_CFA_def_cfa_offset (cur_cfa_offset + offset);
cfi_add_CFA_def_cfa_offset (frchain_now->frch_cfi_data->cur_cfa_offset
+ offset);
break;
case DW_CFA_restore:
@ -553,7 +562,7 @@ dot_cfi (int arg)
break;
case CFI_signal_frame:
cur_fde_data->signal_frame = 1;
frchain_now->frch_cfi_data->cur_fde_data->signal_frame = 1;
break;
default:
@ -569,7 +578,7 @@ dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
struct cfi_escape_data *head, **tail, *e;
struct cfi_insn_data *insn;
if (!cur_fde_data)
if (frchain_now->frch_cfi_data == NULL)
{
as_bad (_("CFI instruction used without previous .cfi_startproc"));
ignore_rest_of_line ();
@ -577,8 +586,9 @@ dot_cfi_escape (int ignored ATTRIBUTE_UNUSED)
}
/* If the last address was not at the current PC, advance to current. */
if (symbol_get_frag (last_address) != frag_now
|| S_GET_VALUE (last_address) != frag_now_fix ())
if (symbol_get_frag (frchain_now->frch_cfi_data->last_address) != frag_now
|| S_GET_VALUE (frchain_now->frch_cfi_data->last_address)
!= frag_now_fix ())
cfi_add_advance_loc (symbol_temp_new_now ());
tail = &head;
@ -605,7 +615,7 @@ dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
{
int simple = 0;
if (cur_fde_data)
if (frchain_now->frch_cfi_data != NULL)
{
as_bad (_("previous CFI entry not closed (missing .cfi_endproc)"));
ignore_rest_of_line ();
@ -632,7 +642,7 @@ dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
}
demand_empty_rest_of_line ();
cur_cfa_offset = 0;
frchain_now->frch_cfi_data->cur_cfa_offset = 0;
if (!simple)
tc_cfi_frame_initial_instructions ();
}
@ -640,7 +650,7 @@ dot_cfi_startproc (int ignored ATTRIBUTE_UNUSED)
static void
dot_cfi_endproc (int ignored ATTRIBUTE_UNUSED)
{
if (! cur_fde_data)
if (frchain_now->frch_cfi_data == NULL)
{
as_bad (_(".cfi_endproc without corresponding .cfi_startproc"));
ignore_rest_of_line ();
@ -1053,12 +1063,6 @@ cfi_finish (void)
struct fde_entry *fde;
int save_flag_traditional_format;
if (cur_fde_data)
{
as_bad (_("open CFI at the end of file; missing .cfi_endproc directive"));
cur_fde_data->end_address = cur_fde_data->start_address;
}
if (all_fde_data == 0)
return;
@ -1078,6 +1082,12 @@ cfi_finish (void)
struct cfi_insn_data *first;
struct cie_entry *cie;
if (fde->end_address == NULL)
{
as_bad (_("open CFI at the end of file; missing .cfi_endproc directive"));
fde->end_address = fde->start_address;
}
cie = select_cie_for_fde (fde, &first);
output_fde (fde, cie, first, fde->next == NULL ? EH_FRAME_ALIGNMENT : 2);
}

View File

@ -40,6 +40,8 @@
#include "obstack.h"
struct frch_cfi_data;
struct frchain /* control building of a frag chain */
{ /* FRCH = FRagment CHain control */
struct frag *frch_root; /* 1st struct frag in chain, or NULL */
@ -50,6 +52,7 @@ struct frchain /* control building of a frag chain */
fixS *fix_tail; /* Last fixup for this subsegment. */
struct obstack frch_obstack; /* for objects in this frag chain */
fragS *frch_frag_now; /* frag_now for this subsegment */
struct frch_cfi_data *frch_cfi_data;
};
typedef struct frchain frchainS;

View File

@ -1,3 +1,9 @@
2006-11-03 Jakub Jelinek <jakub@redhat.com>
* gas/cfi/cfi-common-5.d: New test.
* gas/cfi/cfi-common-5.s: New.
* gas/cfi/cfi.exp: Add cfi-common-5 test.
2006-11-01 Thiemo Seufer <ths@mips.com>
* gas/mips/mips16-intermix.d, gas/mips/mips16-intermix.s: New

View File

@ -0,0 +1,24 @@
#readelf: -wf
#name: CFI common 5
The section .eh_frame contains:
00000000 00000010 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: .*
Data alignment factor: .*
Return address column: .*
Augmentation data: [01]b
#...
00000014 00000014 00000018 FDE cie=00000000 pc=.*
DW_CFA_advance_loc: 4 to .*
DW_CFA_remember_state
DW_CFA_advance_loc: 4 to .*
DW_CFA_restore_state
#...
0000002c 0000001[48] 00000030 FDE cie=00000000 pc=.*
DW_CFA_advance_loc: 4 to .*
DW_CFA_def_cfa: r0 ofs 16
DW_CFA_advance_loc: 4 to .*
DW_CFA_def_cfa_offset: 0
#pass

View File

@ -0,0 +1,24 @@
.text
.cfi_startproc simple
.subsection 3
.cfi_startproc simple
.long 0
.cfi_def_cfa 0, 16
.previous
.long 0
.cfi_remember_state
.subsection 3
.long 0
.cfi_adjust_cfa_offset -16
.previous
.long 0
.cfi_restore_state
.cfi_endproc
.subsection 3
.cfi_endproc
.previous

View File

@ -72,3 +72,4 @@ run_dump_test "cfi-common-1"
run_dump_test "cfi-common-2"
run_dump_test "cfi-common-3"
run_dump_test "cfi-common-4"
run_dump_test "cfi-common-5"