@@ -4059,7 +4059,8 @@ alpha_elf_md_finish (void)
function symbol. This prevents problems with globals. */
cfi_new_fde (symbol_temp_new (S_GET_SEGMENT (p->func_sym),
symbol_get_frag (p->func_sym),
- S_GET_VALUE (p->func_sym)));
+ S_GET_VALUE (p->func_sym)),
+ false);
cfi_set_sections ();
cfi_set_return_column (p->ra_regno);
@@ -447,16 +447,25 @@ alloc_cfi_insn_data (void)
*cur_fde_data->last = insn;
cur_fde_data->last = &insn->next;
SET_CUR_SEG (insn, is_now_linkonce_segment ());
+#ifndef NO_LISTING
+ insn->listing_ctxt = cur_fde_data->listing_ctxt ? listing_tail : NULL;
+#endif
return insn;
}
/* Construct a new FDE structure that begins at LABEL. */
void
-cfi_new_fde (symbolS *label)
+cfi_new_fde (symbolS *label, bool do_listing)
{
struct fde_entry *fde = alloc_fde_entry ();
fde->start_address = label;
+ if (do_listing)
+ {
+#ifndef NO_LISTING
+ fde->listing_ctxt = listing_tail;
+#endif
+ }
frchain_now->frch_cfi_data->last_address = label;
}
@@ -465,7 +474,12 @@ cfi_new_fde (symbolS *label)
void
cfi_end_fde (symbolS *label)
{
- frchain_now->frch_cfi_data->cur_fde_data->end_address = label;
+ struct fde_entry *cur_fde_data = frchain_now->frch_cfi_data->cur_fde_data;
+
+ cur_fde_data->end_address = label;
+#ifndef NO_LISTING
+ cur_fde_data->listing_end = cur_fde_data->listing_ctxt ? listing_tail : NULL;
+#endif
frchain_now->frch_cfi_data = NULL;
}
@@ -1286,7 +1300,7 @@ dot_cfi_startproc (int ignored ATTRIBUTE
return;
}
- cfi_new_fde (symbol_temp_new_now ());
+ cfi_new_fde (symbol_temp_new_now (), listing & LISTING_LISTING);
SKIP_WHITESPACE ();
if (is_name_beginner (*input_line_pointer) || *input_line_pointer == '"')
@@ -2065,7 +2079,19 @@ output_fde (struct fde_entry *fde, struc
for (; first; first = first->next)
if (CUR_SEG (first) == CUR_SEG (fde))
- output_cfi_insn (first);
+ {
+#ifndef NO_LISTING
+ if (eh_frame)
+ listing_override_tail (first->listing_ctxt);
+#endif
+ output_cfi_insn (first);
+ }
+
+#ifndef NO_LISTING
+ /* Associate any padding with .cfi_endproc. */
+ if (eh_frame)
+ listing_override_tail (fde->listing_end);
+#endif
frag_align (align, DW_CFA_nop, 0);
symbol_set_value_now (end_address);
@@ -2312,6 +2338,12 @@ cfi_finish (void)
segT cfi_seg, ccseg;
struct fde_entry *fde;
struct cfi_insn_data *first;
+#ifndef NO_LISTING
+ /* We may temporarily replace listing_tail, which otherwise isn't supposed
+ to be changing anymore. Play safe and restore the original value
+ afterwards. */
+ struct list_info_struct *saved_listing_tail = NULL;
+#endif
int save_flag_traditional_format, seek_next_seg;
if (all_fde_data == 0)
@@ -2394,6 +2426,16 @@ cfi_finish (void)
fde->end_address = fde->start_address;
}
+#ifndef NO_LISTING
+ {
+ struct list_info_struct *listing_prev
+ = listing_override_tail (fde->listing_ctxt);
+
+ if (!saved_listing_tail)
+ saved_listing_tail = listing_prev;
+ }
+#endif
+
cie = select_cie_for_fde (fde, true, &first, 2);
fde->eh_loc = symbol_temp_new_now ();
output_fde (fde, cie, true, first,
@@ -2600,6 +2642,11 @@ cfi_finish (void)
htab_delete (dwcfi_hash);
dwcfi_hash = NULL;
}
+
+#ifndef NO_LISTING
+ if (saved_listing_tail)
+ listing_tail = saved_listing_tail;
+#endif
}
#else /* TARGET_USE_CFIPOP */
@@ -52,7 +52,7 @@ extern void dot_cfi_sections (int);
extern void cfi_finish (void);
/* Entry points for backends to add unwind information. */
-extern void cfi_new_fde (struct symbol *);
+extern void cfi_new_fde (struct symbol *, bool);
extern void cfi_end_fde (struct symbol *);
extern void cfi_set_last_fde (struct fde_entry *fde);
extern void cfi_set_return_column (unsigned);
@@ -99,6 +99,9 @@ struct cfi_insn_data
#if MULTIPLE_FRAME_SECTIONS
segT cur_seg;
#endif
+#ifndef NO_LISTING
+ struct list_info_struct *listing_ctxt;
+#endif
int insn;
union
{
@@ -186,6 +189,10 @@ struct fde_entry
symbolS *end_address;
struct cfi_insn_data *data;
struct cfi_insn_data **last;
+#ifndef NO_LISTING
+ struct list_info_struct *listing_ctxt;
+ struct list_info_struct *listing_end;
+#endif
unsigned char per_encoding;
unsigned char lsda_encoding;
int personality_id;
@@ -133,7 +133,7 @@ scfi_dot_cfi_startproc (const symbolS *s
return;
}
- cfi_new_fde ((symbolS *)start_sym);
+ cfi_new_fde ((symbolS *)start_sym, false);
cfi_set_sections ();
@@ -442,6 +442,51 @@ listing_newline (char *ps)
#endif
}
+/* Set listing context back to where it was when input was parsed, to allow
+ associating late code/data emission to segments with their origin. */
+
+struct list_info_struct *listing_override_tail (struct list_info_struct *info)
+{
+ struct list_info_struct *prev = listing_tail;
+ const fragS *frag;
+
+ if (!info)
+ return NULL;
+
+ listing_tail = info;
+
+ /* The first frag created by listing_newline() is still associated with the
+ earlier line. For the adjustment done below this property doesn't hold,
+ though. */
+ frag = info->frag;
+ if (frag->line != info)
+ frag = frag->fr_next;
+
+ /* Check whether there's any other output data already for this line. Replace
+ info->frag only if there's none. This is to cover for contributions to
+ multiple sections from a single line not being properly represented in the
+ listing, at the time of writing. Prefer the listing to show any "ordinary"
+ code/data contributions over any .eh_frame ones. (This way multiple .cfi_*
+ on a single line will also have all their contributions listed, rather
+ than just those from the last such directive.) */
+ for (; frag; frag = frag->fr_next)
+ if (frag->line != info
+ || (frag->fr_type != rs_dummy
+ && (frag->fr_type != rs_fill
+ || frag->fr_fix
+ || (frag->fr_var && frag->fr_offset))))
+ break;
+
+ if (!frag || frag->line != info)
+ {
+ new_frag ();
+ info->frag = frag_now;
+ new_frag ();
+ }
+
+ return prev;
+}
+
/* Attach all current frags to the previous line instead of the
current line. This is called by the MIPS backend when it discovers
that it needs to add some NOP instructions; the added NOP
@@ -47,6 +47,7 @@ void listing_error (const char *message)
void listing_file (const char *name);
void listing_list (int on);
void listing_newline (char *ps);
+struct list_info_struct *listing_override_tail (struct list_info_struct *);
void listing_prev_line (void);
void listing_print (char *, char **);
void listing_psize (int);
@@ -116,6 +116,11 @@ if { [istarget "i*86-*-*"] || [istarget
run_list_test "cfi-diag-1" ""
+# ARC and HPPA use ';' as comment char rather than as statement separator.
+if { ![istarget "arc*-*-*"] && ![istarget "hppa*-*"] } then {
+ run_list_test "listing" "-aln --listing-cont-lines=1"
+}
+
# HPPA64 uses 64-bit relocations, which results in all of the dump
# offset numbers not matching up.
if { ![istarget "hppa64*-*"] } then {
@@ -0,0 +1,27 @@
+[ ]*[0-9]*[ ]+\.text
+[ ]*[0-9]*[ ]+func:
+[ ]*[0-9]*[ ]+0000 (1[04]00 ?0000|0000 ?001[04])[ ]+\.cfi_startproc
+[ ]*[0-9]*[ ]+0000 ?0000 *
+[ ]*[0-9]*[ ]+[0-9a-f]{4} 0A[ ]+\.cfi_remember_state
+[ ]*[0-9]*[ ]+0000 .*[ ]\.nop
+[ ]*[0-9]*[ ]+[0-9a-f]{4} 4.0A[ ]+\.cfi_escape 0x0a
+[ ]*[0-9]*[ ]+[0-9a-f]{4} .*[ ]\.nop
+[ ]*[0-9]*[ ]+[0-9a-f]{4} 4.02 ?0002[ ]+\.cfi_escape 0x02, 0x00, 0x02, 0x00
+[ ]*[0-9]*[ ]+00
+[ ]*[0-9]*[ ]+[0-9a-f]{4} .*[ ]\.nop
+[ ]*[0-9]*[ ]+[0-9a-f]{4} 4.03 ?0000[ ]+\.cfi_escape 0x03; .cfi_escape 0x00, 0x00
+[ ]*[0-9]*[ ]+[0-9a-f]{4} 0400 ?0000[ ]+\.cfi_escape 0x04; .cfi_escape 0x00, 0x00, 0x00, 0x00
+[ ]*[0-9]*[ ]+00
+[ ]*[0-9]*[ ]+[0-9a-f]{4} .*[ ]\.nop
+[ ]*[0-9]*[ ]+[0-9a-f]{4} 4.0B[ ]+\.cfi_escape 0x0b
+[ ]*[0-9]*[ ]+[0-9a-f]{4} .*[ ]\.nop
+[ ]*[0-9]*[ ]+[0-9a-f]{4} 4.0B[ ]+\.cfi_restore_state
+[ ]*[0-9]*[ ]+[0-9a-f]{4} .*[ ]\.nop
+[ ]*[0-9]*[ ]+([0-9a-f]{4} [0 ]+)?\.cfi_endproc
+[ ]*[0-9]*[ ]*
+[ ]*[0-9]*[ ]+func2:
+[ ]*[0-9]*[ ]+[0-9a-f]{4} (1[048]00 ?0000|0000 ?001[048])[ ]+\.cfi_startproc
+[ ]*[0-9]*[ ]+(4[048]00 ?0000|0000 ?004[048]) *
+[ ]*[0-9]*[ ]+[0-9a-f]{4} .*[ ]\.nop
+[ ]*[0-9]*[ ]+([0-9a-f]{4} [0 ]+)?\.cfi_endproc
+#pass
@@ -0,0 +1,22 @@
+ .text
+func:
+ .cfi_startproc
+ .cfi_remember_state
+ .nop
+ .cfi_escape 0x0a
+ .nop
+ .cfi_escape 0x02, 0x00, 0x02, 0x00
+ .nop
+ .cfi_escape 0x03; .cfi_escape 0x00, 0x00
+ .cfi_escape 0x04; .cfi_escape 0x00, 0x00, 0x00, 0x00
+ .nop
+ .cfi_escape 0x0b
+ .nop
+ .cfi_restore_state
+ .nop
+ .cfi_endproc
+
+func2:
+ .cfi_startproc
+ .nop
+ .cfi_endproc