diff mbox series

ld: Improve the comment about overriding __CTOR_LIST__ for mingw targets

Message ID 20180803083031.71826-1-martin@martin.st
State New
Headers show
Series ld: Improve the comment about overriding __CTOR_LIST__ for mingw targets | expand

Commit Message

Martin Storsjo Aug. 3, 2018, 8:30 a.m. UTC
Explain what happens in the cases if the user actually tries to
provide such symbols from source as well - it's actually a less
dramatic or problematic situation than originally outlined.

ld/Changelog:
2018-08-03  Martin Storsjo  <martin@martin.st>

        * scripttempl/pe.sc: Improve the comment about overriding
        __CTOR_LIST__ and __DTOR_LIST__ symbols.
        * scripttemp/pep.sc: Likewise.
---
mingw-w64 will probably move to unconditionally provide these symbols
themselves, in order to improve compatibility with other linkers (lld).
The fact that the linker also provides them only causes double list
terminator elements; if the code iterating the list is prepared to
handle that case, it actually turns out to work fine.
---
 ld/scripttempl/pe.sc  | 10 ++++++----
 ld/scripttempl/pep.sc | 10 ++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

-- 
2.15.2 (Apple Git-101.1)

Comments

Martin Storsjo Aug. 6, 2018, 10:51 a.m. UTC | #1
Hi Nick,

You handled this matter earlier (the original commit from last year and 
the later revert with a warning comment in the linker script) - can you 
comment on this patch that tries to clarify the comment?

// Martin

On Fri, 3 Aug 2018, Martin Storsjo wrote:

> Explain what happens in the cases if the user actually tries to

> provide such symbols from source as well - it's actually a less

> dramatic or problematic situation than originally outlined.

>

> ld/Changelog:

> 2018-08-03  Martin Storsjo  <martin@martin.st>

>

>        * scripttempl/pe.sc: Improve the comment about overriding

>        __CTOR_LIST__ and __DTOR_LIST__ symbols.

>        * scripttemp/pep.sc: Likewise.

> ---

> mingw-w64 will probably move to unconditionally provide these symbols

> themselves, in order to improve compatibility with other linkers (lld).

> The fact that the linker also provides them only causes double list

> terminator elements; if the code iterating the list is prepared to

> handle that case, it actually turns out to work fine.

> ---

> ld/scripttempl/pe.sc  | 10 ++++++----

> ld/scripttempl/pep.sc | 10 ++++++----

> 2 files changed, 12 insertions(+), 8 deletions(-)

>

> diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc

> index f56d783ea03..3a2a331f681 100644

> --- a/ld/scripttempl/pe.sc

> +++ b/ld/scripttempl/pe.sc

> @@ -106,10 +106,12 @@ SECTIONS

> 	  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).

> +	  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

> +	  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).

>

> 	  See PR 22762 for more details.  */

>        ___CTOR_LIST__ = .;

> diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc

> index 3c6c84da9bf..fb88c144430 100644

> --- a/ld/scripttempl/pep.sc

> +++ b/ld/scripttempl/pep.sc

> @@ -107,10 +107,12 @@ SECTIONS

> 	  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).

> +	  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

> +	  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).

>

> 	  See PR 22762 for more details.  */

>        ___CTOR_LIST__ = .;

> -- 

> 2.15.2 (Apple Git-101.1)

>

>
Nick Clifton Aug. 7, 2018, 7:47 a.m. UTC | #2
Hi Martin,

> ld/Changelog:

> 2018-08-03  Martin Storsjo  <martin@martin.st>

> 

>         * scripttempl/pe.sc: Improve the comment about overriding

>         __CTOR_LIST__ and __DTOR_LIST__ symbols.

>         * scripttemp/pep.sc: Likewise.


Approved and applied.

Cheers
  Nick
Martin Storsjo Aug. 7, 2018, 7:57 a.m. UTC | #3
On Tue, 7 Aug 2018, Nick Clifton wrote:

> Hi Martin,

>

>> ld/Changelog:

>> 2018-08-03  Martin Storsjo  <martin@martin.st>

>>

>>         * scripttempl/pe.sc: Improve the comment about overriding

>>         __CTOR_LIST__ and __DTOR_LIST__ symbols.

>>         * scripttemp/pep.sc: Likewise.

>

> Approved and applied.


Thanks Nick!

// Martin
Nick Clifton Aug. 7, 2018, 7:58 a.m. UTC | #4
Hi Martin,

> You handled this matter earlier (the original commit from last year and the later revert with a warning comment in the linker script) - can you comment on this patch that tries to clarify the comment?


Sorry - it was in my queue but I am a little bit behind at the moment.

Anyway, your patch has been reviewed, approved and committed.

Cheers
  Nick
diff mbox series

Patch

diff --git a/ld/scripttempl/pe.sc b/ld/scripttempl/pe.sc
index f56d783ea03..3a2a331f681 100644
--- a/ld/scripttempl/pe.sc
+++ b/ld/scripttempl/pe.sc
@@ -106,10 +106,12 @@  SECTIONS
 	  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).
+	  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
+	  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).
 
 	  See PR 22762 for more details.  */
        ___CTOR_LIST__ = .;
diff --git a/ld/scripttempl/pep.sc b/ld/scripttempl/pep.sc
index 3c6c84da9bf..fb88c144430 100644
--- a/ld/scripttempl/pep.sc
+++ b/ld/scripttempl/pep.sc
@@ -107,10 +107,12 @@  SECTIONS
 	  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).
+	  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
+	  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).
 
 	  See PR 22762 for more details.  */
        ___CTOR_LIST__ = .;