X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=ld%2Fldexp.c;h=3ffabb8c1da6e2f2677b1dc63e25e7ee92221c03;hb=02eba61aa6cad683e96cf13f483adc04982c0c2b;hp=daf0f2e38235851f0f289b09073a09c008ab2825;hpb=912ebfa0d748b4a762dbc4311364c38692c7f626;p=deliverable%2Fbinutils-gdb.git diff --git a/ld/ldexp.c b/ld/ldexp.c index daf0f2e382..3ffabb8c1d 100644 --- a/ld/ldexp.c +++ b/ld/ldexp.c @@ -1,5 +1,5 @@ /* This module handles expression trees. - Copyright (C) 1991-2019 Free Software Foundation, Inc. + Copyright (C) 1991-2020 Free Software Foundation, Inc. Written by Steve Chamberlain of Cygnus Support . This file is part of the GNU Binutils. @@ -30,6 +30,7 @@ #include "sysdep.h" #include "bfd.h" #include "bfdlink.h" +#include "ctf-api.h" #include "ld.h" #include "ldmain.h" @@ -198,7 +199,7 @@ new_abs (bfd_vma value) etree_type * exp_intop (bfd_vma value) { - etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->value)); + etree_type *new_e = stat_alloc (sizeof (new_e->value)); new_e->type.node_code = INT; new_e->type.filename = ldlex_filename (); new_e->type.lineno = lineno; @@ -211,7 +212,7 @@ exp_intop (bfd_vma value) etree_type * exp_bigintop (bfd_vma value, char *str) { - etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->value)); + etree_type *new_e = stat_alloc (sizeof (new_e->value)); new_e->type.node_code = INT; new_e->type.filename = ldlex_filename (); new_e->type.lineno = lineno; @@ -226,7 +227,7 @@ exp_bigintop (bfd_vma value, char *str) etree_type * exp_relop (asection *section, bfd_vma value) { - etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->rel)); + etree_type *new_e = stat_alloc (sizeof (new_e->rel)); new_e->type.node_code = REL; new_e->type.filename = ldlex_filename (); new_e->type.lineno = lineno; @@ -699,7 +700,8 @@ fold_name (etree_type *tree) /* Don't find the real header size if only marking sections; The bfd function may cache incorrect data. */ if (expld.phase != lang_mark_phase_enum) - hdr_size = bfd_sizeof_headers (link_info.output_bfd, &link_info); + hdr_size = (bfd_sizeof_headers (link_info.output_bfd, &link_info) + / bfd_octets_per_byte (link_info.output_bfd, NULL)); new_number (hdr_size); } break; @@ -729,7 +731,10 @@ fold_name (etree_type *tree) tree->name.name, TRUE, FALSE, TRUE); if (!h) - einfo (_("%F%P: bfd_link_hash_lookup failed: %E\n")); + { + if (expld.phase != lang_first_phase_enum) + einfo (_("%F%P: bfd_link_hash_lookup failed: %E\n")); + } else if (h->type == bfd_link_hash_defined || h->type == bfd_link_hash_defweak) { @@ -851,7 +856,8 @@ fold_name (etree_type *tree) if (tree->type.node_code == SIZEOF) val = (os->bfd_section->size - / bfd_octets_per_byte (link_info.output_bfd)); + / bfd_octets_per_byte (link_info.output_bfd, + os->bfd_section)); else val = (bfd_vma)1 << os->bfd_section->alignment_power; @@ -1277,8 +1283,8 @@ exp_value_fold (etree_type *tree) etree_type * exp_binop (int code, etree_type *lhs, etree_type *rhs) { - etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->binary), - sizeof (new_e->value))); + etree_type *new_e = stat_alloc (MAX (sizeof (new_e->binary), + sizeof (new_e->value))); new_e->type.node_code = code; new_e->type.filename = lhs->type.filename; new_e->type.lineno = lhs->type.lineno; @@ -1297,8 +1303,8 @@ exp_binop (int code, etree_type *lhs, etree_type *rhs) etree_type * exp_trinop (int code, etree_type *cond, etree_type *lhs, etree_type *rhs) { - etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->trinary), - sizeof (new_e->value))); + etree_type *new_e = stat_alloc (MAX (sizeof (new_e->trinary), + sizeof (new_e->value))); new_e->type.node_code = code; new_e->type.filename = cond->type.filename; new_e->type.lineno = cond->type.lineno; @@ -1316,8 +1322,8 @@ exp_trinop (int code, etree_type *cond, etree_type *lhs, etree_type *rhs) etree_type * exp_unop (int code, etree_type *child) { - etree_type *new_e = (etree_type *) stat_alloc (MAX (sizeof (new_e->unary), - sizeof (new_e->value))); + etree_type *new_e = stat_alloc (MAX (sizeof (new_e->unary), + sizeof (new_e->value))); new_e->unary.type.node_code = code; new_e->unary.type.filename = child->type.filename; new_e->unary.type.lineno = child->type.lineno; @@ -1335,7 +1341,7 @@ exp_unop (int code, etree_type *child) etree_type * exp_nameop (int code, const char *name) { - etree_type *new_e = (etree_type *) stat_alloc (sizeof (new_e->name)); + etree_type *new_e = stat_alloc (sizeof (new_e->name)); new_e->name.type.node_code = code; new_e->name.type.filename = ldlex_filename (); @@ -1354,7 +1360,7 @@ exp_assop (const char *dst, { etree_type *n; - n = (etree_type *) stat_alloc (sizeof (n->assign)); + n = stat_alloc (sizeof (n->assign)); n->assign.type.node_code = '='; n->assign.type.filename = src->type.filename; n->assign.type.lineno = src->type.lineno; @@ -1396,7 +1402,7 @@ exp_assert (etree_type *exp, const char *message) { etree_type *n; - n = (etree_type *) stat_alloc (sizeof (n->assert_s)); + n = stat_alloc (sizeof (n->assert_s)); n->assert_s.type.node_code = '!'; n->assert_s.type.filename = exp->type.filename; n->assert_s.type.lineno = exp->type.lineno;