Move struc-symbol.h to symbols.c

This file was never supposed to be widely used.  The fact that it has
found its way into many gas files led to bugs, typically when code
expecting a symbolS* to point at a struct symbol is presented with a
struct local_symbol.  Also, commit 158184ac9e changed these structs in
2012 but didn't catch all places where symbol bsym was being used to
test for a local_symbol.

	* Makefile.am (HFILES): Delete struc-symbol.h.
	* doc/internals.texi: Delete struc-symbol.h reference and out
	of date local symbol description.
	* struc-symbol.h: Delete.  Move contents to..
	* symbols.c: ..here.
	(symbol_on_chain, symbol_symbolS): New functions.
	* symbols.h (symbol_on_chain, symbol_symbolS): Declare.
	* cgen.c: Don't #include struc-symbol.h.
	(gas_cgen_parse_operand): Don't test for local_symbol using
	bsym, instead call symbol_symbolS.  Use symbol_get_bfdsym.
	(weak_operand_overflow_check, make_right_shifted_expr): Use
	symbol accessors.
	* config/obj-coff.c: Don't #include struc-symbol.h.
	(GET_FILENAME_STRING): Delete.
	* config/obj-elf.c: Don't #include struc-symbol.h.
	(elf_file_symbol): Use symbol accessors.
	(elf_adjust_symtab): Call symbol_on_chain.
	* config/obj-evax.c: Don't #include struc-symbol.h.
	* config/tc-nds32.c: Likewise.
	* config/tc-rl78.c: Likewise.
	* config/tc-rx.c: Likewise.
	* config/tc-alpha.c: Likewise.
	(add_to_link_pool, s_alpha_comm): Use symbol accessors.
	* config/tc-arc.c: Don't #include struc-symbol.h.
	(arc_check_relocs): Use symbol accessors, testing gas symbol
	section rather than bfd symbol section.
	* config/tc-avr.c: Don't #include struc-symbol.h.
	(avr_patch_gccisr_frag): Use symbol accessors.
	* config/tc-bfin.c: Don't #include struc-symbol.h.
	(bfin_loop_beginend): Use symbol accessors.
	* config/tc-csky.c: Don't #include struc-symbol.h.
	(v2_work_movih, v2_work_ori): Use symbol accessors.  Check for
	absolute symbol as well as O_constant.
	* config/tc-riscv.c: Don't #include struc-symbol.h.
	(riscv_pre_output_hook): Use symbol accessors.
	* config/tc-s390.c: Don't #include struc-symbol.h.
	(s390_literals): Use symbol accessors.
	* config/tc-score.c (s3_build_la_pic, s3_build_lwst_pic): Use
	symbol accessors.
	(s3_relax_branch_inst16, s3_relax_cmpbranch_inst32): Don't
	test symbol bsym.
	* config/tc-score7.c: Don't #include struc-symbol.h.
	(s7_build_la_pic, s7_build_lwst_pic): Use symbol accessors.
	(s7_b32_relax_to_b16): Don't test symbol bsym.
	* config/tc-sh.c: Don't #include struc-symbol.h.
	(insert_loop_bounds): Use symbol accessors.
	(sh_frob_section): Remove bogus symbol canonicalization.
	* config/tc-tic54x.c: Don't #include struc-symbol.h.
	(tic54x_bss): Use symbol accessors.
	* config/tc-tilegx.c: Don't #include struc-symbol.h.
	(emit_tilegx_instruction, tilegx_parse_name): Use symbol accessors.
	* config/tc-tilepro.c: Don't #include struc-symbol.h.
	(emit_tilepro_instruction, tilepro_parse_name): Use accessors.
	* config/tc-xtensa.c: Don't #include struc-symbol.h.
	(xg_assemble_vliw_tokens): Use symbol accessors.
	(xg_order_trampoline_chain): Likewise.
	* ehopt.c: Don't #include struc-symbol.h.
	(check_eh_frame): Correct local symbol test.  Use symbol accessors.
	* write.c: Don't #include struc-symbol.h.
	(create_note_reloc, maybe_generate_build_notes): Use symbol accessors.
	* Makefile.in: Regenerate.
	* po/POTFILES.in: Regenerate.
This commit is contained in:
Alan Modra 2018-10-29 16:37:24 +10:30
parent c2e863866d
commit 8d1015a887
31 changed files with 353 additions and 326 deletions

View File

@ -1,3 +1,68 @@
2018-10-29 Alan Modra <amodra@gmail.com>
* Makefile.am (HFILES): Delete struc-symbol.h.
* doc/internals.texi: Delete struc-symbol.h reference and out
of date local symbol description.
* struc-symbol.h: Delete. Move contents to..
* symbols.c: ..here.
(symbol_on_chain, symbol_symbolS): New functions.
* symbols.h (symbol_on_chain, symbol_symbolS): Declare.
* cgen.c: Don't #include struc-symbol.h.
(gas_cgen_parse_operand): Don't test for local_symbol using
bsym, instead call symbol_symbolS. Use symbol_get_bfdsym.
(weak_operand_overflow_check, make_right_shifted_expr): Use
symbol accessors.
* config/obj-coff.c: Don't #include struc-symbol.h.
(GET_FILENAME_STRING): Delete.
* config/obj-elf.c: Don't #include struc-symbol.h.
(elf_file_symbol): Use symbol accessors.
(elf_adjust_symtab): Call symbol_on_chain.
* config/obj-evax.c: Don't #include struc-symbol.h.
* config/tc-nds32.c: Likewise.
* config/tc-rl78.c: Likewise.
* config/tc-rx.c: Likewise.
* config/tc-alpha.c: Likewise.
(add_to_link_pool, s_alpha_comm): Use symbol accessors.
* config/tc-arc.c: Don't #include struc-symbol.h.
(arc_check_relocs): Use symbol accessors, testing gas symbol
section rather than bfd symbol section.
* config/tc-avr.c: Don't #include struc-symbol.h.
(avr_patch_gccisr_frag): Use symbol accessors.
* config/tc-bfin.c: Don't #include struc-symbol.h.
(bfin_loop_beginend): Use symbol accessors.
* config/tc-csky.c: Don't #include struc-symbol.h.
(v2_work_movih, v2_work_ori): Use symbol accessors. Check for
absolute symbol as well as O_constant.
* config/tc-riscv.c: Don't #include struc-symbol.h.
(riscv_pre_output_hook): Use symbol accessors.
* config/tc-s390.c: Don't #include struc-symbol.h.
(s390_literals): Use symbol accessors.
* config/tc-score.c (s3_build_la_pic, s3_build_lwst_pic): Use
symbol accessors.
(s3_relax_branch_inst16, s3_relax_cmpbranch_inst32): Don't
test symbol bsym.
* config/tc-score7.c: Don't #include struc-symbol.h.
(s7_build_la_pic, s7_build_lwst_pic): Use symbol accessors.
(s7_b32_relax_to_b16): Don't test symbol bsym.
* config/tc-sh.c: Don't #include struc-symbol.h.
(insert_loop_bounds): Use symbol accessors.
(sh_frob_section): Remove bogus symbol canonicalization.
* config/tc-tic54x.c: Don't #include struc-symbol.h.
(tic54x_bss): Use symbol accessors.
* config/tc-tilegx.c: Don't #include struc-symbol.h.
(emit_tilegx_instruction, tilegx_parse_name): Use symbol accessors.
* config/tc-tilepro.c: Don't #include struc-symbol.h.
(emit_tilepro_instruction, tilepro_parse_name): Use accessors.
* config/tc-xtensa.c: Don't #include struc-symbol.h.
(xg_assemble_vliw_tokens): Use symbol accessors.
(xg_order_trampoline_chain): Likewise.
* ehopt.c: Don't #include struc-symbol.h.
(check_eh_frame): Correct local symbol test. Use symbol accessors.
* write.c: Don't #include struc-symbol.h.
(create_note_reloc, maybe_generate_build_notes): Use symbol accessors.
* Makefile.in: Regenerate.
* po/POTFILES.in: Regenerate.
2018-10-28 Alan Modra <amodra@gmail.com>
PR 23837

