aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/elflink.c11
-rw-r--r--bfd/linker.c1
3 files changed, 19 insertions, 2 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 2fef817..818f580 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2021-03-01 Alan Modra <amodra@gmail.com>
+ Fangrui Song <maskray@google.com>
+
+ * elflink.c (_bfd_elf_gc_mark_rsec): Ignore synthesized linker
+ defined start/stop symbols when start_stop_gc.
+ (bfd_elf_gc_mark_dynamic_ref_symbol): Likewise.
+ (bfd_elf_define_start_stop): Don't modify ldscript_def syms.
+ * linker.c (bfd_generic_define_start_stop): Likewise.
+
2021-02-25 Alan Modra <amodra@gmail.com>
PR 27441
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 7b74f26..74b54c2 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -13444,12 +13444,15 @@ _bfd_elf_gc_mark_rsec (struct bfd_link_info *info, asection *sec,
hw->mark = 1;
}
- if (start_stop != NULL)
+ if (h->start_stop && !h->root.ldscript_def)
{
+ if (info->start_stop_gc)
+ return NULL;
+
/* To work around a glibc bug, mark XXX input sections
when there is a reference to __start_XXX or __stop_XXX
symbols. */
- if (h->start_stop)
+ else if (start_stop != NULL)
{
asection *s = h->u2.start_stop_section;
*start_stop = !s->gc_mark;
@@ -13912,6 +13915,9 @@ bfd_elf_gc_mark_dynamic_ref_symbol (struct elf_link_hash_entry *h, void *inf)
if ((h->root.type == bfd_link_hash_defined
|| h->root.type == bfd_link_hash_defweak)
+ && (!h->start_stop
+ || h->root.ldscript_def
+ || !info->start_stop_gc)
&& ((h->ref_dynamic && !h->forced_local)
|| ((h->def_regular || ELF_COMMON_DEF_P (h))
&& ELF_ST_VISIBILITY (h->other) != STV_INTERNAL
@@ -14984,6 +14990,7 @@ bfd_elf_define_start_stop (struct bfd_link_info *info,
FALSE, FALSE, TRUE);
/* NB: Common symbols will be turned into definition later. */
if (h != NULL
+ && !h->root.ldscript_def
&& (h->root.type == bfd_link_hash_undefined
|| h->root.type == bfd_link_hash_undefweak
|| ((h->ref_regular || h->def_dynamic)
diff --git a/bfd/linker.c b/bfd/linker.c
index 1fb5787..7e0415c 100644
--- a/bfd/linker.c
+++ b/bfd/linker.c
@@ -3188,6 +3188,7 @@ bfd_generic_define_start_stop (struct bfd_link_info *info,
h = bfd_link_hash_lookup (info->hash, symbol, FALSE, FALSE, TRUE);
if (h != NULL
+ && !h->ldscript_def
&& (h->type == bfd_link_hash_undefined
|| h->type == bfd_link_hash_undefweak))
{