mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-25 04:49:54 +08:00
When evaluating a ternary operator in a linker script, copy the symbol flags.
* ld/ldexp.c: (try_copy_symbol_flags): New. Factored out from... (exp_fold_tree_1): Here. Cope with ternary operator in assignments. Use new helper.
This commit is contained in:

committed by
Nick Clifton

parent
b32a5c16f1
commit
1fb80d6d50
@ -1,3 +1,9 @@
|
|||||||
|
2015-10-15 Simon Dardis <Simon.Dardis@imgtec.com>
|
||||||
|
|
||||||
|
* ld/ldexp.c: (try_copy_symbol_flags): New. Factored out from...
|
||||||
|
(exp_fold_tree_1): Here. Cope with ternary operator in
|
||||||
|
assignments. Use new helper.
|
||||||
|
|
||||||
2015-10-14 Nick Clifton <nickc@redhat.com>
|
2015-10-14 Nick Clifton <nickc@redhat.com>
|
||||||
|
|
||||||
* po/zh_TW.po: Updated Chinese translation.
|
* po/zh_TW.po: Updated Chinese translation.
|
||||||
|
44
ld/ldexp.c
44
ld/ldexp.c
@ -973,7 +973,24 @@ is_align_conditional (const etree_type *tree)
|
|||||||
&& is_dot_ne_0 (tree->trinary.cond)
|
&& is_dot_ne_0 (tree->trinary.cond)
|
||||||
&& is_value (tree->trinary.rhs, 1));
|
&& is_value (tree->trinary.rhs, 1));
|
||||||
}
|
}
|
||||||
return 0;
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Subroutine of exp_fold_tree_1 for copying a symbol type. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
try_copy_symbol_type (struct bfd_link_hash_entry * h, etree_type *src)
|
||||||
|
{
|
||||||
|
if (src->type.node_class == etree_name)
|
||||||
|
{
|
||||||
|
struct bfd_link_hash_entry *hsrc;
|
||||||
|
|
||||||
|
hsrc = bfd_link_hash_lookup (link_info.hash, src->name.name,
|
||||||
|
FALSE, FALSE, TRUE);
|
||||||
|
if (hsrc)
|
||||||
|
bfd_copy_link_hash_symbol_type (link_info.output_bfd, h,
|
||||||
|
hsrc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -1166,18 +1183,25 @@ exp_fold_tree_1 (etree_type *tree)
|
|||||||
tree->type.node_class = etree_provided;
|
tree->type.node_class = etree_provided;
|
||||||
|
|
||||||
/* Copy the symbol type if this is a simple assignment of
|
/* Copy the symbol type if this is a simple assignment of
|
||||||
one symbol to another. This could be more general
|
one symbol to another. Also, handle the case of a foldable
|
||||||
(e.g. a ?: operator with NAMEs in each branch). */
|
ternary conditional with names on either side. */
|
||||||
if (tree->assign.src->type.node_class == etree_name)
|
if (tree->assign.src->type.node_class == etree_name)
|
||||||
|
try_copy_symbol_type (h, tree->assign.src);
|
||||||
|
else if (tree->assign.src->type.node_class == etree_trinary)
|
||||||
{
|
{
|
||||||
struct bfd_link_hash_entry *hsrc;
|
exp_fold_tree_1 (tree->assign.src->trinary.cond);
|
||||||
|
if (expld.result.valid_p)
|
||||||
|
{
|
||||||
|
if (expld.result.value
|
||||||
|
&& tree->assign.src->trinary.lhs->type.node_class
|
||||||
|
== etree_name)
|
||||||
|
try_copy_symbol_type (h, tree->assign.src->trinary.lhs);
|
||||||
|
|
||||||
hsrc = bfd_link_hash_lookup (link_info.hash,
|
if (!expld.result.value
|
||||||
tree->assign.src->name.name,
|
&& tree->assign.src->trinary.rhs->type.node_class
|
||||||
FALSE, FALSE, TRUE);
|
== etree_name)
|
||||||
if (hsrc)
|
try_copy_symbol_type (h, tree->assign.src->trinary.rhs);
|
||||||
bfd_copy_link_hash_symbol_type (link_info.output_bfd, h,
|
}
|
||||||
hsrc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (expld.phase == lang_final_phase_enum)
|
else if (expld.phase == lang_final_phase_enum)
|
||||||
|
Reference in New Issue
Block a user