X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=gas%2Fecoff.c;h=08bfee1fc5c6412934ae1ecd40e1ebbf8078b509;hb=975f8708de015fb2b813edbf8b714f4777c57a41;hp=32dd81fb563e9d7143bf6bcad54b8c7f0b4ae832;hpb=b90efa5b79ac1524ec260f8eb89d1be37e0219a7;p=deliverable%2Fbinutils-gdb.git diff --git a/gas/ecoff.c b/gas/ecoff.c index 32dd81fb56..08bfee1fc5 100644 --- a/gas/ecoff.c +++ b/gas/ecoff.c @@ -1,5 +1,5 @@ /* ECOFF debugging support. - Copyright (C) 1993-2015 Free Software Foundation, Inc. + Copyright (C) 1993-2020 Free Software Foundation, Inc. Contributed by Cygnus Support. This file was put together by Ian Lance Taylor . A good deal of it comes directly from mips-tfile.c, by Michael @@ -185,7 +185,7 @@ Each file table has offsets for where the line numbers, local strings, local symbols, and procedure table starts from within the - global tables, and the indexs are reset to 0 for each of those + global tables, and the indices are reset to 0 for each of those tables for the file. The procedure table contains the binary equivalents of the .ent @@ -618,7 +618,7 @@ #26 48 0x00000030 struct no name { ifd = -1, index = 1048575 } */ -/* Redefinition of of storage classes as an enumeration for better +/* Redefinition of storage classes as an enumeration for better debugging. */ typedef enum sc { @@ -1422,7 +1422,7 @@ static symint_t add_aux_sym_tir (type_info_t *t, thash_t **hash_tbl); static tag_t *get_tag (const char *tag, localsym_t *sym, bt_t basic_type); static void add_unknown_tag (tag_t *ptag); -static void add_procedure (char *func); +static void add_procedure (char *func, int aent); static void add_file (const char *file_name, int indx, int fake); #ifdef ECOFF_DEBUG static char *sc_to_string (sc_t storage_class); @@ -2109,10 +2109,11 @@ add_unknown_tag (tag_t *ptag /* pointer to tag information */) } /* Add a procedure to the current file's list of procedures, and record - this is the current procedure. */ + this is the current procedure. If AENT, then only set the requested + symbol's function type. */ static void -add_procedure (char *func /* func name */) +add_procedure (char *func /* func name */, int aent) { varray_t *vp; proc_t *new_proc_ptr; @@ -2123,6 +2124,13 @@ add_procedure (char *func /* func name */) fputc ('\n', stderr); #endif + /* Set the BSF_FUNCTION flag for the symbol. */ + sym = symbol_find_or_make (func); + symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION; + + if (aent) + return; + if (cur_file_ptr == (efdr_t *) NULL) as_fatal (_("no current file pointer")); @@ -2143,10 +2151,6 @@ add_procedure (char *func /* func name */) new_proc_ptr->pdr.lnLow = -1; new_proc_ptr->pdr.lnHigh = -1; - /* Set the BSF_FUNCTION flag for the symbol. */ - sym = symbol_find_or_make (func); - symbol_get_bfdsym (sym)->flags |= BSF_FUNCTION; - /* Push the start of the function. */ new_proc_ptr->sym = add_ecoff_symbol ((const char *) NULL, st_Proc, sc_Text, sym, (bfd_vma) 0, (symint_t) 0, @@ -2196,12 +2200,9 @@ add_file (const char *file_name, int indx ATTRIBUTE_UNUSED, int fake) want to use the actual file name. */ if (file_name == (const char *) NULL) { - char *file; - if (first_file != (efdr_t *) NULL) as_fatal (_("fake .file after real one")); - as_where (&file, (unsigned int *) NULL); - file_name = (const char *) file; + file_name = as_where ((unsigned int *) NULL); /* Automatically generate ECOFF debugging information, since I think that's what other ECOFF assemblers do. We don't do @@ -2226,7 +2227,7 @@ add_file (const char *file_name, int indx ATTRIBUTE_UNUSED, int fake) if (stabs_seen) { (void) add_ecoff_symbol (file_name, st_Nil, sc_Nil, - symbol_new ("L0\001", now_seg, + symbol_new (FAKE_LABEL_NAME, now_seg, (valueT) frag_now_fix (), frag_now), (bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SOL)); @@ -2434,14 +2435,13 @@ ecoff_directive_begin (int ignore ATTRIBUTE_UNUSED) return; } - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); (void) add_ecoff_symbol ((const char *) NULL, st_Block, sc_Text, symbol_find_or_make (name), (bfd_vma) 0, (symint_t) 0, (symint_t) 0); - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); /* The line number follows, but we don't use it. */ (void) get_absolute_expression (); @@ -2472,8 +2472,7 @@ ecoff_directive_bend (int ignore ATTRIBUTE_UNUSED) return; } - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); /* The value is the distance between the .bend directive and the corresponding symbol. We fill in the offset when we write out @@ -2485,7 +2484,7 @@ ecoff_directive_bend (int ignore ATTRIBUTE_UNUSED) (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text, endsym, (bfd_vma) 0, (symint_t) 0, (symint_t) 0); - *input_line_pointer = name_end; + restore_line_pointer (name_end); /* The line number follows, but we don't use it. */ (void) get_absolute_expression (); @@ -2519,8 +2518,7 @@ ecoff_directive_def (int ignore ATTRIBUTE_UNUSED) SKIP_WHITESPACE (); - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); if (coff_sym_name != (char *) NULL) as_warn (_(".def pseudo-op used inside of .def/.endef; ignored")); @@ -2528,10 +2526,8 @@ ecoff_directive_def (int ignore ATTRIBUTE_UNUSED) as_warn (_("empty symbol name in .def; ignored")); else { - if (coff_sym_name != (char *) NULL) - free (coff_sym_name); - if (coff_tag != (char *) NULL) - free (coff_tag); + free (coff_sym_name); + free (coff_tag); coff_sym_name = xstrdup (name); coff_type = type_info_init; @@ -2544,7 +2540,7 @@ ecoff_directive_def (int ignore ATTRIBUTE_UNUSED) coff_sym_addend = 0; } - *input_line_pointer = name_end; + restore_line_pointer (name_end); demand_empty_rest_of_line (); } @@ -2757,12 +2753,11 @@ ecoff_directive_tag (int ignore ATTRIBUTE_UNUSED) return; } - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); coff_tag = xstrdup (name); - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); demand_empty_rest_of_line (); } @@ -3004,13 +2999,12 @@ ecoff_directive_end (int ignore ATTRIBUTE_UNUSED) return; } - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); if (name == input_line_pointer) { as_warn (_(".end directive has no name")); - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); demand_empty_rest_of_line (); return; } @@ -3024,21 +3018,25 @@ ecoff_directive_end (int ignore ATTRIBUTE_UNUSED) as_warn (_(".end directive names unknown symbol")); else (void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text, - symbol_new ("L0\001", now_seg, + symbol_new (FAKE_LABEL_NAME, now_seg, (valueT) frag_now_fix (), frag_now), (bfd_vma) 0, (symint_t) 0, (symint_t) 0); +#ifdef md_flush_pending_output + md_flush_pending_output (); +#endif + cur_proc_ptr = (proc_t *) NULL; - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); demand_empty_rest_of_line (); } /* Parse .ent directives. */ void -ecoff_directive_ent (int ignore ATTRIBUTE_UNUSED) +ecoff_directive_ent (int aent) { char *name; char name_end; @@ -3046,27 +3044,26 @@ ecoff_directive_ent (int ignore ATTRIBUTE_UNUSED) if (cur_file_ptr == (efdr_t *) NULL) add_file ((const char *) NULL, 0, 1); - if (cur_proc_ptr != (proc_t *) NULL) + if (!aent && cur_proc_ptr != (proc_t *) NULL) { as_warn (_("second .ent directive found before .end directive")); demand_empty_rest_of_line (); return; } - name = input_line_pointer; - name_end = get_symbol_end (); + name_end = get_symbol_name (&name); if (name == input_line_pointer) { - as_warn (_(".ent directive has no name")); - *input_line_pointer = name_end; + as_warn (_("%s directive has no name"), aent ? ".aent" : ".ent"); + (void) restore_line_pointer (name_end); demand_empty_rest_of_line (); return; } - add_procedure (name); + add_procedure (name, aent); - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); /* The .ent directive is sometimes followed by a number. I'm not really sure what the number means. I don't see any way to store @@ -3095,10 +3092,9 @@ ecoff_directive_extern (int ignore ATTRIBUTE_UNUSED) symbolS *symbolp; valueT size; - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); symbolp = symbol_find_or_make (name); - *input_line_pointer = c; + (void) restore_line_pointer (c); S_SET_EXTERNAL (symbolp); @@ -3266,7 +3262,7 @@ ecoff_directive_loc (int ignore ATTRIBUTE_UNUSED) if (stabs_seen) { (void) add_ecoff_symbol ((char *) NULL, st_Label, sc_Text, - symbol_new ("L0\001", now_seg, + symbol_new (FAKE_LABEL_NAME, now_seg, (valueT) frag_now_fix (), frag_now), (bfd_vma) 0, 0, lineno); @@ -3328,7 +3324,7 @@ mark_stabs (int ignore ATTRIBUTE_UNUSED) { if (! stabs_seen) { - /* Add a dummy @stabs dymbol. */ + /* Add a dummy @stabs symbol. */ stabs_seen = 1; (void) add_ecoff_symbol (stabs_symbol, st_Nil, sc_Info, (symbolS *) NULL, @@ -3348,10 +3344,9 @@ ecoff_directive_weakext (int ignore ATTRIBUTE_UNUSED) symbolS *symbolP; expressionS exp; - name = input_line_pointer; - c = get_symbol_end (); + c = get_symbol_name (&name); symbolP = symbol_find_or_make (name); - *input_line_pointer = c; + (void) restore_line_pointer (c); SKIP_WHITESPACE (); @@ -3489,11 +3484,9 @@ ecoff_stab (segT sec ATTRIBUTE_UNUSED, return; } - name = input_line_pointer; - name_end = get_symbol_end (); - + name_end = get_symbol_name (&name); sym = symbol_find_or_make (name); - *input_line_pointer = name_end; + (void) restore_line_pointer (name_end); value = 0; addend = 0; @@ -3623,7 +3616,7 @@ ecoff_add_bytes (char **buf, if (need < PAGE_SIZE) need = PAGE_SIZE; want = (*bufend - *buf) + need; - *buf = (char *) xrealloc (*buf, want); + *buf = XRESIZEVEC (char, *buf, want); *bufend = *buf + want; return *buf + at; } @@ -3705,8 +3698,7 @@ ecoff_build_lineno (const struct ecoff_debug_swap *backend, && first_proc_ptr != (proc_t *) NULL && local_first_lineno != (lineno_list_t *) NULL && ((S_GET_VALUE (first_proc_ptr->sym->as_sym) - + bfd_get_section_vma (stdoutput, - S_GET_SEGMENT (first_proc_ptr->sym->as_sym))) + + bfd_section_vma (S_GET_SEGMENT (first_proc_ptr->sym->as_sym))) != 0)) { first.file = local_first_lineno->file; @@ -3986,8 +3978,7 @@ ecoff_build_symbols (const struct ecoff_debug_swap *backend, else sym_ptr->ecoff_sym.asym.value = (S_GET_VALUE (as_sym) - + bfd_get_section_vma (stdoutput, - S_GET_SEGMENT (as_sym)) + + bfd_section_vma (S_GET_SEGMENT (as_sym)) + sym_ptr->addend); sym_ptr->ecoff_sym.weakext = S_IS_WEAK (as_sym); @@ -4109,10 +4100,10 @@ ecoff_build_symbols (const struct ecoff_debug_swap *backend, /* If an st_end symbol has an associated gas symbol, then it is a local label created for a .bend or .end directive. Stabs line - numbers will have \001 in the names. */ + numbers will have FAKE_LABEL_CHAR in the names. */ if (local && sym_ptr->ecoff_sym.asym.st != st_End - && strchr (sym_ptr->name, '\001') == 0) + && strchr (sym_ptr->name, FAKE_LABEL_CHAR) == 0) sym_ptr->ecoff_sym.asym.iss = add_string (&fil_ptr->strings, fil_ptr->str_hash, @@ -4315,8 +4306,7 @@ ecoff_build_procs (const struct ecoff_debug_swap *backend, adr_sym = proc_ptr->sym->as_sym; adr = (S_GET_VALUE (adr_sym) - + bfd_get_section_vma (stdoutput, - S_GET_SEGMENT (adr_sym))); + + bfd_section_vma (S_GET_SEGMENT (adr_sym))); if (first) { /* This code used to force the adr of the very @@ -4704,7 +4694,7 @@ ecoff_build_debug (HDRR *hdr, /* Build the symbolic information. */ offset = 0; - buf = (char *) xmalloc (PAGE_SIZE); + buf = XNEWVEC (char, PAGE_SIZE); bufend = buf + PAGE_SIZE; /* Build the line number information. */ @@ -4863,7 +4853,7 @@ allocate_scope (void) #else - ptr = (scope_t *) xmalloc (sizeof (scope_t)); + ptr = XNEW (scope_t); #endif @@ -4912,7 +4902,7 @@ allocate_vlinks (void) #else - ptr = (vlinks_t *) xmalloc (sizeof (vlinks_t)); + ptr = XNEW (vlinks_t); #endif @@ -4946,7 +4936,7 @@ allocate_shash (void) #else - ptr = (shash_t *) xmalloc (sizeof (shash_t)); + ptr = XNEW (shash_t); #endif @@ -4980,7 +4970,7 @@ allocate_thash (void) #else - ptr = (thash_t *) xmalloc (sizeof (thash_t)); + ptr = XNEW (thash_t); #endif @@ -5020,7 +5010,7 @@ allocate_tag (void) #else - ptr = (tag_t *) xmalloc (sizeof (tag_t)); + ptr = XNEW (tag_t); #endif @@ -5069,7 +5059,7 @@ allocate_forward (void) #else - ptr = (forward_t *) xmalloc (sizeof (forward_t)); + ptr = XNEW (forward_t); #endif @@ -5109,7 +5099,7 @@ allocate_thead (void) #else - ptr = (thead_t *) xmalloc (sizeof (thead_t)); + ptr = XNEW (thead_t); #endif @@ -5156,7 +5146,7 @@ allocate_lineno_list (void) #else - ptr = (lineno_list_t *) xmalloc (sizeof (lineno_list_t)); + ptr = XNEW (lineno_list_t); #endif @@ -5191,10 +5181,10 @@ void ecoff_generate_asm_lineno (void) { unsigned int lineno; - char *filename; + const char *filename; lineno_list_t *list; - as_where (&filename, &lineno); + filename = as_where (&lineno); if (current_stabs_filename == (char *) NULL || filename_cmp (current_stabs_filename, filename))