summaryrefslogtreecommitdiff
path: root/ld/ldexp.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2005-06-05 15:28:36 +0000
committerH.J. Lu <hjl@lucon.org>2005-06-05 15:28:36 +0000
commit6f6b72a4cc3421e7195007ce58b56f06f7ea3461 (patch)
treedd274a454249a463587513cc848417640db34e31 /ld/ldexp.c
parent52a37afa30d48688e1db7903344d2f784bae0e2d (diff)
downloadbinutils-redhat-6f6b72a4cc3421e7195007ce58b56f06f7ea3461.tar.gz
ld/
2005-06-05 H.J. Lu <hongjiu.lu@intel.com> * ldexp.c (exp_mark_used_section): Set SEC_KEEP on current section only if the symbol will be defined. ld/testsuite/ 2005-06-05 H.J. Lu <hongjiu.lu@intel.com> * ld-cris/hiddef1.d: Undo the last change. * ld-cris/libdso-10.d: Likewise. * ld-cris/libdso-2.d: Likewise.
Diffstat (limited to 'ld/ldexp.c')
-rw-r--r--ld/ldexp.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/ld/ldexp.c b/ld/ldexp.c
index 7d63c8d9ac..3927f85f0b 100644
--- a/ld/ldexp.c
+++ b/ld/ldexp.c
@@ -1247,24 +1247,33 @@ exp_mark_used_section (etree_type *tree, asection *current_section)
if (tree->assign.dst[0] != '.' || tree->assign.dst[1] != 0)
{
etree_value_type result;
+ bfd_boolean create = tree->type.node_class == etree_assign;
+ struct bfd_link_hash_entry *h;
result = exp_fold_tree_1 (tree->assign.src,
current_section,
lang_allocating_phase_enum,
dot, &dot, TRUE);
- if (current_section != bfd_abs_section_ptr)
+
+ /* We mark the current section SEC_KEEP only if the symbol
+ will be defined. */
+ if (!create)
+ h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst,
+ create, FALSE, TRUE);
+ else
+ h = NULL;
+
+ if ((create || h)
+ && current_section != bfd_abs_section_ptr)
current_section->flags |= SEC_KEEP;
+
if (result.valid_p)
{
- bfd_boolean create;
- struct bfd_link_hash_entry *h;
- if (tree->type.node_class == etree_assign)
- create = TRUE;
- else
- create = FALSE;
- h = bfd_link_hash_lookup (link_info.hash, tree->assign.dst,
- create, FALSE, TRUE);
+ if (create)
+ h = bfd_link_hash_lookup (link_info.hash,
+ tree->assign.dst, create,
+ FALSE, TRUE);
if (h == NULL)
{
if (create)