aboutsummaryrefslogtreecommitdiff
path: root/ld/ldexp.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2005-06-05 15:28:36 +0000
committerH.J. Lu <hjl.tools@gmail.com>2005-06-05 15:28:36 +0000
commit18b7982923d444f29fafdc4b691c1f07a43aa199 (patch)
tree0d8ef23673a183e2974ce7937af6012c9fa55972 /ld/ldexp.c
parent9ee913b8a045a3d16864035249356e544cbbac7f (diff)
downloadgdb-18b7982923d444f29fafdc4b691c1f07a43aa199.zip
gdb-18b7982923d444f29fafdc4b691c1f07a43aa199.tar.gz
gdb-18b7982923d444f29fafdc4b691c1f07a43aa199.tar.bz2
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 7d63c8d..3927f85 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)