View File

@ -120,7 +120,6 @@ HFILES = \
output-file.h \
read.h \
sb.h \
struc-symbol.h \
subsegs.h \
symbols.h \
tc.h \

View File

@ -509,7 +509,6 @@ HFILES = \
output-file.h \
read.h \
sb.h \
struc-symbol.h \
subsegs.h \
symbols.h \
tc.h \

View File

@ -26,7 +26,6 @@
#include "dwarf2dbg.h"
#include "symbols.h"
#include "struc-symbol.h"
#ifdef OBJ_COMPLEX_RELC
static expressionS * make_right_shifted_expr
@ -416,6 +415,8 @@ gas_cgen_parse_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
if (! errmsg)
{
asymbol *bsym;
/* Fragment the expression as necessary, and queue a reloc. */
memset (& dummy_fixup, 0, sizeof (fixS));
@ -423,11 +424,12 @@ gas_cgen_parse_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
if (exp.X_op == O_symbol
&& reloc_type == BFD_RELOC_RELC
&& exp.X_add_symbol->sy_value.X_op == O_constant
&& (!exp.X_add_symbol->bsym
|| (exp.X_add_symbol->bsym->section != expr_section
&& exp.X_add_symbol->bsym->section != absolute_section
&& exp.X_add_symbol->bsym->section != undefined_section)))
&& symbol_constant_p (exp.X_add_symbol)
&& (!symbol_symbolS (exp.X_add_symbol)
|| (bsym = symbol_get_bfdsym (exp.X_add_symbol)) == NULL
|| (bsym->section != expr_section
&& bsym->section != absolute_section
&& bsym->section != undefined_section)))
{
/* Local labels will have been (eagerly) turned into constants
by now, due to the inappropriately deep insight of the
@ -455,13 +457,15 @@ gas_cgen_parse_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED,
if (operand && (operand->hw_type == HW_H_SINT))
signed_p = 1;
if (stmp->bsym && (stmp->bsym->section == expr_section)
if (symbol_symbolS (stmp)
&& (bsym = symbol_get_bfdsym (stmp)) != NULL
&& bsym->section == expr_section
&& ! S_IS_LOCAL (stmp))
{
if (signed_p)
stmp->bsym->flags |= BSF_SRELC;
bsym->flags |= BSF_SRELC;
else
stmp->bsym->flags |= BSF_RELC;
bsym->flags |= BSF_RELC;
}
/* Now package it all up for the fixup emitter. */
@ -771,12 +775,12 @@ weak_operand_overflow_check (const expressionS * exp,
mask = exp->X_add_number;
if (exp->X_add_symbol
&& exp->X_add_symbol->sy_value.X_op == O_constant)
mask |= exp->X_add_symbol->sy_value.X_add_number;
&& symbol_constant_p (exp->X_add_symbol))
mask |= *symbol_X_add_number (exp->X_add_symbol);
if (exp->X_op_symbol
&& exp->X_op_symbol->sy_value.X_op == O_constant)
mask |= exp->X_op_symbol->sy_value.X_add_number;
&& symbol_constant_p (exp->X_op_symbol))
mask |= *symbol_X_add_number (exp->X_op_symbol);
/* Want to know if mask covers more bits than opmask.
this is the same as asking if mask has any bits not in opmask,
@ -800,15 +804,17 @@ make_right_shifted_expr (expressionS * exp,
{
symbolS * stmp = 0;
expressionS * new_exp;
asymbol *bsym;
stmp = expr_build_binary (O_right_shift,
make_expr_symbol (exp),
expr_build_uconstant (amount));
bsym = symbol_get_bfdsym (stmp);
if (signed_p)
stmp->bsym->flags |= BSF_SRELC;
bsym->flags |= BSF_SRELC;
else
stmp->bsym->flags |= BSF_RELC;
bsym->flags |= BSF_RELC;
/* Then wrap that in a "symbol expr" for good measure. */
new_exp = XNEW (expressionS);

View File

@ -23,7 +23,6 @@
#include "as.h"
#include "safe-ctype.h"
#include "subsegs.h"
#include "struc-symbol.h"
#ifdef TE_PE
#include "coff/pe.h"
@ -236,9 +235,6 @@ obj_coff_comm (int ignore ATTRIBUTE_UNUSED)
}
#endif /* TE_PE */
#define GET_FILENAME_STRING(X) \
((char *) (&((X)->sy_symbol.ost_auxent->x_file.x_n.x_offset))[1])
/* @@ Ick. */
static segT
fetch_coff_debug_section (void)

View File

