public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* PATCH: Add SORT_NONE to .init and .fini sections in linker sripts
@ 2012-07-31 21:00 H.J. Lu
  2012-07-31 22:56 ` Alan Modra
  0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2012-07-31 21:00 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 282 bytes --]

Hi,

Some linker sripts put .init and .fini sections in .text section. Those
targets fail PR ld/14156 tests.  This set of patches adds SORT_NONE to
.init and .fini sections in linker sripts.  Tested for xtensa-elf, d30v-elf,
d10v-elf and msp430-elf.  OK to install?

Thanks.


H.J.

[-- Attachment #2: binutils-pr14156-2a.patch --]
[-- Type: text/plain, Size: 801 bytes --]

2012-07-31  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14156
	* scripttempl/elfxtensa.sc: Add SORT_NONE to .init and .fini
	sections.

diff --git a/ld/scripttempl/elfxtensa.sc b/ld/scripttempl/elfxtensa.sc
index d330230..5e03797 100644
--- a/ld/scripttempl/elfxtensa.sc
+++ b/ld/scripttempl/elfxtensa.sc
@@ -402,7 +402,7 @@ cat <<EOF
 
     ${RELOCATING+${INIT_START}}
     ${RELOCATING+KEEP (*(.init.literal))}
-    ${RELOCATING+KEEP (*(.init))}
+    ${RELOCATING+KEEP (*(SORT_NONE(.init)))}
     ${RELOCATING+${INIT_END}}
 
     ${RELOCATING+${TEXT_START_SYMBOLS}}
@@ -413,7 +413,7 @@ cat <<EOF
 
     ${RELOCATING+${FINI_START}}
     ${RELOCATING+KEEP (*(.fini.literal))}
-    ${RELOCATING+KEEP (*(.fini))}
+    ${RELOCATING+KEEP (*(SORT_NONE(.fini)))}
     ${RELOCATING+${FINI_END}}
   } =${NOP-0}
 

[-- Attachment #3: binutils-pr14156-2b.patch --]
[-- Type: text/plain, Size: 3610 bytes --]

2012-07-31  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14156
	* scripttempl/elf32msp430.sc: Add SORT_NONE to .init and .fini
	sections.
	* elf32msp430_3.sc: Likewise.

diff --git a/ld/scripttempl/elf32msp430.sc b/ld/scripttempl/elf32msp430.sc
index 5098c17..beabd89 100644
--- a/ld/scripttempl/elf32msp430.sc
+++ b/ld/scripttempl/elf32msp430.sc
@@ -99,17 +99,17 @@ SECTIONS
   .text :
   {
     ${RELOCATING+. = ALIGN(2);}
-    *(.init)
-    *(.init0)  /* Start here after reset.  */
-    *(.init1)
-    *(.init2)  /* Copy data loop  */
-    *(.init3)
-    *(.init4)  /* Clear bss  */
-    *(.init5)
-    *(.init6)  /* C++ constructors.  */
-    *(.init7)
-    *(.init8)
-    *(.init9)  /* Call main().  */
+    *(SORT_NONE(.init))
+    *(SORT_NONE(.init0))  /* Start here after reset.  */
+    *(SORT_NONE(.init1))
+    *(SORT_NONE(.init2))  /* Copy data loop  */
+    *(SORT_NONE(.init3))
+    *(SORT_NONE(.init4))  /* Clear bss  */
+    *(SORT_NONE(.init5))
+    *(SORT_NONE(.init6))  /* C++ constructors.  */
+    *(SORT_NONE(.init7))
+    *(SORT_NONE(.init8))
+    *(SORT_NONE(.init9))  /* Call main().  */
 
     ${CONSTRUCTING+ __ctors_start = . ; }
     ${CONSTRUCTING+ *(.ctors) }
@@ -124,17 +124,17 @@ SECTIONS
     *(.text.*)
 
     ${RELOCATING+. = ALIGN(2);}
-    *(.fini9)  /*   */
-    *(.fini8)
-    *(.fini7)
-    *(.fini6)  /* C++ destructors.  */
-    *(.fini5)
-    *(.fini4)
-    *(.fini3)
-    *(.fini2)
-    *(.fini1)
-    *(.fini0)  /* Infinite loop after program termination.  */
-    *(.fini)
+    *(SORT_NONE(.fini9))
+    *(SORT_NONE(.fini8))
+    *(SORT_NONE(.fini7))
+    *(SORT_NONE(.fini6))  /* C++ destructors.  */
+    *(SORT_NONE(.fini5))
+    *(SORT_NONE(.fini4))
+    *(SORT_NONE(.fini3))
+    *(SORT_NONE(.fini2))
+    *(SORT_NONE(.fini1))
+    *(SORT_NONE(.fini0))  /* Infinite loop after program termination.  */
+    *(SORT_NONE(.fini))
 
     _etext = .;
   } ${RELOCATING+ > text}
diff --git a/ld/scripttempl/elf32msp430_3.sc b/ld/scripttempl/elf32msp430_3.sc
index c730c5d..0ddcf0f 100644
--- a/ld/scripttempl/elf32msp430_3.sc
+++ b/ld/scripttempl/elf32msp430_3.sc
@@ -75,17 +75,17 @@ SECTIONS
   .text :
   {
     ${RELOCATING+. = ALIGN(2);}
-    *(.init)
-    *(.init0)  /* Start here after reset.  */
-    *(.init1)
-    *(.init2)
-    *(.init3)
-    *(.init4)
-    *(.init5)
-    *(.init6)  /* C++ constructors.  */
-    *(.init7)
-    *(.init8)
-    *(.init9)  /* Call main().  */
+    *(SORT_NONE(.init))
+    *(SORT_NONE(.init0))  /* Start here after reset.  */
+    *(SORT_NONE(.init1))
+    *(SORT_NONE(.init2))
+    *(SORT_NONE(.init3))
+    *(SORT_NONE(.init4))
+    *(SORT_NONE(.init5))
+    *(SORT_NONE(.init6)) /* C++ constructors.  */
+    *(SORT_NONE(.init7))
+    *(SORT_NONE(.init8))
+    *(SORT_NONE(.init9))  /* Call main().  */
 
     ${CONSTRUCTING+ __ctors_start = . ; }
     ${CONSTRUCTING+ *(.ctors) }
@@ -100,17 +100,17 @@ SECTIONS
     *(.text.*)
 
     ${RELOCATING+. = ALIGN(2);}
-    *(.fini9)
-    *(.fini8)
-    *(.fini7)
-    *(.fini6)  /* C++ destructors.  */
-    *(.fini5)
-    *(.fini4)
-    *(.fini3)
-    *(.fini2)
-    *(.fini1)
-    *(.fini0)  /* Infinite loop after program termination.  */
-    *(.fini)
+    *(SORT_NONE(.fini9))
+    *(SORT_NONE(.fini8))
+    *(SORT_NONE(.fini7))
+    *(SORT_NONE(.fini6))  /* C++ destructors.  */
+    *(SORT_NONE(.fini5))
+    *(SORT_NONE(.fini4))
+    *(SORT_NONE(.fini3))
+    *(SORT_NONE(.fini2))
+    *(SORT_NONE(.fini1))
+    *(SORT_NONE(.fini0))  /* Infinite loop after program termination.  */
+    *(SORT_NONE(.fini))
 
     ${RELOCATING+ _etext = . ; }
   } ${RELOCATING+ > text}

[-- Attachment #4: binutils-pr14156-2c.patch --]
[-- Type: text/plain, Size: 729 bytes --]

2012-07-31  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14156
	* scripttempl/elfd10v.sc: Add SORT_NONE to .init and .fini
	sections.

diff --git a/ld/scripttempl/elfd10v.sc b/ld/scripttempl/elfd10v.sc
index 1cdfbdc..dc45cdd 100644
--- a/ld/scripttempl/elfd10v.sc
+++ b/ld/scripttempl/elfd10v.sc
@@ -87,10 +87,10 @@ SECTIONS
   .text ${RELOCATING+${TEXT_START_ADDR}} :
   {
     ${RELOCATING+${TEXT_START_SYMBOLS}}
-    KEEP (*(.init))
-    KEEP (*(.init.*))
-    KEEP (*(.fini))
-    KEEP (*(.fini.*))
+    KEEP (*(SORT_NONE(.init)))
+    KEEP (*(SORT_NONE(.init.*)))
+    KEEP (*(SORT_NONE(.fini)))
+    KEEP (*(SORT_NONE(.fini.*)))
     *(.text)
     *(.text.*)
     /* .gnu.warning sections are handled specially by elf32.em.  */

[-- Attachment #5: binutils-pr14156-2d.patch --]
[-- Type: text/plain, Size: 515 bytes --]

2012-07-31  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/14156
	* scripttempl/elfd30v.sc: Add SORT_NONE to .init and .fini
	sections.

diff --git a/ld/scripttempl/elfd30v.sc b/ld/scripttempl/elfd30v.sc
index d8d3fbe..df64f1b 100644
--- a/ld/scripttempl/elfd30v.sc
+++ b/ld/scripttempl/elfd30v.sc
@@ -110,8 +110,8 @@ SECTIONS
   {
     *(.text)
     *(.gnu.linkonce.t*)
-    *(.init)
-    *(.fini)
+    *(SORT_NONE(.init))
+    *(SORT_NONE(.fini))
     ${RELOCATING+ _etext = . ; }
   } ${RELOCATING+ > ${TEXT_MEMORY}}
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: Add SORT_NONE to .init and .fini sections in linker sripts
  2012-07-31 21:00 PATCH: Add SORT_NONE to .init and .fini sections in linker sripts H.J. Lu
@ 2012-07-31 22:56 ` Alan Modra
  2012-08-01  1:09   ` H.J. Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Modra @ 2012-07-31 22:56 UTC (permalink / raw)
  To: H.J. Lu; +Cc: binutils

On Tue, Jul 31, 2012 at 02:00:30PM -0700, H.J. Lu wrote:
> Some linker sripts put .init and .fini sections in .text section. Those
> targets fail PR ld/14156 tests.  This set of patches adds SORT_NONE to
> .init and .fini sections in linker sripts.  Tested for xtensa-elf, d30v-elf,
> d10v-elf and msp430-elf.  OK to install?

OK, but please add SORT_NONE to elf.sc too.

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: Add SORT_NONE to .init and .fini sections in linker sripts
  2012-07-31 22:56 ` Alan Modra
