aboutsummaryrefslogtreecommitdiff
path: root/gas/ecoff.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>1996-01-29 17:25:26 +0000
committerIan Lance Taylor <ian@airs.com>1996-01-29 17:25:26 +0000
commit8e3ff08126739ee67fb43d46473ae9d3c61cd324 (patch)
treed5d0326a5708f2bc66fbe8c2b328ef2f3bbbe645 /gas/ecoff.c
parentd221b17e83dc8562129b8e9284021baa89e3c877 (diff)
downloadgdb-8e3ff08126739ee67fb43d46473ae9d3c61cd324.zip
gdb-8e3ff08126739ee67fb43d46473ae9d3c61cd324.tar.gz
gdb-8e3ff08126739ee67fb43d46473ae9d3c61cd324.tar.bz2
* ecoff.c (localsym_t): Add addend field.
(add_ecoff_symbol): Add addend argument. Change all callers. (coff_sym_value): Make static. (coff_sym_addend): New static variable. (ecoff_directive_def): Initialize coff_sym_addend. (ecoff_directive_val): Accept symbol + constant. (ecoff_directive_endef): Pass coff_sym_addend to add_ecoff_symbol. (ecoff_build_symbols): Include the addend in the symbol value.
Diffstat (limited to 'gas/ecoff.c')
-rw-r--r--gas/ecoff.c130
1 files changed, 74 insertions, 56 deletions
diff --git a/gas/ecoff.c b/gas/ecoff.c
index 51d5c65..0d70ba3 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -1,5 +1,5 @@
/* ECOFF debugging support.
- Copyright (C) 1993 Free Software Foundation, Inc.
+ Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
Contributed by Cygnus Support.
This file was put together by Ian Lance Taylor <ian@cygnus.com>. A
good deal of it comes directly from mips-tfile.c, by Michael
@@ -18,8 +18,9 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with GAS; see the file COPYING. If not, write to
- the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ along with GAS; see the file COPYING. If not, write to the Free
+ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+ 02111-1307, USA. */
#include "as.h"
@@ -832,6 +833,7 @@ typedef struct scope {
typedef struct localsym {
const char *name; /* symbol name */
symbolS *as_sym; /* symbol as seen by gas */
+ bfd_vma addend; /* addend to as_sym value */
struct efdr *file_ptr; /* file pointer */
struct ecoff_proc *proc_ptr; /* proc pointer */
struct localsym *begin_ptr; /* symbol at start of block */
@@ -1425,7 +1427,7 @@ static symint_t add_string PARAMS ((varray_t *vp,
shash_t **ret_hash));
static localsym_t *add_ecoff_symbol PARAMS ((const char *str, st_t type,
sc_t storage, symbolS *sym,
- symint_t value,
+ bfd_vma addend, symint_t value,
symint_t indx));
static symint_t add_aux_sym_symint PARAMS ((symint_t aux_word));
static symint_t add_aux_sym_rndx PARAMS ((int file_index,
@@ -1600,11 +1602,12 @@ add_string (vp, hash_tbl, str, ret_hash)
/* Add debugging information for a symbol. */
static localsym_t *
-add_ecoff_symbol (str, type, storage, sym_value, value, indx)
+add_ecoff_symbol (str, type, storage, sym_value, addend, value, indx)
const char *str; /* symbol name */
st_t type; /* symbol type */
sc_t storage; /* storage class */
symbolS *sym_value; /* associated symbol. */
+ bfd_vma addend; /* addend to sym_value. */
symint_t value; /* value of symbol */
symint_t indx; /* index to local/aux. syms */
{
@@ -1634,6 +1637,7 @@ add_ecoff_symbol (str, type, storage, sym_value, value, indx)
psym->as_sym = sym_value;
if (sym_value != (symbolS *) NULL)
sym_value->ecoff_symbol = psym;
+ psym->addend = addend;
psym->file_ptr = cur_file_ptr;
psym->proc_ptr = cur_proc_ptr;
psym->begin_ptr = (localsym_t *) NULL;
@@ -2104,6 +2108,7 @@ add_unknown_tag (ptag)
st_Block,
sc_Info,
(symbolS *) NULL,
+ (bfd_vma) 0,
(symint_t) 0,
(symint_t) 0);
@@ -2111,6 +2116,7 @@ add_unknown_tag (ptag)
st_End,
sc_Info,
(symbolS *) NULL,
+ (bfd_vma) 0,
(symint_t) 0,
(symint_t) 0);
@@ -2157,7 +2163,8 @@ add_procedure (func)
/* Push the start of the function. */
new_proc_ptr->sym = add_ecoff_symbol ((const char *) NULL, st_Proc, sc_Text,
symbol_find_or_make (func),
- (symint_t) 0, (symint_t) 0);
+ (bfd_vma) 0, (symint_t) 0,
+ (symint_t) 0);
++proc_cnt;
@@ -2225,7 +2232,7 @@ add_file (file_name, indx, fake)
symbol_new ("L0\001", now_seg,
(valueT) frag_now_fix (),
frag_now),
- 0, ECOFF_MARK_STAB (N_SOL));
+ (bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SOL));
return;
}
@@ -2292,7 +2299,7 @@ add_file (file_name, indx, fake)
/* Push the start of the filename. We assume that the filename
will be stored at string offset 1. */
(void) add_ecoff_symbol (file_name, st_File, sc_Text,
- (symbolS *) NULL,
+ (symbolS *) NULL, (bfd_vma) 0,
(symint_t) 0, (symint_t) 0);
fil_ptr->fdr.rss = 1;
fil_ptr->name = &fil_ptr->strings.last->datum->byte[1];
@@ -2321,9 +2328,9 @@ add_file (file_name, indx, fake)
symbol_new ("L0\001", now_seg,
(valueT) frag_now_fix (),
frag_now),
- 0, ECOFF_MARK_STAB (N_SO));
+ (bfd_vma) 0, 0, ECOFF_MARK_STAB (N_SO));
(void) add_ecoff_symbol ("void:t1=1", st_Nil, sc_Nil,
- (symbolS *) NULL, 0,
+ (symbolS *) NULL, (bfd_vma) 0, 0,
ECOFF_MARK_STAB (N_LSYM));
}
#endif
@@ -2438,7 +2445,7 @@ ecoff_directive_begin (ignore)
(void) add_ecoff_symbol ((const char *) NULL, st_Block, sc_Text,
symbol_find_or_make (name),
- (symint_t) 0, (symint_t) 0);
+ (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
*input_line_pointer = name_end;
@@ -2483,7 +2490,7 @@ ecoff_directive_bend (ignore)
as_warn (".bend directive names unknown symbol");
else
(void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text, endsym,
- (symint_t) 0, (symint_t) 0);
+ (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
*input_line_pointer = name_end;
@@ -2503,7 +2510,8 @@ static st_t coff_symbol_typ;
static int coff_is_function;
static char *coff_tag;
static valueT coff_value;
-symbolS *coff_sym_value;
+static symbolS *coff_sym_value;
+static bfd_vma coff_sym_addend;
static int coff_inside_enumeration;
/* Handle a .def directive: start defining a symbol. */
@@ -2541,6 +2549,7 @@ ecoff_directive_def (ignore)
coff_tag = (char *) NULL;
coff_value = 0;
coff_sym_value = (symbolS *) NULL;
+ coff_sym_addend = 0;
}
*input_line_pointer = name_end;
@@ -2779,6 +2788,8 @@ void
ecoff_directive_val (ignore)
int ignore;
{
+ expressionS exp;
+
if (coff_sym_name == (char *) NULL)
{
as_warn (".val pseudo-op used outside of .def/.endef; ignored");
@@ -2786,26 +2797,20 @@ ecoff_directive_val (ignore)
return;
}
- if (! is_name_beginner ((unsigned char) *input_line_pointer))
- coff_value = get_absolute_expression ();
- else
+ expression (&exp);
+ if (exp.X_op != O_constant && exp.X_op != O_symbol)
{
- char *name;
- char name_end;
-
- name = input_line_pointer;
- name_end = get_symbol_end ();
-
- if (strcmp (name, ".") == 0)
- as_warn ("`.val .' not supported");
- else
- coff_sym_value = symbol_find_or_make (name);
-
- *input_line_pointer = name_end;
+ as_bad (".val expression is too copmlex");
+ demand_empty_rest_of_line ();
+ return;
+ }
- /* FIXME: gcc can generate address expressions here in unusual
- cases (search for "obscure" in sdbout.c), although this is
- very unlikely for a MIPS chip. */
+ if (exp.X_op == O_constant)
+ coff_value = exp.X_add_number;
+ else
+ {
+ coff_sym_value = exp.X_add_symbol;
+ coff_sym_addend = exp.X_add_number;
}
demand_empty_rest_of_line ();
@@ -2967,6 +2972,7 @@ ecoff_directive_endef (ignore)
coff_symbol_typ,
coff_storage_class,
coff_sym_value,
+ coff_sym_addend,
(symint_t) coff_value,
indx);
@@ -3036,10 +3042,10 @@ ecoff_directive_end (ignore)
else
{
(void) add_ecoff_symbol ((const char *) NULL, st_End, sc_Text,
- symbol_new ("L0\001", now_seg,
- (valueT) frag_now_fix (),
- frag_now),
- (symint_t) 0, (symint_t) 0);
+ symbol_new ("L0\001", now_seg,
+ (valueT) frag_now_fix (),
+ frag_now),
+ (bfd_vma) 0, (symint_t) 0, (symint_t) 0);
if (stabs_seen && generate_asm_lineno)
{
@@ -3049,7 +3055,8 @@ ecoff_directive_end (ignore)
strcpy (n, name);
strcat (n, ":F1");
(void) add_ecoff_symbol ((const char *) n, stGlobal, scText,
- ent, 0, ECOFF_MARK_STAB (N_FUN));
+ ent, (bfd_vma) 0, 0,
+ ECOFF_MARK_STAB (N_FUN));
}
}
@@ -3304,7 +3311,7 @@ ecoff_directive_loc (ignore)
symbol_new ("L0\001", now_seg,
(valueT) frag_now_fix (),
frag_now),
- 0, lineno);
+ (bfd_vma) 0, 0, lineno);
return;
}
@@ -3348,7 +3355,8 @@ mark_stabs (ignore)
stabs_seen = 1;
(void) add_ecoff_symbol (stabs_symbol, stNil, scInfo,
(symbolS *) NULL,
- (symint_t) -1, ECOFF_MARK_STAB (0));
+ (bfd_vma) 0, (symint_t) -1,
+ ECOFF_MARK_STAB (0));
}
}
@@ -3539,23 +3547,23 @@ ecoff_stab (sec, what, string, type, other, desc)
{
char *name;
char name_end;
-
- name = input_line_pointer;
- name_end = get_symbol_end ();
-
- sym = symbol_find_or_make (name);
+ expressionS exp;
sc = sc_Nil;
st = st_Nil;
value = 0;
- *input_line_pointer = name_end;
- if (name_end == '+' || name_end == '-')
+ if (string == NULL)
+ {
+ name = input_line_pointer;
+ name_end = get_symbol_end ();
+ sym = symbol_find_or_make (name);
+ *input_line_pointer = name_end;
+ }
+ else
{
- ++input_line_pointer;
- value = get_absolute_expression ();
- if (name_end == '-')
- value = - value;
+ sym = symbol_find_or_make (string);
+ expression (&sym->sy_value);
}
}
@@ -3568,7 +3576,7 @@ ecoff_stab (sec, what, string, type, other, desc)
if (sym != (symbolS *) NULL)
hold = sym->ecoff_symbol;
- (void) add_ecoff_symbol (string, st, sc, sym, value, indx);
+ (void) add_ecoff_symbol (string, st, sc, sym, (bfd_vma) 0, value, indx);
if (sym != (symbolS *) NULL)
sym->ecoff_symbol = hold;
@@ -3585,8 +3593,8 @@ ecoff_frob_symbol (sym)
symbolS *sym;
{
if (S_IS_COMMON (sym)
- && S_GET_VALUE (sym) > 0
- && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
+ && S_GET_VALUE (sym) > 0
+ && S_GET_VALUE (sym) <= bfd_get_gp_size (stdoutput))
{
static asection scom_section;
static asymbol scom_symbol;
@@ -3606,6 +3614,14 @@ ecoff_frob_symbol (sym)
}
S_SET_SEGMENT (sym, &scom_section);
}
+
+ /* Double check weak symbols. */
+ if (sym->bsym->flags & BSF_WEAK)
+ {
+ if (S_IS_COMMON (sym))
+ as_bad ("Symbol `%s' can not be both weak and common",
+ S_GET_NAME (sym));
+ }
}
/* Add bytes to the symbolic information buffer. */
@@ -3984,7 +4000,8 @@ ecoff_build_symbols (backend, buf, bufend, offset)
sym_ptr->ecoff_sym.asym.value =
(S_GET_VALUE (as_sym)
+ bfd_get_section_vma (stdoutput,
- S_GET_SEGMENT (as_sym)));
+ S_GET_SEGMENT (as_sym))
+ + sym_ptr->addend);
sym_ptr->ecoff_sym.weakext = S_IS_WEAK (as_sym);
@@ -4329,7 +4346,7 @@ ecoff_build_aux (backend, buf, bufend, offset)
long iaux;
vlinks_t *file_link;
- bigendian = stdoutput->xvec->header_byteorder_big_p;
+ bigendian = bfd_big_endian (stdoutput);
aux_out = (union aux_ext *) (*buf + offset);
@@ -4642,7 +4659,7 @@ ecoff_build_debug (hdr, bufp, backend)
cur_file_ptr = sym->ecoff_file;
add_ecoff_symbol ((const char *) NULL, st_Nil, sc_Nil, sym,
- S_GET_VALUE (sym), indexNil);
+ (bfd_vma) 0, S_GET_VALUE (sym), indexNil);
}
cur_proc_ptr = hold_proc_ptr;
cur_file_ptr = hold_file_ptr;
@@ -4670,6 +4687,7 @@ ecoff_build_debug (hdr, bufp, backend)
(void) add_ecoff_symbol ((const char *) NULL,
st_End, sc_Text,
(symbolS *) NULL,
+ (bfd_vma) 0,
(symint_t) 0,
(symint_t) 0);
}
@@ -5247,7 +5265,7 @@ generate_ecoff_stab (what, string, type, other, desc)
if (sym != (symbolS *) NULL)
hold = sym->ecoff_symbol;
- (void) add_ecoff_symbol (string, st, sc, sym, value, indx);
+ (void) add_ecoff_symbol (string, st, sc, sym, (bfd_vma) 0, value, indx);
if (sym != (symbolS *) NULL)
sym->ecoff_symbol = hold;