@ -23,7 +23,6 @@
#include "safe-ctype.h"
#include "subsegs.h"
#include "obstack.h"
#include "struc-symbol.h"
#include "dwarf2dbg.h"
#ifndef ECOFF_DEBUGGING
@ -261,10 +260,12 @@ elf_sec_sym_ok_for_reloc (asection *sec)
void
elf_file_symbol (const char *s, int appfile)
{
asymbol *bsym;
if (!appfile
|| symbol_rootP == NULL
|| symbol_rootP->bsym == NULL
|| (symbol_rootP->bsym->flags & BSF_FILE) == 0)
|| (bsym = symbol_get_bfdsym (symbol_rootP)) == NULL
|| (bsym->flags & BSF_FILE) == 0)
{
symbolS *sym;
size_t name_length;
@ -284,8 +285,8 @@ elf_file_symbol (const char *s, int appfile)
symbol_get_bfdsym (sym)->flags |= BSF_FILE;
if (symbol_rootP != sym
&& (symbol_rootP->bsym == NULL
|| !(symbol_rootP->bsym->flags & BSF_FILE)))
&& ((bsym = symbol_get_bfdsym (symbol_rootP)) == NULL
|| (bsym->flags & BSF_FILE) == 0))
{
symbol_remove (sym, &symbol_rootP, &symbol_lastP);
symbol_insert (sym, symbol_rootP, &symbol_rootP, &symbol_lastP);
@ -2469,11 +2470,7 @@ elf_adjust_symtab (void)
/* Make sure that the signature symbol for the group has the
name of the group. */
sy = symbol_find_exact (group_name);
if (!sy
|| (sy != symbol_lastP
&& (sy->sy_flags.sy_local_symbol
|| sy->sy_next == NULL
|| sy->sy_next->sy_previous != sy)))
if (!sy || !symbol_on_chain (sy, symbol_rootP, symbol_lastP))
{
/* Create the symbol now. */
sy = symbol_new (group_name, now_seg, (valueT) 0, frag_now);

View File

@ -27,7 +27,6 @@
#include "bfd.h"
#include "vms.h"
#include "subsegs.h"
#include "struc-symbol.h"
#include "safe-ctype.h"
static void s_evax_weak (int);

View File

@ -49,7 +49,6 @@
#include "as.h"
#include "subsegs.h"
#include "struc-symbol.h"
#include "ecoff.h"
#include "opcode/alpha.h"
@ -3400,7 +3399,9 @@ add_to_link_pool (symbolS *sym, offsetT addend)
&& fixp->fx_offset == (valueT)addend
&& fixp->tc_fix_data.info
&& fixp->tc_fix_data.info->sym
&& fixp->tc_fix_data.info->sym->sy_value.X_op_symbol == basesym)
&& symbol_symbolS (fixp->tc_fix_data.info->sym)
&& (symbol_get_value_expression (fixp->tc_fix_data.info->sym)
->X_op_symbol == basesym))
return fixp->tc_fix_data.info->sym;
}
@ -3628,7 +3629,7 @@ s_alpha_comm (int ignore ATTRIBUTE_UNUSED)
}
#ifndef OBJ_EVAX
know (symbolP->sy_frag == &zero_address_frag);
know (symbol_get_frag (symbolP) == &zero_address_frag);
#endif
demand_empty_rest_of_line ();
}

View File

@ -22,7 +22,6 @@
#include "as.h"
#include "subsegs.h"
#include "struc-symbol.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "safe-ctype.h"
@ -4211,7 +4210,7 @@ arc_check_reloc (expressionS *exp,
if (*r_type_p == BFD_RELOC_32
&& exp->X_op == O_subtract
&& exp->X_op_symbol != NULL
&& exp->X_op_symbol->bsym->section == now_seg)
&& S_GET_SEGMENT (exp->X_op_symbol) == now_seg)
*r_type_p = BFD_RELOC_ARC_32_PCREL;
}

View File

@ -23,7 +23,6 @@
#include "as.h"
#include "safe-ctype.h"
#include "subsegs.h"
#include "struc-symbol.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "elf/avr.h"
@ -2628,8 +2627,7 @@ avr_patch_gccisr_frag (fragS *fr, int reg)
symbolS *sy = avr_isr.sym_n_pushed;
/* Turn magic `__gcc_isr.n_pushed' into its now known value. */
sy->sy_value.X_op = O_constant;
sy->sy_value.X_add_number = n_pushed;
S_SET_VALUE (sy, n_pushed);
S_SET_SEGMENT (sy, expr_section);
avr_isr.sym_n_pushed = NULL;
}

View File

@ -19,7 +19,6 @@
02110-1301, USA. */
#include "as.h"
#include "struc-symbol.h"
#include "bfin-defs.h"
#include "obstack.h"
#include "safe-ctype.h"
@ -1930,7 +1929,7 @@ bfin_loop_beginend (Expr_Node *exp, int begin)
/* LOOP_END follows the last instruction in the loop.
Adjust label address. */
if (!begin)
((struct local_symbol *) linelabel)->lsy_value -= last_insn_size;
*symbol_X_add_number (linelabel) -= last_insn_size;
}
bfd_boolean

View File

