aboutsummaryrefslogtreecommitdiff
path: root/ld/scripttempl
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2018-02-03 13:11:35 +0000
committerNick Clifton <nickc@redhat.com>2018-02-03 13:11:35 +0000
commitb0daac83d78c82f7998287bb717063c4d01d4f97 (patch)
tree2beb203c407b3a1225e23ceb23cb401fbee24a31 /ld/scripttempl
parent138a158f0a561d406bebb8b91eba0dd6dedd430e (diff)
downloadgdb-b0daac83d78c82f7998287bb717063c4d01d4f97.zip
gdb-b0daac83d78c82f7998287bb717063c4d01d4f97.tar.gz
gdb-b0daac83d78c82f7998287bb717063c4d01d4f97.tar.bz2
Remove PROVIDE() qualifiers from definition of __CTOR_LIST__ and __DTOR_LIST__ symbols in PE linker scripts.
PR 22762 * scripttempl/pe.sc: Remove PROVIDE()s from __CTOR_LIST__ and __DTOR_LIST__ symbols. Add a comment explaining why this is necessary. * scripttemp/pep.sc: Likewise. * ld.texinfo (PROVIDE): Add a note about the effect of common symbols.
Diffstat (limited to 'ld/scripttempl')
-rw-r--r--ld/scripttempl/pe.sc24
-rw-r--r--ld/scripttempl/pep.sc24
2 files changed, 40 insertions, 8 deletions
diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc
index c8a45ca..f56d783 100644
--- a/ld/scripttempl/pe.sc
+++ b/ld/scripttempl/pe.sc
@@ -98,8 +98,22 @@ SECTIONS
${RELOCATING+*(.glue_7t)}
${RELOCATING+*(.glue_7)}
${CONSTRUCTING+
- PROVIDE(___CTOR_LIST__ = .);
- PROVIDE(__CTOR_LIST__ = .);
+ /* Note: we always define __CTOR_LIST__ and ___CTOR_LIST__ here,
+ we do not PROVIDE them. This is because the ctors.o startup
+ code in libgcc defines them as common symbols, with the
+ expectation that they will be overridden by the definitions
+ here. If we PROVIDE the symbols then they will not be
+ overridden and global constructors will not be run.
+
+ This does mean that it is not possible for a user to define
+ their own __CTOR_LIST__ and __DTOR_LIST__ symbols. If that
+ ability is needed a custom linker script will have to be
+ used. (The custom script can just be a copy of this script
+ with the PROVIDE() qualifiers added).
+
+ See PR 22762 for more details. */
+ ___CTOR_LIST__ = .;
+ __CTOR_LIST__ = .;
LONG (-1);
KEEP(*(.ctors));
KEEP(*(.ctor));
@@ -107,8 +121,10 @@ SECTIONS
LONG (0);
}
${CONSTRUCTING+
- PROVIDE(___DTOR_LIST__ = .);
- PROVIDE(__DTOR_LIST__ = .);
+ /* See comment about __CTOR_LIST__ above. The same reasoning
+ applies here too. */
+ ___DTOR_LIST__ = .;
+ __DTOR_LIST__ = .;
LONG (-1);
KEEP(*(.dtors));
KEEP(*(.dtor));
diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc
index 8daacb2..3c6c84d 100644
--- a/ld/scripttempl/pep.sc
+++ b/ld/scripttempl/pep.sc
@@ -99,8 +99,22 @@ SECTIONS
${RELOCATING+*(.glue_7)}
${CONSTRUCTING+. = ALIGN(8);}
${CONSTRUCTING+
- PROVIDE(___CTOR_LIST__ = .);
- PROVIDE(__CTOR_LIST__ = .);
+ /* Note: we always define __CTOR_LIST__ and ___CTOR_LIST__ here,
+ we do not PROVIDE them. This is because the ctors.o startup
+ code in libgcc defines them as common symbols, with the
+ expectation that they will be overridden by the definitions
+ here. If we PROVIDE the symbols then they will not be
+ overridden and global constructors will not be run.
+
+ This does mean that it is not possible for a user to define
+ their own __CTOR_LIST__ and __DTOR_LIST__ symbols. If that
+ ability is needed a custom linker script will have to be
+ used. (The custom script can just be a copy of this script
+ with the PROVIDE() qualifiers added).
+
+ See PR 22762 for more details. */
+ ___CTOR_LIST__ = .;
+ __CTOR_LIST__ = .;
LONG (-1); LONG (-1);
KEEP (*(.ctors));
KEEP (*(.ctor));
@@ -108,8 +122,10 @@ SECTIONS
LONG (0); LONG (0);
}
${CONSTRUCTING+
- PROVIDE(___DTOR_LIST__ = .);
- PROVIDE(__DTOR_LIST__ = .);
+ /* See comment about __CTOR_LIST__ above. The same reasoning
+ applies here too. */
+ ___DTOR_LIST__ = .;
+ __DTOR_LIST__ = .;
LONG (-1); LONG (-1);
KEEP (*(.dtors));
KEEP (*(.dtor));