static void dot_cfi_escape (int ignored ATTRIBUTE_UNUSED) { struct cfi_escape_data *head, **tail, *e; struct cfi_insn_data *insn; if (frchain_now->frch_cfi_data == NULL) { as_bad (_("CFI instruction used without previous .cfi_startproc")); ignore_rest_of_line (); return; } /* If the last address was not at the current PC, advance to current. */ 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; do { e = xmalloc (sizeof (*e)); do_parse_cons_expression (&e->exp, 1); *tail = e; tail = &e->next; } while (*input_line_pointer++ == ','); *tail = NULL; insn = alloc_cfi_insn_data (); insn->insn = CFI_escape; insn->u.esc = head; --input_line_pointer; demand_empty_rest_of_line (); }
static void output_cfi_insn (struct cfi_insn_data *insn) { offsetT offset; unsigned int regno; switch (insn->insn) { case DW_CFA_advance_loc: { symbolS *from = insn->u.ll.lab1; symbolS *to = insn->u.ll.lab2; if (symbol_get_frag (to) == symbol_get_frag (from)) { addressT delta = S_GET_VALUE (to) - S_GET_VALUE (from); addressT scaled = delta / DWARF2_LINE_MIN_INSN_LENGTH; if (scaled <= 0x3F) out_one (DW_CFA_advance_loc + scaled); else if (delta <= 0xFF) { out_one (DW_CFA_advance_loc1); out_one (delta); } else if (delta <= 0xFFFF) { out_one (DW_CFA_advance_loc2); out_two (delta); } else { out_one (DW_CFA_advance_loc4); out_four (delta); } } else { expressionS exp; exp.X_op = O_subtract; exp.X_add_symbol = to; exp.X_op_symbol = from; exp.X_add_number = 0; /* The code in ehopt.c expects that one byte of the encoding is already allocated to the frag. This comes from the way that it scans the .eh_frame section looking first for the .byte DW_CFA_advance_loc4. */ frag_more (1); frag_var (rs_cfa, 4, 0, DWARF2_LINE_MIN_INSN_LENGTH << 3, make_expr_symbol (&exp), frag_now_fix () - 1, (char *) frag_now); } } break; case DW_CFA_def_cfa: offset = insn->u.ri.offset; if (offset < 0) { out_one (DW_CFA_def_cfa_sf); out_uleb128 (insn->u.ri.reg); out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); } else { out_one (DW_CFA_def_cfa); out_uleb128 (insn->u.ri.reg); out_uleb128 (offset); } break; case DW_CFA_def_cfa_register: case DW_CFA_undefined: case DW_CFA_same_value: out_one (insn->insn); out_uleb128 (insn->u.r); break; case DW_CFA_def_cfa_offset: offset = insn->u.i; if (offset < 0) { out_one (DW_CFA_def_cfa_offset_sf); out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); } else { out_one (DW_CFA_def_cfa_offset); out_uleb128 (offset); } break; case DW_CFA_restore: regno = insn->u.r; if (regno <= 0x3F) { out_one (DW_CFA_restore + regno); } else { out_one (DW_CFA_restore_extended); out_uleb128 (regno); } break; case DW_CFA_offset: regno = insn->u.ri.reg; offset = insn->u.ri.offset / DWARF2_CIE_DATA_ALIGNMENT; if (offset < 0) { out_one (DW_CFA_offset_extended_sf); out_uleb128 (regno); out_sleb128 (offset); } else if (regno <= 0x3F) { out_one (DW_CFA_offset + regno); out_uleb128 (offset); } else { out_one (DW_CFA_offset_extended); out_uleb128 (regno); out_uleb128 (offset); } break; case DW_CFA_register: out_one (DW_CFA_register); out_uleb128 (insn->u.rr.reg1); out_uleb128 (insn->u.rr.reg2); break; case DW_CFA_remember_state: case DW_CFA_restore_state: out_one (insn->insn); break; case DW_CFA_GNU_window_save: out_one (DW_CFA_GNU_window_save); break; case CFI_escape: { struct cfi_escape_data *e; for (e = insn->u.esc; e ; e = e->next) emit_expr (&e->exp, 1); break; } default: abort (); } }
static void dot_cfi (int arg) { offsetT offset; unsigned reg1, reg2; if (frchain_now->frch_cfi_data == NULL) { as_bad (_("CFI instruction used without previous .cfi_startproc")); ignore_rest_of_line (); return; } /* If the last address was not at the current PC, advance to current. */ 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) { case DW_CFA_offset: reg1 = cfi_parse_reg (); cfi_parse_separator (); offset = cfi_parse_const (); cfi_add_CFA_offset (reg1, offset); break; case CFI_rel_offset: reg1 = cfi_parse_reg (); cfi_parse_separator (); offset = cfi_parse_const (); cfi_add_CFA_offset (reg1, offset - frchain_now->frch_cfi_data->cur_cfa_offset); break; case DW_CFA_def_cfa: reg1 = cfi_parse_reg (); cfi_parse_separator (); offset = cfi_parse_const (); cfi_add_CFA_def_cfa (reg1, offset); break; case DW_CFA_register: reg1 = cfi_parse_reg (); cfi_parse_separator (); reg2 = cfi_parse_reg (); cfi_add_CFA_register (reg1, reg2); break; case DW_CFA_def_cfa_register: reg1 = cfi_parse_reg (); cfi_add_CFA_def_cfa_register (reg1); break; case DW_CFA_def_cfa_offset: offset = cfi_parse_const (); cfi_add_CFA_def_cfa_offset (offset); break; case CFI_adjust_cfa_offset: offset = cfi_parse_const (); cfi_add_CFA_def_cfa_offset (frchain_now->frch_cfi_data->cur_cfa_offset + offset); break; case DW_CFA_restore: 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: 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: reg1 = cfi_parse_reg (); cfi_add_CFA_same_value (reg1); break; case CFI_return_column: reg1 = cfi_parse_reg (); cfi_set_return_column (reg1); break; case DW_CFA_remember_state: cfi_add_CFA_remember_state (); break; case DW_CFA_restore_state: cfi_add_CFA_restore_state (); break; case DW_CFA_GNU_window_save: cfi_add_CFA_insn (DW_CFA_GNU_window_save); break; case CFI_signal_frame: frchain_now->frch_cfi_data->cur_fde_data->signal_frame = 1; break; default: abort (); } demand_empty_rest_of_line (); }
static void process_entries (segT seg, struct line_entry *e) { unsigned filenum = 1; unsigned line = 1; unsigned column = 0; unsigned isa = 0; unsigned flags = DWARF2_LINE_DEFAULT_IS_STMT ? DWARF2_FLAG_IS_STMT : 0; fragS *last_frag = NULL, *frag; addressT last_frag_ofs = 0, frag_ofs; symbolS *last_lab = NULL, *lab; struct line_entry *next; do { int line_delta; if (filenum != e->loc.filenum) { filenum = e->loc.filenum; out_opcode (DW_LNS_set_file); out_uleb128 (filenum); } if (column != e->loc.column) { column = e->loc.column; out_opcode (DW_LNS_set_column); out_uleb128 (column); } if (e->loc.discriminator != 0) { out_opcode (DW_LNS_extended_op); out_leb128 (1 + sizeof_leb128 (e->loc.discriminator, 0)); out_opcode (DW_LNE_set_discriminator); out_uleb128 (e->loc.discriminator); } if (isa != e->loc.isa) { isa = e->loc.isa; out_opcode (DW_LNS_set_isa); out_uleb128 (isa); } if ((e->loc.flags ^ flags) & DWARF2_FLAG_IS_STMT) { flags = e->loc.flags; out_opcode (DW_LNS_negate_stmt); } if (e->loc.flags & DWARF2_FLAG_BASIC_BLOCK) out_opcode (DW_LNS_set_basic_block); if (e->loc.flags & DWARF2_FLAG_PROLOGUE_END) out_opcode (DW_LNS_set_prologue_end); if (e->loc.flags & DWARF2_FLAG_EPILOGUE_BEGIN) out_opcode (DW_LNS_set_epilogue_begin); /* Don't try to optimize away redundant entries; gdb wants two entries for a function where the code starts on the same line as the {, and there's no way to identify that case here. Trust gcc to optimize appropriately. */ line_delta = e->loc.line - line; lab = e->label; frag = symbol_get_frag (lab); frag_ofs = S_GET_VALUE (lab); if (last_frag == NULL) { out_set_addr (lab); out_inc_line_addr (line_delta, 0); } else if (frag == last_frag && ! DWARF2_USE_FIXED_ADVANCE_PC) out_inc_line_addr (line_delta, frag_ofs - last_frag_ofs); else relax_inc_line_addr (line_delta, lab, last_lab); line = e->loc.line; last_lab = lab; last_frag = frag; last_frag_ofs = frag_ofs; next = e->next; free (e); e = next; } while (e); /* Emit a DW_LNE_end_sequence for the end of the section. */ frag = last_frag_for_seg (seg); frag_ofs = get_frag_fix (frag, seg); if (frag == last_frag && ! DWARF2_USE_FIXED_ADVANCE_PC) out_inc_line_addr (INT_MAX, frag_ofs - last_frag_ofs); else { lab = symbol_temp_new (seg, frag_ofs, frag); relax_inc_line_addr (INT_MAX, lab, last_lab); } }
static void list_symbol_table (void) { extern symbolS *symbol_rootP; int got_some = 0; symbolS *ptr; eject = 1; listing_page (NULL); for (ptr = symbol_rootP; ptr != (symbolS *) NULL; ptr = symbol_next (ptr)) { if (SEG_NORMAL (S_GET_SEGMENT (ptr)) || S_GET_SEGMENT (ptr) == absolute_section) { /* Don't report section symbols. They are not interesting. */ if (symbol_section_p (ptr)) continue; if (S_GET_NAME (ptr)) { char buf[30], fmt[8]; valueT val = S_GET_VALUE (ptr); /* @@ Note that this is dependent on the compilation options, not solely on the target characteristics. */ if (sizeof (val) == 4 && sizeof (int) == 4) sprintf (buf, "%08lx", (unsigned long) val); else if (sizeof (val) <= sizeof (unsigned long)) { sprintf (fmt, "%%0%lulx", (unsigned long) (sizeof (val) * 2)); sprintf (buf, fmt, (unsigned long) val); } #if defined (BFD64) else if (sizeof (val) > 4) sprintf_vma (buf, val); #endif else abort (); if (!got_some) { fprintf (list_file, "DEFINED SYMBOLS\n"); on_page++; got_some = 1; } if (symbol_get_frag (ptr) && symbol_get_frag (ptr)->line) { fprintf (list_file, "%20s:%-5d %s:%s %s\n", symbol_get_frag (ptr)->line->file->filename, symbol_get_frag (ptr)->line->line, segment_name (S_GET_SEGMENT (ptr)), buf, S_GET_NAME (ptr)); } else { fprintf (list_file, "%33s:%s %s\n", segment_name (S_GET_SEGMENT (ptr)), buf, S_GET_NAME (ptr)); } on_page++; listing_page (NULL); } } } if (!got_some) { fprintf (list_file, "NO DEFINED SYMBOLS\n"); on_page++; } emit_line (NULL, "\n"); got_some = 0; for (ptr = symbol_rootP; ptr != (symbolS *) NULL; ptr = symbol_next (ptr)) { if (S_GET_NAME (ptr) && strlen (S_GET_NAME (ptr)) != 0) { if (S_GET_SEGMENT (ptr) == undefined_section) { if (!got_some) { got_some = 1; emit_line (NULL, "UNDEFINED SYMBOLS\n"); } emit_line (NULL, "%s\n", S_GET_NAME (ptr)); } } } if (!got_some) emit_line (NULL, "NO UNDEFINED SYMBOLS\n"); }
static void dot_cfi_val_encoded_addr (int ignored ATTRIBUTE_UNUSED) { struct cfi_insn_data *insn_ptr; offsetT encoding; if (frchain_now->frch_cfi_data == NULL) { as_bad (_("CFI instruction used without previous .cfi_startproc")); ignore_rest_of_line (); return; } /* If the last address was not at the current PC, advance to current. */ 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 ()); insn_ptr = alloc_cfi_insn_data (); insn_ptr->insn = CFI_val_encoded_addr; insn_ptr->u.ea.reg = cfi_parse_reg (); cfi_parse_separator (); encoding = cfi_parse_const (); if ((encoding & 0xff) != encoding || ((encoding & 0x70) != 0 #if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr && (encoding & 0x70) != DW_EH_PE_pcrel #endif ) /* leb128 can be handled, but does something actually need it? */ || (encoding & 7) == DW_EH_PE_uleb128 || (encoding & 7) > DW_EH_PE_udata8) { as_bad (_("invalid or unsupported encoding in .cfi_lsda")); encoding = DW_EH_PE_omit; } cfi_parse_separator (); expression_and_evaluate (&insn_ptr->u.ea.exp); switch (insn_ptr->u.ea.exp.X_op) { case O_symbol: break; case O_constant: if ((encoding & 0x70) != DW_EH_PE_pcrel) break; default: encoding = DW_EH_PE_omit; break; } insn_ptr->u.ea.encoding = encoding; if (encoding == DW_EH_PE_omit) { as_bad (_("wrong third argument to .cfi_val_encoded_addr")); ignore_rest_of_line (); return; } demand_empty_rest_of_line (); }
static void output_cfi_insn (struct cfi_insn_data *insn) { offsetT offset; unsigned int regno; switch (insn->insn) { case DW_CFA_advance_loc: { symbolS *from = insn->u.ll.lab1; symbolS *to = insn->u.ll.lab2; if (symbol_get_frag (to) == symbol_get_frag (from)) { addressT delta = S_GET_VALUE (to) - S_GET_VALUE (from); addressT scaled = delta / DWARF2_LINE_MIN_INSN_LENGTH; if (scaled <= 0x3F) out_one (DW_CFA_advance_loc + scaled); else if (scaled <= 0xFF) { out_one (DW_CFA_advance_loc1); out_one (scaled); } else if (scaled <= 0xFFFF) { out_one (DW_CFA_advance_loc2); out_two (scaled); } else { out_one (DW_CFA_advance_loc4); out_four (scaled); } } else { expressionS exp; exp.X_op = O_subtract; exp.X_add_symbol = to; exp.X_op_symbol = from; exp.X_add_number = 0; /* The code in ehopt.c expects that one byte of the encoding is already allocated to the frag. This comes from the way that it scans the .eh_frame section looking first for the .byte DW_CFA_advance_loc4. */ *frag_more (1) = DW_CFA_advance_loc4; frag_var (rs_cfa, 4, 0, DWARF2_LINE_MIN_INSN_LENGTH << 3, make_expr_symbol (&exp), frag_now_fix () - 1, (char *) frag_now); } } break; case DW_CFA_def_cfa: offset = insn->u.ri.offset; if (offset < 0) { out_one (DW_CFA_def_cfa_sf); out_uleb128 (insn->u.ri.reg); out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); } else { out_one (DW_CFA_def_cfa); out_uleb128 (insn->u.ri.reg); out_uleb128 (offset); } break; case DW_CFA_def_cfa_register: case DW_CFA_undefined: case DW_CFA_same_value: out_one (insn->insn); out_uleb128 (insn->u.r); break; case DW_CFA_def_cfa_offset: offset = insn->u.i; if (offset < 0) { out_one (DW_CFA_def_cfa_offset_sf); out_sleb128 (offset / DWARF2_CIE_DATA_ALIGNMENT); } else { out_one (DW_CFA_def_cfa_offset); out_uleb128 (offset); } break; case DW_CFA_restore: regno = insn->u.r; if (regno <= 0x3F) { out_one (DW_CFA_restore + regno); } else { out_one (DW_CFA_restore_extended); out_uleb128 (regno); } break; case DW_CFA_offset: regno = insn->u.ri.reg; offset = insn->u.ri.offset / DWARF2_CIE_DATA_ALIGNMENT; if (offset < 0) { out_one (DW_CFA_offset_extended_sf); out_uleb128 (regno); out_sleb128 (offset); } else if (regno <= 0x3F) { out_one (DW_CFA_offset + regno); out_uleb128 (offset); } else { out_one (DW_CFA_offset_extended); out_uleb128 (regno); out_uleb128 (offset); } break; case DW_CFA_register: out_one (DW_CFA_register); out_uleb128 (insn->u.rr.reg1); out_uleb128 (insn->u.rr.reg2); break; case DW_CFA_remember_state: case DW_CFA_restore_state: out_one (insn->insn); break; case DW_CFA_GNU_window_save: out_one (DW_CFA_GNU_window_save); break; case CFI_escape: { struct cfi_escape_data *e; for (e = insn->u.esc; e ; e = e->next) emit_expr (&e->exp, 1); break; } case CFI_val_encoded_addr: { unsigned encoding = insn->u.ea.encoding; offsetT encoding_size; if (encoding == DW_EH_PE_omit) break; out_one (DW_CFA_val_expression); out_uleb128 (insn->u.ea.reg); switch (encoding & 0x7) { case DW_EH_PE_absptr: encoding_size = DWARF2_ADDR_SIZE (stdoutput); break; case DW_EH_PE_udata2: encoding_size = 2; break; case DW_EH_PE_udata4: encoding_size = 4; break; case DW_EH_PE_udata8: encoding_size = 8; break; default: abort (); } /* If the user has requested absolute encoding, then use the smaller DW_OP_addr encoding. */ if (insn->u.ea.encoding == DW_EH_PE_absptr) { out_uleb128 (1 + encoding_size); out_one (DW_OP_addr); } else { out_uleb128 (1 + 1 + encoding_size); out_one (DW_OP_GNU_encoded_addr); out_one (encoding); if ((encoding & 0x70) == DW_EH_PE_pcrel) { #if CFI_DIFF_EXPR_OK insn->u.ea.exp.X_op = O_subtract; insn->u.ea.exp.X_op_symbol = symbol_temp_new_now (); #elif defined (tc_cfi_emit_pcrel_expr) tc_cfi_emit_pcrel_expr (&insn->u.ea.exp, encoding_size); break; #else abort (); #endif } } emit_expr (&insn->u.ea.exp, encoding_size); } break; default: abort (); } }
void coff_frob_symbol (symbolS *symp, int *punt) { static symbolS *last_tagP; static stack *block_stack; static symbolS *set_end; symbolS *next_set_end = NULL; if (symp == &abs_symbol) { *punt = 1; return; } if (current_lineno_sym) coff_add_linesym (NULL); if (!block_stack) block_stack = stack_init (512, sizeof (symbolS*)); #ifdef TE_PE if (S_GET_STORAGE_CLASS (symp) == C_NT_WEAK && ! S_IS_WEAK (symp) && weak_is_altname (S_GET_NAME (symp))) { /* This is a weak alternate symbol. All processing of PECOFFweak symbols is done here, through the alternate. */ symbolS *weakp = symbol_find_noref (weak_altname2name (S_GET_NAME (symp)), 1); assert (weakp); assert (S_GET_NUMBER_AUXILIARY (weakp) == 1); if (! S_IS_WEAK (weakp)) { /* The symbol was turned from weak to strong. Discard altname. */ *punt = 1; return; } else if (symbol_equated_p (weakp)) { /* The weak symbol has an alternate specified; symp is unneeded. */ S_SET_STORAGE_CLASS (weakp, C_NT_WEAK); SA_SET_SYM_TAGNDX (weakp, symbol_get_value_expression (weakp)->X_add_symbol); S_CLEAR_EXTERNAL (symp); *punt = 1; return; } else { /* The weak symbol has been assigned an alternate value. Copy this value to symp, and set symp as weakp's alternate. */ if (S_GET_STORAGE_CLASS (weakp) != C_NT_WEAK) { S_SET_STORAGE_CLASS (symp, S_GET_STORAGE_CLASS (weakp)); S_SET_STORAGE_CLASS (weakp, C_NT_WEAK); } if (S_IS_DEFINED (weakp)) { /* This is a defined weak symbol. Copy value information from the weak symbol itself to the alternate symbol. */ symbol_set_value_expression (symp, symbol_get_value_expression (weakp)); symbol_set_frag (symp, symbol_get_frag (weakp)); S_SET_SEGMENT (symp, S_GET_SEGMENT (weakp)); } else { /* This is an undefined weak symbol. Define the alternate symbol to zero. */ S_SET_VALUE (symp, 0); S_SET_SEGMENT (symp, absolute_section); } S_SET_NAME (symp, weak_uniquify (S_GET_NAME (symp))); S_SET_STORAGE_CLASS (symp, C_EXT); S_SET_VALUE (weakp, 0); S_SET_SEGMENT (weakp, undefined_section); } } #else /* TE_PE */ if (S_IS_WEAK (symp)) S_SET_STORAGE_CLASS (symp, C_WEAKEXT); #endif /* TE_PE */ if (!S_IS_DEFINED (symp) && !S_IS_WEAK (symp) && S_GET_STORAGE_CLASS (symp) != C_STAT) S_SET_STORAGE_CLASS (symp, C_EXT); if (!SF_GET_DEBUG (symp)) { symbolS * real; if (!SF_GET_LOCAL (symp) && !SF_GET_STATICS (symp) && S_GET_STORAGE_CLASS (symp) != C_LABEL && symbol_constant_p (symp) && (real = symbol_find_noref (S_GET_NAME (symp), 1)) && S_GET_STORAGE_CLASS (real) == C_NULL && real != symp) { c_symbol_merge (symp, real); *punt = 1; return; } if (!S_IS_DEFINED (symp) && !SF_GET_LOCAL (symp)) { assert (S_GET_VALUE (symp) == 0); if (S_IS_WEAKREFD (symp)) *punt = 1; else S_SET_EXTERNAL (symp); } else if (S_GET_STORAGE_CLASS (symp) == C_NULL) { if (S_GET_SEGMENT (symp) == text_section && symp != seg_info (text_section)->sym) S_SET_STORAGE_CLASS (symp, C_LABEL); else S_SET_STORAGE_CLASS (symp, C_STAT); } if (SF_GET_PROCESS (symp)) { if (S_GET_STORAGE_CLASS (symp) == C_BLOCK) { if (streq (S_GET_NAME (symp), ".bb")) stack_push (block_stack, (char *) &symp); else { symbolS *begin; begin = *(symbolS **) stack_pop (block_stack); if (begin == 0) as_warn (_("mismatched .eb")); else next_set_end = begin; } } if (coff_last_function == 0 && SF_GET_FUNCTION (symp)) { union internal_auxent *auxp; coff_last_function = symp; if (S_GET_NUMBER_AUXILIARY (symp) < 1) S_SET_NUMBER_AUXILIARY (symp, 1); auxp = SYM_AUXENT (symp); memset (auxp->x_sym.x_fcnary.x_ary.x_dimen, 0, sizeof (auxp->x_sym.x_fcnary.x_ary.x_dimen)); } if (S_GET_STORAGE_CLASS (symp) == C_EFCN) { if (coff_last_function == 0) as_fatal (_("C_EFCN symbol for %s out of scope"), S_GET_NAME (symp)); SA_SET_SYM_FSIZE (coff_last_function, (long) (S_GET_VALUE (symp) - S_GET_VALUE (coff_last_function))); next_set_end = coff_last_function; coff_last_function = 0; } } if (S_IS_EXTERNAL (symp)) S_SET_STORAGE_CLASS (symp, C_EXT); else if (SF_GET_LOCAL (symp)) *punt = 1; if (SF_GET_FUNCTION (symp)) symbol_get_bfdsym (symp)->flags |= BSF_FUNCTION; } /* Double check weak symbols. */ if (S_IS_WEAK (symp) && S_IS_COMMON (symp)) as_bad (_("Symbol `%s' can not be both weak and common"), S_GET_NAME (symp)); if (SF_GET_TAG (symp)) last_tagP = symp; else if (S_GET_STORAGE_CLASS (symp) == C_EOS) next_set_end = last_tagP; #ifdef OBJ_XCOFF /* This is pretty horrible, but we have to set *punt correctly in order to call SA_SET_SYM_ENDNDX correctly. */ if (! symbol_used_in_reloc_p (symp) && ((symbol_get_bfdsym (symp)->flags & BSF_SECTION_SYM) != 0 || (! (S_IS_EXTERNAL (symp) || S_IS_WEAK (symp)) && ! symbol_get_tc (symp)->output && S_GET_STORAGE_CLASS (symp) != C_FILE))) *punt = 1; #endif if (set_end != (symbolS *) NULL && ! *punt && ((symbol_get_bfdsym (symp)->flags & BSF_NOT_AT_END) != 0 || (S_IS_DEFINED (symp) && ! S_IS_COMMON (symp) && (! S_IS_EXTERNAL (symp) || SF_GET_FUNCTION (symp))))) { SA_SET_SYM_ENDNDX (set_end, symp); set_end = NULL; } if (next_set_end != NULL) { if (set_end != NULL) as_warn ("Warning: internal error: forgetting to set endndx of %s", S_GET_NAME (set_end)); set_end = next_set_end; } #ifndef OBJ_XCOFF if (! *punt && S_GET_STORAGE_CLASS (symp) == C_FCN && streq (S_GET_NAME (symp), ".bf")) { if (coff_last_bf != NULL) SA_SET_SYM_ENDNDX (coff_last_bf, symp); coff_last_bf = symp; } #endif if (coffsymbol (symbol_get_bfdsym (symp))->lineno) { int i; struct line_no *lptr; alent *l; lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno; for (i = 0; lptr; lptr = lptr->next) i++; lptr = (struct line_no *) coffsymbol (symbol_get_bfdsym (symp))->lineno; /* We need i entries for line numbers, plus 1 for the first entry which BFD will override, plus 1 for the last zero entry (a marker for BFD). */ l = xmalloc ((i + 2) * sizeof (* l)); coffsymbol (symbol_get_bfdsym (symp))->lineno = l; l[i + 1].line_number = 0; l[i + 1].u.sym = NULL; for (; i > 0; i--) { if (lptr->frag) lptr->l.u.offset += lptr->frag->fr_address / OCTETS_PER_BYTE; l[i] = lptr->l; lptr = lptr->next; } } }