@ 2012-08-01  1:09   ` H.J. Lu
  2012-08-02 13:52     ` H.J. Lu
  0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2012-08-01  1:09 UTC (permalink / raw)
  To: Binutils

On Tue, Jul 31, 2012 at 3:56 PM, Alan Modra <amodra@gmail.com> wrote:
> On Tue, Jul 31, 2012 at 02:00:30PM -0700, H.J. Lu wrote:
>> Some linker sripts put .init and .fini sections in .text section. Those
>> targets fail PR ld/14156 tests.  This set of patches adds SORT_NONE to
>> .init and .fini sections in linker sripts.  Tested for xtensa-elf, d30v-elf,
>> d10v-elf and msp430-elf.  OK to install?
>
> OK, but please add SORT_NONE to elf.sc too.
>
Here is the additional patch I checked in.  I'd like to backport
it to 2.23 since SORT_NONE isn't handled properly.

-- 
H.J.
---
	PR ld/14156
	* ldlang.c (wild_sort): Properly handle by_none.

	* scripttempl/elf.sc: Add SORT_NONE to .init and .fini sections.

diff --git a/ld/ldlang.c b/ld/ldlang.c
index 5a4eef7..5327e12 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -2462,7 +246@@ -3512,8 +3512,6 @@ update_wild_statements (lang_statement_u
 		      if (sort_section == by_name)
 			sec->spec.sorted = by_alignment_name;
 		      break;
-		    case by_none:
-		      sec->spec.sorted = none;
 		    default:
 		      break;
 		    }
