[gdb/symtab] Prefer var def over decl
[deliverable/binutils-gdb.git] / ld / scripttempl / pe.sc
index 9f7b2b220ee283a40a9ee6a3cb2e017ab28bb1a9..8b5e1a1dad77e67ad58ac7cd7ec49a0c2bc46eb5 100644 (file)
@@ -1,7 +1,7 @@
 # Linker script for PE.
 #
-# Copyright (C) 2014-2017 Free Software Foundation, Inc.
-# 
+# Copyright (C) 2014-2019 Free Software Foundation, Inc.
+#
 # Copying and distribution of this file, with or without modification,
 # are permitted in any medium without royalty provided the copyright
 # notice and this notice are preserved.
@@ -21,13 +21,13 @@ if test "${RELOCATING}"; then
   R_TEXT='*(SORT(.text$*))'
   if test "x$LD_FLAG" = "xauto_import" ; then
     R_DATA='*(SORT(.data$*))
-            *(.rdata)
+           *(.rdata)
            *(SORT(.rdata$*))'
     R_RDATA=''
   else
     R_DATA='*(SORT(.data$*))'
     R_RDATA='*(.rdata)
-             *(SORT(.rdata$*))'
+            *(SORT(.rdata$*))'
   fi
   R_IDATA234='
     KEEP (SORT(*)(.idata$2))
@@ -70,7 +70,7 @@ else
 fi
 
 cat <<EOF
-/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
+/* Copyright (C) 2014-2019 Free Software Foundation, Inc.
 
    Copying and distribution of this script, with or without modification,
    are permitted in any medium without royalty provided the copyright
@@ -90,19 +90,54 @@ SECTIONS
   ${RELOCATING+. = ALIGN(__section_alignment__);}
   .text ${RELOCATING+ __image_base__ + ( __section_alignment__ < ${TARGET_PAGE_SIZE} ? . : __section_alignment__ )} :
   {
-    ${RELOCATING+ KEEP(*(.init))}
+    ${RELOCATING+KEEP (*(SORT_NONE(.init)))}
     *(.text)
     ${R_TEXT}
     ${RELOCATING+ *(.text.*)}
     ${RELOCATING+ *(.gnu.linkonce.t.*)}
     ${RELOCATING+*(.glue_7t)}
     ${RELOCATING+*(.glue_7)}
-    ${CONSTRUCTING+ ___CTOR_LIST__ = .; __CTOR_LIST__ = . ;
-                       LONG (-1);*(.ctors); *(.ctor); *(SORT(.ctors.*));  LONG (0); }
-    ${CONSTRUCTING+ ___DTOR_LIST__ = .; __DTOR_LIST__ = . ;
-                       LONG (-1); *(.dtors); *(.dtor); *(SORT(.dtors.*));  LONG (0); }
-    ${RELOCATING+ KEEP (*(.fini))}
-    /* ??? Why is .gcc_exc here?  */
+    ${CONSTRUCTING+
+       /* 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.
+         See PR 22762 for more details.
+         
+         This does mean that it is not possible for a user to define
+         their own __CTOR_LIST__ and __DTOR_LIST__ symbols; if they do,
+         the content from those variables are included but the symbols
+         defined here silently take precedence.  If they truly need to
+         be redefined, 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).
+
+         In particular this means that ld -Ur does not work, because
+         the proper __CTOR_LIST__ set by ld -Ur is overridden by a
+         bogus __CTOR_LIST__ set by the final link.  See PR 46.  */
+       ___CTOR_LIST__ = .;
+       __CTOR_LIST__ = .;
+       LONG (-1);
+       KEEP(*(.ctors));
+       KEEP(*(.ctor));
+       KEEP(*(SORT_BY_NAME(.ctors.*)));
+       LONG (0);
+     }
+    ${CONSTRUCTING+
+       /* See comment about __CTOR_LIST__ above.  The same reasoning
+          applies here too.  */
+       ___DTOR_LIST__ = .;
+       __DTOR_LIST__ = .;
+       LONG (-1);
+       KEEP(*(.dtors));
+       KEEP(*(.dtor));
+       KEEP(*(SORT_BY_NAME(.dtors.*)));
+       LONG (0);
+     }
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
+    ${RELOCATING+/* ??? Why is .gcc_exc here?  */}
     ${RELOCATING+ *(.gcc_exc)}
     ${RELOCATING+PROVIDE (etext = .);}
     ${RELOCATING+PROVIDE (_etext = .);}
@@ -129,6 +164,7 @@ SECTIONS
   .rdata ${RELOCATING+BLOCK(__section_alignment__)} :
   {
     ${R_RDATA}
+    . = ALIGN(4);
     ${RELOCATING+__rt_psrelocs_start = .;}
     ${RELOCATING+KEEP(*(.rdata_runtime_pseudo_reloc))}
     ${RELOCATING+__rt_psrelocs_end = .;}
@@ -183,7 +219,7 @@ SECTIONS
     ${R_IDATA67}
   }
   .CRT ${RELOCATING+BLOCK(__section_alignment__)} :
-  {                                    
+  {
     ${RELOCATING+___crt_xc_start__ = . ;}
     ${R_CRT_XC}
     ${RELOCATING+___crt_xc_end__ = . ;}
@@ -206,7 +242,7 @@ SECTIONS
      be at the beginning of the section to enable SECREL32 relocations with TLS
      data.  */
   .tls ${RELOCATING+BLOCK(__section_alignment__)} :
-  {                                    
+  {
     ${RELOCATING+___tls_start__ = . ;}
     ${R_TLS}
     ${RELOCATING+___tls_end__ = . ;}
This page took 0.02612 seconds and 4 git commands to generate.