@ -29,7 +29,6 @@
#include "subsegs.h"
#include "obstack.h"
#include "libiberty.h"
#include "struc-symbol.h"
#ifdef OBJ_ELF
#include "elf/csky.h"
@ -6783,8 +6782,9 @@ v2_work_movih (void)
|| (csky_insn.e1.X_op == O_symbol && insn_reloc != BFD_RELOC_NONE))
{
if (csky_insn.e1.X_op_symbol != 0
&& csky_insn.e1.X_op_symbol->sy_value.X_op == O_constant
&& 16 == csky_insn.e1.X_op_symbol->sy_value.X_add_number)
&& symbol_constant_p (csky_insn.e1.X_op_symbol)
&& S_GET_SEGMENT (csky_insn.e1.X_op_symbol) == absolute_section
&& 16 == S_GET_VALUE (csky_insn.e1.X_op_symbol))
{
csky_insn.e1.X_op = O_symbol;
if (insn_reloc == BFD_RELOC_CKCORE_GOT32)
@ -6833,8 +6833,9 @@ v2_work_ori (void)
}
else if (csky_insn.e1.X_op == O_bit_and)
{
if (csky_insn.e1.X_op_symbol->sy_value.X_op == O_constant
&& 0xffff == csky_insn.e1.X_op_symbol->sy_value.X_add_number)
if (symbol_constant_p (csky_insn.e1.X_op_symbol)
&& S_GET_SEGMENT (csky_insn.e1.X_op_symbol) == absolute_section
&& 0xffff == S_GET_VALUE (csky_insn.e1.X_op_symbol))
{
csky_insn.e1.X_op = O_symbol;
if (insn_reloc == BFD_RELOC_CKCORE_GOT32)

View File

@ -31,7 +31,6 @@
#include "hash.h"
#include "sb.h"
#include "macro.h"
#include "struc-symbol.h"
#include "opcode/nds32.h"
#include <stdio.h>

View File

@ -28,7 +28,6 @@
#include "itbl-ops.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "struc-symbol.h"
#include "elf/riscv.h"
#include "opcode/riscv.h"
@ -2620,14 +2619,13 @@ riscv_pre_output_hook (void)
if (frag->fr_type == rs_cfa)
{
expressionS exp;
expressionS *symval;
symbolS *add_symbol = frag->fr_symbol->sy_value.X_add_symbol;
symbolS *op_symbol = frag->fr_symbol->sy_value.X_op_symbol;
symval = symbol_get_value_expression (frag->fr_symbol);
exp.X_op = O_subtract;
exp.X_add_symbol = add_symbol;
exp.X_add_symbol = symval->X_add_symbol;
exp.X_add_number = 0;
exp.X_op_symbol = op_symbol;
exp.X_op_symbol = symval->X_op_symbol;
fix_new_exp (frag, (int) frag->fr_offset, 1, &exp, 0,
BFD_RELOC_RISCV_CFA);

View File

@ -19,7 +19,6 @@
02110-1301, USA. */
#include "as.h"
#include "struc-symbol.h"
#include "safe-ctype.h"
#include "dwarf2dbg.h"
#include "elf/common.h"

View File

@ -19,7 +19,6 @@
02110-1301, USA. */
#include "as.h"
#include "struc-symbol.h"
#include "safe-ctype.h"
#include "dwarf2dbg.h"
#include "elf/common.h"

View File

@ -22,7 +22,6 @@
#include "as.h"
#include "safe-ctype.h"
#include "subsegs.h"
#include "struc-symbol.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
@ -1858,7 +1857,7 @@ s390_literals (int ignore ATTRIBUTE_UNUSED)
/* Emit symbol for start of literal pool. */
S_SET_SEGMENT (lp_sym, now_seg);
S_SET_VALUE (lp_sym, (valueT) frag_now_fix ());
lp_sym->sy_frag = frag_now;
symbol_set_frag (lp_sym, frag_now);
while (lpe_list)
{
@ -1866,7 +1865,7 @@ s390_literals (int ignore ATTRIBUTE_UNUSED)
lpe_list = lpe_list->next;
S_SET_SEGMENT (lpe->sym, now_seg);
S_SET_VALUE (lpe->sym, (valueT) frag_now_fix ());
lpe->sym->sy_frag = frag_now;
symbol_set_frag (lpe->sym, frag_now);
/* Emit literal pool entry. */
if (lpe->reloc != BFD_RELOC_UNUSED)

View File

@ -4096,7 +4096,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
/* Fix part
For an external symbol: lw rD, <sym>($gp)
(BFD_RELOC_SCORE_GOT15 or BFD_RELOC_SCORE_CALL15) */
sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
return;
@ -4110,7 +4110,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
addi rD, <sym> (BFD_RELOC_GOT_LO16) */
s3_inst.reloc.type = BFD_RELOC_SCORE_GOT15;
memcpy (&var_insts[0], &s3_inst, sizeof (struct s3_score_it));
sprintf (tmp, "addi_s_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "addi_s_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
return;
@ -4120,7 +4120,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
else if (add_number >= -0x8000 && add_number <= 0x7fff)
{
/* Insn 1: lw rD, <sym>($gp) (BFD_RELOC_SCORE_GOT15) */
sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s3_append_insn (tmp, TRUE) == (int) s3_FAIL)
return;
@ -4137,7 +4137,8 @@ s3_build_la_pic (int reg_rd, expressionS exp)
/* Var part
For a local symbol: addi rD, <sym>+<constant> (BFD_RELOC_GOT_LO16) */
sprintf (tmp, "addi_s_pic r%d, %s + %d", reg_rd, add_symbol->bsym->name, (int)add_number);
sprintf (tmp, "addi_s_pic r%d, %s + %d", reg_rd,
S_GET_NAME (add_symbol), (int) add_number);
if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
return;
@ -4150,7 +4151,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
int lo = add_number & 0x0000FFFF;
/* Insn 1: lw rD, <sym>($gp) (BFD_RELOC_SCORE_GOT15) */
sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s3_append_insn (tmp, TRUE) == (int) s3_FAIL)
return;
@ -4192,7 +4193,7 @@ s3_build_la_pic (int reg_rd, expressionS exp)
/* Var part
For a local symbol: addi r1, <sym>+LO%<constant> (BFD_RELOC_GOT_LO16) */
sprintf (tmp, "addi_u_pic r1, %s + %d", add_symbol->bsym->name, lo);
sprintf (tmp, "addi_u_pic r1, %s + %d", S_GET_NAME (add_symbol), lo);
if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
return;
@ -4860,7 +4861,7 @@ s3_build_lwst_pic (int reg_rd, expressionS exp, const char *insn_name)
/* Fix part
For an external symbol: lw rD, <sym>($gp)
(BFD_RELOC_SCORE_GOT15) */
sprintf (tmp, "lw_pic r1, %s", add_symbol->bsym->name);
sprintf (tmp, "lw_pic r1, %s", S_GET_NAME (add_symbol));
if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
return;
@ -4872,7 +4873,7 @@ s3_build_lwst_pic (int reg_rd, expressionS exp, const char *insn_name)
addi rD, <sym> (BFD_RELOC_GOT_LO16) */
s3_inst.reloc.type = BFD_RELOC_SCORE_GOT15;
memcpy (&var_insts[0], &s3_inst, sizeof (struct s3_score_it));
sprintf (tmp, "addi_s_pic r1, %s", add_symbol->bsym->name);
sprintf (tmp, "addi_s_pic r1, %s", S_GET_NAME (add_symbol));
if (s3_append_insn (tmp, FALSE) == (int) s3_FAIL)
return;
@ -6847,10 +6848,7 @@ s3_relax_branch_inst16 (fragS * fragp)
if (s == NULL)
frag_addr = 0;
else
{
if (s->bsym != NULL)
symbol_address = (addressT) symbol_get_frag (s)->fr_address;
}
symbol_address = (addressT) symbol_get_frag (s)->fr_address;
inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN16_SIZE);
offset = (inst_value & 0x1ff) << 1;
@ -6862,7 +6860,6 @@ s3_relax_branch_inst16 (fragS * fragp)
if (relaxable_p
&& (!((value & 0xfffffe00) == 0 || (value & 0xfffffe00) == 0xfffffe00))
&& fragp->fr_fix == 2
&& (s->bsym != NULL)
&& (S_IS_DEFINED (s)
&& !S_IS_COMMON (s)
&& !S_IS_EXTERNAL (s)))
@ -6894,10 +6891,7 @@ s3_relax_cmpbranch_inst32 (fragS * fragp)
if (s == NULL)
frag_addr = 0;
else
{
if (s->bsym != NULL)
symbol_address = (addressT) symbol_get_frag (s)->fr_address;
}
symbol_address = (addressT) symbol_get_frag (s)->fr_address;
inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN_SIZE);
offset = (inst_value & 0x1)
@ -6921,8 +6915,7 @@ s3_relax_cmpbranch_inst32 (fragS * fragp)
/* need to translate when extern or not defined or common symbol */
else if ((relaxable_p
&& (!((value & 0xfffffe00) == 0 || (value & 0xfffffe00) == 0xfffffe00))
&& fragp->fr_fix == 4
&& (s->bsym != NULL))
&& fragp->fr_fix == 4)
|| !S_IS_DEFINED (s)
||S_IS_COMMON (s)
||S_IS_EXTERNAL (s))

View File

@ -27,7 +27,6 @@
#include "subsegs.h"
#include "safe-ctype.h"
#include "opcode/score-inst.h"
#include "struc-symbol.h"
#include "libiberty.h"
#ifdef OBJ_ELF
@ -4200,7 +4199,7 @@ s7_build_la_pic (int reg_rd, expressionS exp)
/* Fix part
For an external symbol: lw rD, <sym>($gp)
(BFD_RELOC_SCORE_GOT15 or BFD_RELOC_SCORE_CALL15) */
sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s7_append_insn (tmp, FALSE) == (int) s7_FAIL)
return;
@ -4214,7 +4213,7 @@ s7_build_la_pic (int reg_rd, expressionS exp)
addi rD, <sym> (BFD_RELOC_GOT_LO16) */
s7_inst.reloc.type = BFD_RELOC_SCORE_GOT15;
memcpy (&var_insts[0], &s7_inst, sizeof (struct s7_score_it));
sprintf (tmp, "addi_s_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "addi_s_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s7_append_insn (tmp, FALSE) == (int) s7_FAIL)
return;
@ -4224,7 +4223,7 @@ s7_build_la_pic (int reg_rd, expressionS exp)
else if (add_number >= -0x8000 && add_number <= 0x7fff)
{
/* Insn 1: lw rD, <sym>($gp) (BFD_RELOC_SCORE_GOT15) */
sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s7_append_insn (tmp, TRUE) == (int) s7_FAIL)
return;
@ -4241,7 +4240,8 @@ s7_build_la_pic (int reg_rd, expressionS exp)
/* Var part
For a local symbol: addi rD, <sym>+<constant> (BFD_RELOC_GOT_LO16) */
sprintf (tmp, "addi_s_pic r%d, %s + %d", reg_rd, add_symbol->bsym->name, (int) add_number);
sprintf (tmp, "addi_s_pic r%d, %s + %d", reg_rd,
S_GET_NAME (add_symbol), (int) add_number);
if (s7_append_insn (tmp, FALSE) == (int) s7_FAIL)
return;
@ -4254,7 +4254,7 @@ s7_build_la_pic (int reg_rd, expressionS exp)
int lo = add_number & 0x0000FFFF;
/* Insn 1: lw rD, <sym>($gp) (BFD_RELOC_SCORE_GOT15) */
sprintf (tmp, "lw_pic r%d, %s", reg_rd, add_symbol->bsym->name);
sprintf (tmp, "lw_pic r%d, %s", reg_rd, S_GET_NAME (add_symbol));
if (s7_append_insn (tmp, TRUE) == (int) s7_FAIL)
return;
@ -4296,7 +4296,7 @@ s7_build_la_pic (int reg_rd, expressionS exp)
/* Var part
For a local symbol: addi r1, <sym>+LO%<constant> (BFD_RELOC_GOT_LO16) */
sprintf (tmp, "addi_u_pic r1, %s + %d", add_symbol->bsym->name, lo);
sprintf (tmp, "addi_u_pic r1, %s + %d", S_GET_NAME (add_symbol), lo);
if (s7_append_insn (tmp, FALSE) == (int) s7_FAIL)
return;
@ -4661,7 +4661,7 @@ s7_build_lwst_pic (int reg_rd, expressionS exp, const char *insn_name)
/* Fix part
For an external symbol: lw rD, <sym>($gp)
(BFD_RELOC_SCORE_GOT15) */
sprintf (tmp, "lw_pic r1, %s", add_symbol->bsym->name);
sprintf (tmp, "lw_pic r1, %s", S_GET_NAME (add_symbol));
if (s7_append_insn (tmp, FALSE) == (int) s7_FAIL)
return;
@ -4673,7 +4673,7 @@ s7_build_lwst_pic (int reg_rd, expressionS exp, const char *insn_name)
addi rD, <sym> (BFD_RELOC_GOT_LO16) */
s7_inst.reloc.type = BFD_RELOC_SCORE_GOT15;
memcpy (&var_insts[0], &s7_inst, sizeof (struct s7_score_it));
sprintf (tmp, "addi_s_pic r1, %s", add_symbol->bsym->name);
sprintf (tmp, "addi_s_pic r1, %s", S_GET_NAME (add_symbol));
if (s7_append_insn (tmp, FALSE) == (int) s7_FAIL)
return;
@ -5263,10 +5263,7 @@ s7_b32_relax_to_b16 (fragS * fragp)
if (s == NULL)
frag_addr = 0;
else
{
if (s->bsym != NULL)
symbol_address = (addressT) symbol_get_frag (s)->fr_address;
}
symbol_address = (addressT) symbol_get_frag (s)->fr_address;
value = s7_md_chars_to_number (fragp->fr_literal, s7_INSN_SIZE);
@ -5280,7 +5277,7 @@ s7_b32_relax_to_b16 (fragS * fragp)
abs_value = 0xffffffff - abs_value + 1;
/* Relax branch 32 to branch 16. */
if (relaxable_p && (s->bsym != NULL) && ((abs_value & 0xffffff00) == 0)
if (relaxable_p && ((abs_value & 0xffffff00) == 0)
&& (S_IS_DEFINED (s) && !S_IS_COMMON (s) && !S_IS_EXTERNAL (s)))
{
/* do nothing. */

View File

@ -25,7 +25,6 @@
#define DEFINE_TABLE
#include "opcodes/sh-opc.h"
#include "safe-ctype.h"
#include "struc-symbol.h"
#ifdef OBJ_ELF
#include "elf/sh.h"
@ -1911,6 +1910,7 @@ insert_loop_bounds (char *output, sh_operand_info *operand)
{
static int count = 0;
char name[11];
expressionS *symval;
/* If the last loop insn is a two-byte-insn, it is in danger of being
swapped with the insn after it. To prevent this, create a new
@ -1926,8 +1926,9 @@ insert_loop_bounds (char *output, sh_operand_info *operand)
SF_SET_LOCAL (end_sym);
#endif /* OBJ_COFF */
symbol_table_insert (end_sym);
end_sym->sy_value = operand[1].immediate;
end_sym->sy_value.X_add_number += 2;
symval = symbol_get_value_expression (end_sym);
*symval = operand[1].immediate;
symval->X_add_number += 2;
fix_new (frag_now, frag_now_fix (), 2, end_sym, 0, 1, BFD_RELOC_SH_LABEL);
}
@ -2923,21 +2924,6 @@ sh_frob_section (bfd *abfd ATTRIBUTE_UNUSED, segT sec,
if (seginfo == NULL)
return;
for (fix = seginfo->fix_root; fix != NULL; fix = fix->fx_next)
{
symbolS *sym;
sym = fix->fx_addsy;
/* Check for a local_symbol. */
if (sym && sym->bsym == NULL)
{
struct local_symbol *ls = (struct local_symbol *)sym;
/* See if it's been converted. If so, canonicalize. */
if (local_symbol_converted_p (ls))
fix->fx_addsy = local_symbol_get_real_symbol (ls);
}
}
for (fix = seginfo->fix_root; fix != NULL; fix = fix->fx_next)
{
symbolS *sym;

View File

@ -50,7 +50,6 @@
#include "sb.h"
#include "macro.h"
#include "subsegs.h"
#include "struc-symbol.h"
#include "opcode/tic54x.h"
#include "obj-coff.h"
#include <math.h>
@ -506,7 +505,7 @@ tic54x_bss (int x ATTRIBUTE_UNUSED)
symbolP = symbol_find_or_make (name);
if (S_GET_SEGMENT (symbolP) == bss_section)
symbolP->sy_frag->fr_symbol = (symbolS *) NULL;
symbol_get_frag (symbolP)->fr_symbol = (symbolS *) NULL;
symbol_set_frag (symbolP, frag_now);
p = frag_var (rs_org, 1, 1, (relax_substateT) 0, symbolP,

View File

@ -19,7 +19,6 @@
MA 02110-1301, USA. */
#include "as.h"
#include "struc-symbol.h"
#include "subsegs.h"
#include "elf/tilegx.h"
@ -737,16 +736,18 @@ emit_tilegx_instruction (tilegx_bundle_bits bits,
}
else if (use_subexp)
{
expressionS *sval = NULL;
/* Now that we've changed the reloc, change ha16(x) into x,
etc. */
if (!operand_exp->X_add_symbol->sy_flags.sy_local_symbol
&& operand_exp->X_add_symbol->sy_value.X_md)
if (symbol_symbolS (operand_exp->X_add_symbol))
sval = symbol_get_value_expression (operand_exp->X_add_symbol);
if (sval && sval->X_md)
{
/* HACK: We used X_md to mark this symbol as a fake wrapper
around a real expression. To unwrap it, we just grab its
value here. */
operand_exp = &operand_exp->X_add_symbol->sy_value;
operand_exp = sval;
if (require_symbol)
{
@ -1067,7 +1068,7 @@ tilegx_parse_name (char *name, expressionS *e, char *nextcharP)
/* HACK: mark this symbol as a temporary wrapper around a proper
expression, so we can unwrap it later once we have communicated
the relocation type. */
sym->sy_value.X_md = 1;
symbol_get_value_expression (sym)->X_md = 1;
}
memset (e, 0, sizeof *e);

View File

@ -19,7 +19,6 @@
MA 02110-1301, USA. */
#include "as.h"
#include "struc-symbol.h"
#include "subsegs.h"
#include "elf/tilepro.h"
@ -628,16 +627,18 @@ emit_tilepro_instruction (tilepro_bundle_bits bits,
}
else if (use_subexp)
{
expressionS *sval = NULL;
/* Now that we've changed the reloc, change ha16(x) into x,
etc. */
if (!operand_exp->X_add_symbol->sy_flags.sy_local_symbol
&& operand_exp->X_add_symbol->sy_value.X_md)
if (symbol_symbolS (operand_exp->X_add_symbol))
sval = symbol_get_value_expression (operand_exp->X_add_symbol);
if (sval && sval->X_md)
{
/* HACK: We used X_md to mark this symbol as a fake wrapper
around a real expression. To unwrap it, we just grab its
value here. */
operand_exp = &operand_exp->X_add_symbol->sy_value;
operand_exp = sval;
if (require_symbol)
{
@ -958,7 +959,7 @@ tilepro_parse_name (char *name, expressionS *e, char *nextcharP)
/* HACK: mark this symbol as a temporary wrapper around a proper
expression, so we can unwrap it later once we have communicated
the relocation type. */
sym->sy_value.X_md = 1;
symbol_get_value_expression (sym)->X_md = 1;
}
memset (e, 0, sizeof *e);

View File

@ -27,7 +27,6 @@
#include "xtensa-relax.h"
#include "dwarf2dbg.h"
#include "xtensa-istack.h"
#include "struc-symbol.h"
#include "xtensa-config.h"
#include "elf/xtensa.h"
@ -7215,10 +7214,8 @@ xg_assemble_vliw_tokens (vliw_insn *vinsn)
frag_now->tc_frag_data.slot_offsets[slot] = tinsn->offset;
frag_now->tc_frag_data.literal_frags[slot] = tinsn->literal_frag;
if (tinsn->opcode == xtensa_l32r_opcode)
{
frag_now->tc_frag_data.literal_frags[slot] =
tinsn->tok[1].X_add_symbol->sy_frag;
}
frag_now->tc_frag_data.literal_frags[slot]
= symbol_get_frag (tinsn->tok[1].X_add_symbol);
if (tinsn->literal_space != 0)
xg_assemble_literal_space (tinsn->literal_space, slot);
frag_now->tc_frag_data.free_reg[slot] = tinsn->extra_arg;
@ -7683,14 +7680,15 @@ static int xg_order_trampoline_chain (const void *a, const void *b)
const struct trampoline_chain_entry *pb = &_pb->target;
symbolS *s1 = pa->sym;
symbolS *s2 = pb->sym;
symbolS *tmp;
if (s1->sy_flags.sy_local_symbol
&& local_symbol_converted_p ((struct local_symbol *) s1))
s1 = local_symbol_get_real_symbol ((struct local_symbol *) s1);
tmp = symbol_symbolS (s1);
if (tmp)
s1 = tmp;
if (s2->sy_flags.sy_local_symbol
&& local_symbol_converted_p ((struct local_symbol *) s2))
s2 = local_symbol_get_real_symbol ((struct local_symbol *) s2);
tmp = symbol_symbolS (s2);
if (tmp)
s2 = tmp;
if (s1 == s2)
if (pa->offset == pb->offset)

View File

@ -41,11 +41,10 @@ This section describes some fundamental GAS data types.
@cindex symbolS structure
The definition for the symbol structure, @code{symbolS}, is located in
@file{struc-symbol.h}.
@file{symbols.c}.
In general, the fields of this structure may not be referred to directly.
The fields of this structure may not be referred to directly.
Instead, you must use one of the accessor functions defined in @file{symbol.h}.
These accessor functions should work for any GAS version.
Symbol structures contain the following fields:
@ -398,12 +397,6 @@ deal with local symbols. @code{struct local_symbol} is much smaller than
@code{symbolS} (which also automatically creates a bfd @code{asymbol}
structure), so this saves space when assembling large files.
The first field of @code{symbolS} is @code{bsym}, the pointer to the BFD
symbol. The first field of @code{struct local_symbol} is a pointer which is
always set to NULL. This is how the symbol accessor functions can distinguish
local symbols from ordinary symbols. The symbol accessor functions
automatically convert a local symbol into an ordinary symbol when necessary.
@node Expressions
@subsection Expressions
@cindex internals, expressions

View File

@ -21,7 +21,6 @@
#include "as.h"
#include "subsegs.h"
#include "struc-symbol.h"
/* We include this ELF file, even though we may not be assembling for
ELF, since the exception frame information is always in a format
@ -434,23 +433,28 @@ check_eh_frame (expressionS *exp, unsigned int *pnbytes)
|| exp->X_op == O_right_shift)
&& d->cie_info.code_alignment > 1)
{
if (exp->X_add_symbol->bsym
&& exp->X_op_symbol->bsym
&& exp->X_add_symbol->sy_value.X_op == O_subtract
&& exp->X_op_symbol->sy_value.X_op == O_constant
if (symbol_symbolS (exp->X_add_symbol)
&& symbol_constant_p (exp->X_op_symbol)
&& S_GET_SEGMENT (exp->X_op_symbol) == absolute_section
&& ((exp->X_op == O_divide
? exp->X_op_symbol->sy_value.X_add_number
: (offsetT) 1 << exp->X_op_symbol->sy_value.X_add_number)
? *symbol_X_add_number (exp->X_op_symbol)
: (offsetT) 1 << *symbol_X_add_number (exp->X_op_symbol))
== (offsetT) d->cie_info.code_alignment))
{
/* This is a case we can optimize as well. The expression was
not reduced, so we can not finish the optimization until the
end of the assembly. We set up a variant frag which we
handle later. */
frag_var (rs_cfa, 4, 0, d->cie_info.code_alignment << 3,
make_expr_symbol (&exp->X_add_symbol->sy_value),
d->loc4_fix, (char *) d->loc4_frag);
return 1;
expressionS *symval;
symval = symbol_get_value_expression (exp->X_add_symbol);
if (symval->X_op == O_subtract)
{
/* This is a case we can optimize as well. The
expression was not reduced, so we can not finish
the optimization until the end of the assembly.
We set up a variant frag which we handle later. */
frag_var (rs_cfa, 4, 0, d->cie_info.code_alignment << 3,
make_expr_symbol (symval),
d->loc4_fix, (char *) d->loc4_frag);
return 1;
}
}
}
break;

View File

@ -254,7 +254,6 @@ remap.c
sb.c
sb.h
stabs.c
struc-symbol.h
subsegs.c
subsegs.h
symbols.c

View File

@ -1,158 +0,0 @@
/* struct_symbol.h - Internal symbol structure
Copyright (C) 1987-2018 Free Software Foundation, Inc.
This file is part of GAS, the GNU Assembler.
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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, 51 Franklin Street - Fifth Floor, Boston, MA
02110-1301, USA. */
#ifndef __struc_symbol_h__
#define __struc_symbol_h__
struct symbol_flags
{
/* Whether the symbol is a local_symbol. */
unsigned int sy_local_symbol : 1;
/* Weather symbol has been written. */
unsigned int sy_written : 1;
/* Whether symbol value has been completely resolved (used during
final pass over symbol table). */
unsigned int sy_resolved : 1;
/* Whether the symbol value is currently being resolved (used to
detect loops in symbol dependencies). */
unsigned int sy_resolving : 1;
/* Whether the symbol value is used in a reloc. This is used to
ensure that symbols used in relocs are written out, even if they
are local and would otherwise not be. */
unsigned int sy_used_in_reloc : 1;
/* Whether the symbol is used as an operand or in an expression.
NOTE: Not all the backends keep this information accurate;
backends which use this bit are responsible for setting it when
a symbol is used in backend routines. */
unsigned int sy_used : 1;
/* Whether the symbol can be re-defined. */
unsigned int sy_volatile : 1;
/* Whether the symbol is a forward reference. */
unsigned int sy_forward_ref : 1;
/* This is set if the symbol is defined in an MRI common section.
We handle such sections as single common symbols, so symbols
defined within them must be treated specially by the relocation
routines. */
unsigned int sy_mri_common : 1;
/* This is set if the symbol is set with a .weakref directive. */
unsigned int sy_weakrefr : 1;
/* This is set when the symbol is referenced as part of a .weakref
directive, but only if the symbol was not in the symbol table
before. It is cleared as soon as any direct reference to the
symbol is present. */
unsigned int sy_weakrefd : 1;
};
/* The information we keep for a symbol. Note that the symbol table
holds pointers both to this and to local_symbol structures. See
below. */
struct symbol
{
/* Symbol flags. */
struct symbol_flags sy_flags;
/* BFD symbol */
asymbol *bsym;
/* The value of the symbol. */
expressionS sy_value;
/* Forwards and (optionally) backwards chain pointers. */
struct symbol *sy_next;
struct symbol *sy_previous;
/* Pointer to the frag this symbol is attached to, if any.
Otherwise, NULL. */
struct frag *sy_frag;
#ifdef OBJ_SYMFIELD_TYPE
OBJ_SYMFIELD_TYPE sy_obj;
#endif
#ifdef TC_SYMFIELD_TYPE
TC_SYMFIELD_TYPE sy_tc;
#endif
#ifdef TARGET_SYMBOL_FIELDS
TARGET_SYMBOL_FIELDS
#endif
};
/* A pointer in the symbol may point to either a complete symbol
(struct symbol above) or to a local symbol (struct local_symbol
defined here). The symbol code can detect the case by examining
the first field. It is always NULL for a local symbol.
We do this because we ordinarily only need a small amount of
information for a local symbol. The symbol table takes up a lot of
space, and storing less information for a local symbol can make a
big difference in assembler memory usage when assembling a large
file. */
struct local_symbol
{
/* Symbol flags. Only sy_local_symbol and sy_resolved are relevant. */
struct symbol_flags lsy_flags;
/* The symbol section. This also serves as a flag. If this is
reg_section, then this symbol has been converted into a regular
symbol, and lsy_sym points to it. */
segT lsy_section;
/* The symbol name. */
const char *lsy_name;
/* The symbol frag or the real symbol, depending upon the value in
lsy_section. */
union
{
fragS *lsy_frag;
symbolS *lsy_sym;
} u;
/* The value of the symbol. */
valueT lsy_value;
#ifdef TC_LOCAL_SYMFIELD_TYPE
TC_LOCAL_SYMFIELD_TYPE lsy_tc;
#endif
};
#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
#define local_symbol_resolved_p(l) ((l)->lsy_flags.sy_resolved)
#define local_symbol_mark_resolved(l) ((l)->lsy_flags.sy_resolved = 1)
#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
#endif /* __struc_symbol_h__ */

View File

@ -24,9 +24,142 @@
#include "safe-ctype.h"
#include "obstack.h" /* For "symbols.h" */
#include "subsegs.h"
#include "struc-symbol.h"
#include "write.h"
struct symbol_flags
{
/* Whether the symbol is a local_symbol. */
unsigned int sy_local_symbol : 1;
/* Weather symbol has been written. */
unsigned int sy_written : 1;
/* Whether symbol value has been completely resolved (used during
final pass over symbol table). */
unsigned int sy_resolved : 1;
/* Whether the symbol value is currently being resolved (used to
detect loops in symbol dependencies). */
unsigned int sy_resolving : 1;
/* Whether the symbol value is used in a reloc. This is used to
ensure that symbols used in relocs are written out, even if they
are local and would otherwise not be. */
unsigned int sy_used_in_reloc : 1;
/* Whether the symbol is used as an operand or in an expression.
NOTE: Not all the backends keep this information accurate;
backends which use this bit are responsible for setting it when
a symbol is used in backend routines. */
unsigned int sy_used : 1;
/* Whether the symbol can be re-defined. */
unsigned int sy_volatile : 1;
/* Whether the symbol is a forward reference. */
unsigned int sy_forward_ref : 1;
/* This is set if the symbol is defined in an MRI common section.
We handle such sections as single common symbols, so symbols
defined within them must be treated specially by the relocation
routines. */
unsigned int sy_mri_common : 1;
/* This is set if the symbol is set with a .weakref directive. */
unsigned int sy_weakrefr : 1;
/* This is set when the symbol is referenced as part of a .weakref
directive, but only if the symbol was not in the symbol table
before. It is cleared as soon as any direct reference to the
symbol is present. */
unsigned int sy_weakrefd : 1;
};
/* The information we keep for a symbol. Note that the symbol table
holds pointers both to this and to local_symbol structures. See
below. */
struct symbol
{
/* Symbol flags. */
struct symbol_flags sy_flags;
/* BFD symbol */
asymbol *bsym;
/* The value of the symbol. */
expressionS sy_value;
/* Forwards and (optionally) backwards chain pointers. */
struct symbol *sy_next;
struct symbol *sy_previous;
/* Pointer to the frag this symbol is attached to, if any.
Otherwise, NULL. */
struct frag *sy_frag;
#ifdef OBJ_SYMFIELD_TYPE
OBJ_SYMFIELD_TYPE sy_obj;
#endif
#ifdef TC_SYMFIELD_TYPE
TC_SYMFIELD_TYPE sy_tc;
#endif
#ifdef TARGET_SYMBOL_FIELDS
TARGET_SYMBOL_FIELDS
#endif
};
/* A pointer in the symbol may point to either a complete symbol
(struct symbol above) or to a local symbol (struct local_symbol
defined here). The symbol code can detect the case by examining
the first field. It is always NULL for a local symbol.
We do this because we ordinarily only need a small amount of
information for a local symbol. The symbol table takes up a lot of
space, and storing less information for a local symbol can make a
big difference in assembler memory usage when assembling a large
file. */
struct local_symbol
{
/* Symbol flags. Only sy_local_symbol and sy_resolved are relevant. */
struct symbol_flags lsy_flags;
/* The symbol section. This also serves as a flag. If this is
reg_section, then this symbol has been converted into a regular
symbol, and lsy_sym points to it. */
segT lsy_section;
/* The symbol name. */
const char *lsy_name;
/* The symbol frag or the real symbol, depending upon the value in
lsy_section. */
union
{
fragS *lsy_frag;
symbolS *lsy_sym;
} u;
/* The value of the symbol. */
valueT lsy_value;
#ifdef TC_LOCAL_SYMFIELD_TYPE
TC_LOCAL_SYMFIELD_TYPE lsy_tc;
#endif
};
#define local_symbol_converted_p(l) ((l)->lsy_section == reg_section)
#define local_symbol_mark_converted(l) ((l)->lsy_section = reg_section)
#define local_symbol_resolved_p(l) ((l)->lsy_flags.sy_resolved)
#define local_symbol_mark_resolved(l) ((l)->lsy_flags.sy_resolved = 1)
#define local_symbol_get_frag(l) ((l)->u.lsy_frag)
#define local_symbol_set_frag(l, f) ((l)->u.lsy_frag = (f))
#define local_symbol_get_real_symbol(l) ((l)->u.lsy_sym)
#define local_symbol_set_real_symbol(l, s) ((l)->u.lsy_sym = (s))
/* This is non-zero if symbols are case sensitive, which is the
default. */
int symbols_case_sensitive = 1;
@ -928,6 +1061,20 @@ verify_symbol_chain (symbolS *rootP, symbolS *lastP)
gas_assert (lastP == symbolP);
}
int
symbol_on_chain (symbolS *s, symbolS *rootPP, symbolS *lastPP)
{
return (!LOCAL_SYMBOL_CHECK (s)
&& ((s->sy_next != s
&& s->sy_next != NULL
&& s->sy_next->sy_previous == s)
|| s == lastPP)
&& ((s->sy_previous != s
&& s->sy_previous != NULL
&& s->sy_previous->sy_next == s)
|| s == rootPP));
}
#ifdef OBJ_COMPLEX_RELC
static int
@ -2733,6 +2880,18 @@ symbol_shadow_p (symbolS *s)
return s->sy_next == s;
}
/* If S was created as a struct symbol, return S, otherwise if S is a
converted local_symbol return the converted symbol, otherwise
return NULL. */
symbolS *
symbol_symbolS (symbolS *s)
{
if (LOCAL_SYMBOL_CHECK (s))
return NULL;
return s;
}
/* Return the BFD symbol for a symbol. */
asymbol *

View File

@ -168,6 +168,8 @@ void symbol_remove (symbolS * symbolP, symbolS ** rootP,
extern symbolS *symbol_previous (symbolS *);
extern int symbol_on_chain (symbolS *s, symbolS *rootPP, symbolS *lastPP);
void verify_symbol_chain (symbolS * rootP, symbolS * lastP);
void symbol_append (symbolS * addme, symbolS * target,
@ -200,6 +202,7 @@ extern int symbol_equated_p (symbolS *);
extern int symbol_equated_reloc_p (symbolS *);
extern int symbol_constant_p (symbolS *);
extern int symbol_shadow_p (symbolS *);
extern symbolS *symbol_symbolS (symbolS *);
extern asymbol *symbol_get_bfdsym (symbolS *);
extern void symbol_set_bfdsym (symbolS *, asymbol *);
extern int symbol_same_p (symbolS *, symbolS *);

View File

@ -1886,8 +1886,6 @@ create_obj_attrs_section (void)
size_seg (stdoutput, s, NULL);
}
#include "struc-symbol.h"
/* Create a relocation against an entry in a GNU Build attribute section. */
static void
@ -1904,7 +1902,7 @@ create_note_reloc (segT sec,
/* We create a .b type reloc as resolve_reloc_expr_symbols() has already been called. */
reloc->u.b.sec = sec;
reloc->u.b.s = sym->bsym;
reloc->u.b.s = symbol_get_bfdsym (sym);
reloc->u.b.r.sym_ptr_ptr = & reloc->u.b.s;
reloc->u.b.r.address = offset;
reloc->u.b.r.addend = addend;
@ -1951,6 +1949,7 @@ maybe_generate_build_notes (void)
offsetT desc2_offset;
int desc_reloc;
symbolS * sym;
asymbol * bsym;
if (! flag_generate_build_notes
|| bfd_get_section_by_name (stdoutput,
@ -2004,12 +2003,12 @@ maybe_generate_build_notes (void)
total_size = 0;
note = NULL;
for (sym = symbol_rootP; sym != NULL; sym = sym->sy_next)
if (sym->bsym != NULL
&& sym->bsym->flags & BSF_SECTION_SYM
&& sym->bsym->section != NULL
for (sym = symbol_rootP; sym != NULL; sym = symbol_next (sym))
if ((bsym = symbol_get_bfdsym (sym)) != NULL
&& bsym->flags & BSF_SECTION_SYM
&& bsym->section != NULL
/* Skip linkonce sections - we cannot use these section symbols as they may disappear. */
&& (sym->bsym->section->flags & (SEC_CODE | SEC_LINK_ONCE)) == SEC_CODE
&& (bsym->section->flags & (SEC_CODE | SEC_LINK_ONCE)) == SEC_CODE
/* Not all linkonce sections are flagged... */
&& strncmp (S_GET_NAME (sym), ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) != 0)
{
@ -2042,7 +2041,7 @@ maybe_generate_build_notes (void)
/* ...and another one to install the end address. */
create_note_reloc (sec, sym, total_size + desc2_offset, desc_reloc,
bfd_get_section_size (sym->bsym->section),
bfd_get_section_size (bsym->section),
note);
total_size += note_size;