2,9 @@ wild_sort (lang_wild_statement_type *wild,
       /* Here either the files are not sorted by name, or we are
 	 looking at the sections for this file.  */

-      if (sec != NULL && sec->spec.sorted != none)
+      if (sec != NULL
+	  && sec->spec.sorted != none
+	  && sec->spec.sorted != by_none)
 	if (compare_section (sec->spec.sorted, section, ls->section) < 0)
 	  break;
     }
diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
index 17c2cf1..51a655e 100644
--- a/ld/scripttempl/elf.sc
+++ b/ld/scripttempl/elf.sc
@@ -462,7 +462,7 @@ cat <<EOF
   .init         ${RELOCATING-0} :
   {
     ${RELOCATING+${INIT_START}}
-    KEEP (*(.init))
+    KEEP (*(SORT_NONE(.init)))
     ${RELOCATING+${INIT_END}}
   } ${FILL}

@@ -483,7 +483,7 @@ cat <<EOF
   .fini         ${RELOCATING-0} :
   {
     ${RELOCATING+${FINI_START}}
-    KEEP (*(.fini))
+    KEEP (*(SORT_NONE(.fini)))
     ${RELOCATING+${FINI_END}}
   } ${FILL}
   ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: PATCH: Add SORT_NONE to .init and .fini sections in linker sripts
  2012-08-01  1:09   ` H.J. Lu
@ 2012-08-02 13:52     ` H.J. Lu
  0 siblings, 0 replies; 4+ messages in thread
