diff options
author | Ian Lance Taylor <ian@airs.com> | 1996-02-12 20:33:06 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@airs.com> | 1996-02-12 20:33:06 +0000 |
commit | a043f579dfeef80f68f5533144c29987d935b121 (patch) | |
tree | 78fbd2ebdae21c7d9980c29d6506c497e82de219 /gas/write.c | |
parent | 0e1ad456ce784bccd351002d31f47b8564559161 (diff) | |
download | gdb-a043f579dfeef80f68f5533144c29987d935b121.zip gdb-a043f579dfeef80f68f5533144c29987d935b121.tar.gz gdb-a043f579dfeef80f68f5533144c29987d935b121.tar.bz2 |
Mon Feb 12 15:16:29 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Support for OBJ_ELF on m68k, mostly inside #ifdef OBJ_ELF:
* config/m68k-parse.h (enum pic_relocation): Define.
(struct m68k_exp): Add pic_reloc field.
* config/tc-m68k.h (TC_RELOC_RTSYM_LOC_FIXUP): Define.
(tc_fix_adjustable): Define to call tc_m68k_fix_adjustable.
(NO_RELOC): Define to BFD_RELOC_NONE if BFD_ASSEMBLER, to zero
otherwise.
* config/tc-m68k.c: Delete definition of NO_RELOC.
(struct m68k_it): Add pic_reloc field.
(add_fix): Copy over pic_reloc field.
(md_pseudo_table): Interpret .align parameter as byte count.
(mote_pseudo_table): Likewise.
(tc_m68k_fix_adjustable): New function.
(get_reloc_code): New function.
(md_assemble): Use it as last argument to fix_new_exp.
(md_apply_fix_2): For a relocation against a symbol don't put the
addend into the data.
(tc_gen_reloc): Different addend computation for OBJ_ELF.
(m68k_ip): Don't relax an operand that requires pic relocation.
(md_begin): Align .text, .data and .bss on 4 byte boundary by
default.
* write.c (fixup_segment): Don't add symbol value to addend if
TC_M68K and OBJ_ELF.
* config/m68k-parse.y (yylex): Handle @PLTPC, etc.
(motorola_operand): Add rule for `(zapc, EXPR)'.
Diffstat (limited to 'gas/write.c')
-rw-r--r-- | gas/write.c | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/gas/write.c b/gas/write.c index 91871da..97df4fb 100644 --- a/gas/write.c +++ b/gas/write.c @@ -1,5 +1,5 @@ /* write.c - emit .o file - Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 1995 + Copyright (C) 1986, 87, 90, 91, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. This file is part of GAS, the GNU Assembler. @@ -94,6 +94,8 @@ int magic_number_for_object_file = DEFAULT_MAGIC_NUMBER_FOR_OBJECT_FILE; #endif /* BFD_ASSEMBLER */ +static int n_fixups; + #ifdef BFD_ASSEMBLER static fixS *fix_new_internal PARAMS ((fragS *, int where, int size, symbolS *add, symbolS *sub, @@ -133,6 +135,8 @@ fix_new_internal (frag, where, size, add_symbol, sub_symbol, offset, pcrel, { fixS *fixP; + n_fixups++; + fixP = (fixS *) obstack_alloc (¬es, sizeof (fixS)); fixP->fx_frag = frag; @@ -799,12 +803,23 @@ write_relocs (abfd, sec, xxx) { arelent *reloc; bfd_reloc_status_type s; + symbolS *sym; if (fixp->fx_done) { n--; continue; } + + /* If this is an undefined symbol which was equated to another + symbol, then use generate the reloc against the latter symbol + rather than the former. */ + sym = fixp->fx_addsy; + while (sym->sy_value.X_op == O_symbol + && (! S_IS_DEFINED (sym) || S_IS_COMMON (sym))) + sym = sym->sy_value.X_add_symbol; + fixp->fx_addsy = sym; + reloc = tc_gen_reloc (sec, fixp); if (!reloc) { @@ -844,6 +859,7 @@ write_relocs (abfd, sec, xxx) arelent **reloc; char *data; bfd_reloc_status_type s; + symbolS *sym; int j; if (fixp->fx_done) @@ -851,6 +867,16 @@ write_relocs (abfd, sec, xxx) n--; continue; } + + /* If this is an undefined symbol which was equated to another + symbol, then use generate the reloc against the latter symbol + rather than the former. */ + sym = fixp->fx_addsy; + while (sym->sy_value.X_op == O_symbol + && (! S_IS_DEFINED (sym) || S_IS_COMMON (sym))) + sym = sym->sy_value.X_add_symbol; + fixp->fx_addsy = sym; + reloc = tc_gen_reloc (sec, fixp); for (j = 0; reloc[j]; j++) @@ -1642,6 +1668,15 @@ write_object_file () resolve_symbol_value (symp); } + /* Skip symbols which were equated to undefined or common + symbols. */ + if (symp->sy_value.X_op == O_symbol + && (! S_IS_DEFINED (symp) || S_IS_COMMON (symp))) + { + symbol_remove (symp, &symbol_rootP, &symbol_lastP); + continue; + } + /* So far, common symbols have been treated like undefined symbols. Put them in the common section now. */ if (S_IS_DEFINED (symp) == 0 @@ -1703,6 +1738,9 @@ write_object_file () /* Now do any format-specific adjustments to the symbol table, such as adding file symbols. */ +#ifdef tc_adjust_symtab + tc_adjust_symtab (); +#endif #ifdef obj_adjust_symtab obj_adjust_symtab (); #endif @@ -2402,9 +2440,11 @@ fixup_segment (fixP, this_segment_type) else { seg_reloc_count++; +#if !(defined (TC_M68K) && defined (OBJ_ELF)) #if !defined (TC_I386) || !(defined (OBJ_ELF) || defined (OBJ_COFF)) add_number += S_GET_VALUE (add_symbolP); #endif +#endif } } } @@ -2531,6 +2571,13 @@ number_to_chars_littleendian (buf, val, n) } } +void +write_print_statistics (file) + FILE *file; +{ + fprintf (stderr, "fixups: %d\n", n_fixups); +} + /* for debugging */ extern int indent_level; extern void print_symbol_value_1 (); |