From a1facbec7a584827dc10d1e3afc326e8653de4ac Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Thu, 16 Dec 2010 18:48:28 +0000 Subject: [PATCH] * symbols.c (symbol_clone_if_forward_ref): Call tc_new_dot_label for new fake labels created off the dot special symbol. * config/tc-mips.h (tc_new_dot_label): New macro. (mips_record_label): New prototype. * config/tc-mips.c (my_getExpression): Remove MIPS16 fake label annotation. (s_cons, s_float_cons, s_gpword, s_gpdword): Only clear labels recorded once data expressions have been evaluated. (mips_define_label): Move code to record labels over to... (mips_record_label): ... this new function. * doc/internals.texi: Document tc_new_dot_label. --- gas/ChangeLog | 14 ++++++++++++++ gas/config/tc-mips.c | 41 ++++++++++++++++++----------------------- gas/config/tc-mips.h | 3 +++ gas/doc/internals.texi | 5 +++++ gas/symbols.c | 7 ++++++- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index ae54fcab29..f16fbbc9da 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,17 @@ +2010-12-16 Maciej W. Rozycki + + * symbols.c (symbol_clone_if_forward_ref): Call tc_new_dot_label + for new fake labels created off the dot special symbol. + * config/tc-mips.h (tc_new_dot_label): New macro. + (mips_record_label): New prototype. + * config/tc-mips.c (my_getExpression): Remove MIPS16 fake label + annotation. + (s_cons, s_float_cons, s_gpword, s_gpdword): Only clear labels + recorded once data expressions have been evaluated. + (mips_define_label): Move code to record labels over to... + (mips_record_label): ... this new function. + * doc/internals.texi: Document tc_new_dot_label. + 2010-12-10 Maciej W. Rozycki * config/tc-mips.h (TC_ADDRESS_BYTES): New macro. diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index a414c3ac12..65d198913b 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -11136,26 +11136,12 @@ static void my_getExpression (expressionS *ep, char *str) { char *save_in; - valueT val; save_in = input_line_pointer; input_line_pointer = str; expression (ep); expr_end = input_line_pointer; input_line_pointer = save_in; - - /* If we are in mips16 mode, and this is an expression based on `.', - then we bump the value of the symbol by 1 since that is how other - text symbols are handled. We don't bother to handle complex - expressions, just `.' plus or minus a constant. */ - if (mips_opts.mips16 - && ep->X_op == O_symbol - && strcmp (S_GET_NAME (ep->X_add_symbol), FAKE_LABEL_NAME) == 0 - && S_GET_SEGMENT (ep->X_add_symbol) == now_seg - && symbol_get_frag (ep->X_add_symbol) == frag_now - && symbol_constant_p (ep->X_add_symbol) - && (val = S_GET_VALUE (ep->X_add_symbol)) == frag_now_fix ()) - S_SET_VALUE (ep->X_add_symbol, val + 1); } char * @@ -12726,8 +12712,8 @@ s_cons (int log_size) mips_emit_delays (); if (log_size > 0 && auto_align) mips_align (log_size, 0, label); - mips_clear_insn_labels (); cons (1 << log_size); + mips_clear_insn_labels (); } static void @@ -12749,9 +12735,8 @@ s_float_cons (int type) mips_align (2, 0, label); } - mips_clear_insn_labels (); - float_cons (type); + mips_clear_insn_labels (); } /* Handle .globl. We need to override it because on Irix 5 you are @@ -13516,9 +13501,9 @@ s_gpword (int ignore ATTRIBUTE_UNUSED) mips_emit_delays (); if (auto_align) mips_align (2, 0, label); - mips_clear_insn_labels (); expression (&ex); + mips_clear_insn_labels (); if (ex.X_op != O_symbol || ex.X_add_number != 0) { @@ -13556,9 +13541,9 @@ s_gpdword (int ignore ATTRIBUTE_UNUSED) mips_emit_delays (); if (auto_align) mips_align (3, 0, label); - mips_clear_insn_labels (); expression (&ex); + mips_clear_insn_labels (); if (ex.X_op != O_symbol || ex.X_add_number != 0) { @@ -14706,12 +14691,14 @@ mips_frob_file_after_relocs (void) #endif -/* This function is called whenever a label is defined. It is used - when handling branch delays; if a branch has a label, we assume we - can not move it. */ +/* This function is called whenever a label is defined, including fake + labels instantiated off the dot special symbol. It is used when + handling branch delays; if a branch has a label, we assume we cannot + move it. This also bumps the value of the symbol by 1 in compressed + code. */ void -mips_define_label (symbolS *sym) +mips_record_label (symbolS *sym) { segment_info_type *si = seg_info (now_seg); struct insn_label_list *l; @@ -14727,7 +14714,15 @@ mips_define_label (symbolS *sym) l->label = sym; l->next = si->label_list; si->label_list = l; +} +/* This function is called as tc_frob_label() whenever a label is defined + and adds a DWARF-2 record we only want for true labels. */ + +void +mips_define_label (symbolS *sym) +{ + mips_record_label (sym); #ifdef OBJ_ELF dwarf2_emit_label (sym); #endif diff --git a/gas/config/tc-mips.h b/gas/config/tc-mips.h index abd8d1e516..3da94ada71 100644 --- a/gas/config/tc-mips.h +++ b/gas/config/tc-mips.h @@ -112,6 +112,9 @@ extern int mips_parse_long_option (const char *); #define tc_frob_label(sym) mips_define_label (sym) extern void mips_define_label (symbolS *); +#define tc_new_dot_label(sym) mips_record_label (sym) +extern void mips_record_label (symbolS *); + #define tc_frob_file_before_adjust() mips_frob_file_before_adjust () extern void mips_frob_file_before_adjust (void); diff --git a/gas/doc/internals.texi b/gas/doc/internals.texi index f8495a9196..58b56868ce 100644 --- a/gas/doc/internals.texi +++ b/gas/doc/internals.texi @@ -1395,6 +1395,11 @@ that @code{md_pcrel_from} does not take a section argument. @cindex tc_frob_label If you define this macro, GAS will call it each time a label is defined. +@item tc_new_dot_label +@cindex tc_new_dot_label +If you define this macro, GAS will call it each time a fake label is created +off the special dot symbol. + @item md_section_align @cindex md_section_align GAS will call this function for each section at the end of the assembly, to diff --git a/gas/symbols.c b/gas/symbols.c index 4e4ad775b3..9a4e2bef54 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -668,7 +668,12 @@ symbol_clone_if_forward_ref (symbolS *symbolP, int is_forward) symbolP->sy_resolving = 0; } else - symbolP = symbol_temp_new_now (); + { + symbolP = symbol_temp_new_now (); +#ifdef tc_new_dot_label + tc_new_dot_label (symbolP); +#endif + } } symbolP->sy_value.X_add_symbol = add_symbol; -- 2.34.1