From: H.J. Lu @ 2012-08-02 13:52 UTC (permalink / raw)
  To: Binutils

On Tue, Jul 31, 2012 at 6:09 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Jul 31, 2012 at 3:56 PM, Alan Modra <amodra@gmail.com> wrote:
>> On Tue, Jul 31, 2012 at 02:00:30PM -0700, H.J. Lu wrote:
>>> Some linker sripts put .init and .fini sections in .text section. Those
>>> targets fail PR ld/14156 tests.  This set of patches adds SORT_NONE to
>>> .init and .fini sections in linker sripts.  Tested for xtensa-elf, d30v-elf,
>>> d10v-elf and msp430-elf.  OK to install?
>>
>> OK, but please add SORT_NONE to elf.sc too.
>>
> Here is the additional patch I checked in.  I'd like to backport
> it to 2.23 since SORT_NONE isn't handled properly.
>
> --
> H.J.
> ---
>         PR ld/14156
>         * ldlang.c (wild_sort): Properly handle by_none.
>
>         * scripttempl/elf.sc: Add SORT_NONE to .init and .fini sections.
>
> diff --git a/ld/ldlang.c b/ld/ldlang.c
> index 5a4eef7..5327e12 100644
> --- a/ld/ldlang.c
> +++ b/ld/ldlang.c
> @@ -2462,7 +246@@ -3512,8 +3512,6 @@ update_wild_statements (lang_statement_u
>                       if (sort_section == by_name)
>                         sec->spec.sorted = by_alignment_name;
>                       break;
> -                   case by_none:
> -                     sec->spec.sorted = none;
>                     default:
>                       break;
>                     }
> 2,9 @@ wild_sort (lang_wild_statement_type *wild,
>        /* Here either the files are not sorted by name, or we are
>          looking at the sections for this file.  */
>
> -      if (sec != NULL && sec->spec.sorted != none)
> +      if (sec != NULL
> +         && sec->spec.sorted != none
> +         && sec->spec.sorted != by_none)
>         if (compare_section (sec->spec.sorted, section, ls->section) < 0)
>           break;
>      }
> diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc
> index 17c2cf1..51a655e 100644
> --- a/ld/scripttempl/elf.sc
> +++ b/ld/scripttempl/elf.sc
> @@ -462,7 +462,7 @@ cat <<EOF
>    .init         ${RELOCATING-0} :
>    {
>      ${RELOCATING+${INIT_START}}
> -    KEEP (*(.init))
> +    KEEP (*(SORT_NONE(.init)))
>      ${RELOCATING+${INIT_END}}
>    } ${FILL}
>
> @@ -483,7 +483,7 @@ cat <<EOF
>    .fini         ${RELOCATING-0} :
>    {
>      ${RELOCATING+${FINI_START}}
> -    KEEP (*(.fini))
> +    KEEP (*(SORT_NONE(.fini)))
>      ${RELOCATING+${FINI_END}}
>    } ${FILL}
>    ${RELOCATING+PROVIDE (__${ETEXT_NAME} = .);}

I am checking this into 2.23 branch.

-- 
H.J.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-08-02 13:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-31 21:00 PATCH: Add SORT_NONE to .init and .fini sections in linker sripts H.J. Lu
2012-07-31 22:56 ` Alan Modra
2012-08-01  1:09   ` H.J. Lu
2012-08-02 13:52     ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).