+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
output-file.h \
read.h \
sb.h \
- struc-symbol.h \
subsegs.h \
symbols.h \
tc.h \
output-file.h \
read.h \
sb.h \
- struc-symbol.h \
subsegs.h \
symbols.h \
tc.h \
#include "dwarf2dbg.h"
#include "symbols.h"
-#include "struc-symbol.h"
#ifdef OBJ_COMPLEX_RELC
static expressionS * make_right_shifted_expr
if (! errmsg)
{
+ asymbol *bsym;
+
/* Fragment the expression as necessary, and queue a reloc. */
memset (& dummy_fixup, 0, sizeof (fixS));
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
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. */
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,
{
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);
#include "as.h"
#include "safe-ctype.h"
#include "subsegs.h"
-#include "struc-symbol.h"
#ifdef TE_PE
#include "coff/pe.h"
}
#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)
#include "safe-ctype.h"
#include "subsegs.h"
#include "obstack.h"
-#include "struc-symbol.h"
#include "dwarf2dbg.h"
#ifndef ECOFF_DEBUGGING
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;
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);
/* 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);
#include "bfd.h"
#include "vms.h"
#include "subsegs.h"
-#include "struc-symbol.h"
#include "safe-ctype.h"
static void s_evax_weak (int);
#include "as.h"
#include "subsegs.h"
-#include "struc-symbol.h"
#include "ecoff.h"
#include "opcode/alpha.h"
&& 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;
}
}
#ifndef OBJ_EVAX
- know (symbolP->sy_frag == &zero_address_frag);
+ know (symbol_get_frag (symbolP) == &zero_address_frag);
#endif
demand_empty_rest_of_line ();
}
#include "as.h"
#include "subsegs.h"
-#include "struc-symbol.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "safe-ctype.h"
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;
}
#include "as.h"
#include "safe-ctype.h"
#include "subsegs.h"
-#include "struc-symbol.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#include "elf/avr.h"
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;
}
02110-1301, USA. */
#include "as.h"
-#include "struc-symbol.h"
#include "bfin-defs.h"
#include "obstack.h"
#include "safe-ctype.h"
/* 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
#include "subsegs.h"
#include "obstack.h"
#include "libiberty.h"
-#include "struc-symbol.h"
#ifdef OBJ_ELF
#include "elf/csky.h"
|| (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)
}
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)
#include "hash.h"
#include "sb.h"
#include "macro.h"
-#include "struc-symbol.h"
#include "opcode/nds32.h"
#include <stdio.h>
#include "itbl-ops.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
-#include "struc-symbol.h"
#include "elf/riscv.h"
#include "opcode/riscv.h"
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);
02110-1301, USA. */
#include "as.h"
-#include "struc-symbol.h"
#include "safe-ctype.h"
#include "dwarf2dbg.h"
#include "elf/common.h"
02110-1301, USA. */
#include "as.h"
-#include "struc-symbol.h"
#include "safe-ctype.h"
#include "dwarf2dbg.h"
#include "elf/common.h"
#include "as.h"
#include "safe-ctype.h"
#include "subsegs.h"
-#include "struc-symbol.h"
#include "dwarf2dbg.h"
#include "dw2gencfi.h"
/* 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)
{
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)
/* 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;
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;
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;
/* 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;
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;
/* 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;
/* 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;
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;
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;
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)))
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)
/* 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))
#include "subsegs.h"
#include "safe-ctype.h"
#include "opcode/score-inst.h"
-#include "struc-symbol.h"
#include "libiberty.h"
#ifdef OBJ_ELF
/* 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;
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;
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;
/* 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;
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;
/* 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;
/* 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;
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;
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);
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. */
#define DEFINE_TABLE
#include "opcodes/sh-opc.h"
#include "safe-ctype.h"
-#include "struc-symbol.h"
#ifdef OBJ_ELF
#include "elf/sh.h"
{
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
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);
}
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;
#include "sb.h"
#include "macro.h"
#include "subsegs.h"
-#include "struc-symbol.h"
#include "opcode/tic54x.h"
#include "obj-coff.h"
#include <math.h>
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,
MA 02110-1301, USA. */
#include "as.h"
-#include "struc-symbol.h"
#include "subsegs.h"
#include "elf/tilegx.h"
}
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)
{
/* 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);
MA 02110-1301, USA. */
#include "as.h"
-#include "struc-symbol.h"
#include "subsegs.h"
#include "elf/tilepro.h"
}
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)
{
/* 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);
#include "xtensa-relax.h"
#include "dwarf2dbg.h"
#include "xtensa-istack.h"
-#include "struc-symbol.h"
#include "xtensa-config.h"
#include "elf/xtensa.h"
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;
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)
@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:
@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
#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
|| 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;
sb.c
sb.h
stabs.c
-struc-symbol.h
subsegs.c
subsegs.h
symbols.c
+++ /dev/null
-/* 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__ */
#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;
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
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 *
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,
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 *);
size_seg (stdoutput, s, NULL);
}
-#include "struc-symbol.h"
-
/* Create a relocation against an entry in a GNU Build attribute section. */
static void
/* 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;
offsetT desc2_offset;
int desc_reloc;
symbolS * sym;
+ asymbol * bsym;
if (! flag_generate_build_notes
|| bfd_get_section_by_name (stdoutput,
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)
{
/* ...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;